var d = document;
var isIE=(document.all && !window.opera)?true:false;
var isOpera=(navigator.userAgent.indexOf("Opera")!=-1)?true:false;
var thisUser = null;
var thisHash = null;

var activeSettings = null;

function initOverLabels () {
  if (!document.getElementById) return;
  var labels, id, field;
  // Set focus and blur handlers to hide and show
  // labels with 'overlabel' class names.
  labels = document.getElementsByTagName('label');
  for (var i = 0; i < labels.length; i++) {
    if (labels[i].className == 'over') {
      // Skip labels that do not have a named association
      // with another field.
      id = labels[i].htmlFor || labels[i].getAttribute('for');
      if (!id || !(field = document.getElementById(id))) {
        continue;
      }
      // Change the applied class to hover the label
      // over the form field.
      labels[i].className = 'over';
      // Hide any fields having an initial value.
      if (field.value !== '') {
        hideLabel(field.getAttribute('id'), true);
      }
      // Set handlers to show and hide labels.
      field.onfocus = function () {
        hideLabel(this.getAttribute('id'), true);
      };
      field.onblur = function () {
        if (this.value === '') {
          hideLabel(this.getAttribute('id'), false);
        }
      };
      // Handle clicks to label elements (for Safari).
      labels[i].onclick = function () {
        var id, field;
        id = this.getAttribute('for');
        if (id && (field = document.getElementById(id))) {
          field.focus();
        }
      };
    }
  }
};

function hideLabel (field_id, hide) { var field_for; var labels = d.getElementsByTagName('label'); for (var i = 0; i < labels.length; i++) { field_for = labels[i].htmlFor || labels[i].getAttribute('for'); if (field_for == field_id) { labels[i].style.textIndent = (hide) ? '-10000px' : '0px'; return true; } } }

//window.onload = function () { setTimeout(initOverLabels, 50); createMainMenu(); };

var activeMenu = null;
var selectedMenu = null;

function createMainMenu() { var mainMenu = d.getElementById('main_menu'); var menuItem = mainMenu.getElementsByTagName('li'); for (var i = 0; i < menuItem.length; i++) { if (menuItem[i].parentNode == mainMenu && menuItem[i].getElementsByTagName('ul').length == 1) { if (isIE) { menuItem[i].onmouseover = function () {showMenu(this);}; menuItem[i].onmouseout = function () {hideMenu(this);} } else { menuItem[i].setAttribute("onmouseover", "showMenu(this);"); menuItem[i].setAttribute("onmouseout", "hideMenu(this);"); menuItem[i].setAttribute("onmousemove", "showMenu(this);"); } if (menuItem[i].className == 'selected') { selectedMenu = menuItem[i]; } } } }

function showMenu (par) { var v = par.getElementsByTagName('ul')[0]; if (v != activeMenu) activeMenu = v; activeMenu.style.visibility = 'visible'; }
function hideMenu () { if (activeMenu) { activeMenu.style.visibility = 'hidden'; } }

function fadeIn(obj, opacity) { if (opacity <= 100 && obj) { setOpacity(obj, opacity); opacity += 10; setTimeout(function () { fadeIn(obj, opacity) }, 50); } }
function fadeOut(obj, opacity) { if (opacity > 0 && obj) { setOpacity(obj, opacity); opacity -= 10; setTimeout(function () { fadeOut(obj, opacity) }, 50); } }
function setOpacity(obj, opacity) { opacity = (opacity == 100)?99.999:opacity; obj.style.filter = "alpha(opacity:"+opacity+")"; obj.style.KHTMLOpacity = opacity/100; obj.style.MozOpacity = opacity/101; obj.style.opacity = opacity/100; }

function addToAddressBook (box) { var co = d.getElementById('addressName'); if (box.checked==true) co.style.display = "table-row"; else co.style.display = "none"; }
function addressBook () { var el = d.getElementById('addressBook'); if (el.style.display != "block") el.style.display = "block"; else el.style.display = "none"; }
function insertAddressBookNumber (num) { var el = d.getElementById('phoneNumber'); el.value = num; addressBook(); }

function administracnibox() { var el = d.getElementById('administracnibox'); if (el.style.display != "block") el.style.display = "block"; else el.style.display = "none"; }

function setSet(name) { var a = d.getElementById(name); showSet(a); }
function showSet (par) { if (par != activeSettings) { hideSet (); activeSettings = par; par.className = "selected"; pan = d.getElementById(par.id+"Box"); pan.style.display = "block"; } }
function hideSet () { if (activeSettings) { activeSettings.className = ''; pan = d.getElementById(activeSettings.id+"Box"); pan.style.display = "none"; } }

function makeNav () {
    var img = d.getElementById("photo"); var goLeft = d.getElementById("goLeft"); var goRight = d.getElementById("goRight"); var des = d.getElementById("photoDes"); var project = d.getElementById("project");
    if (goLeft) { var goLeftImg = goLeft.getElementsByTagName("IMG"); goLeft.style.width = '200px'; goLeft.style.height = img.height+'px'; goLeftImg[0].style.width = '200px'; goLeftImg[0].style.height = img.height+'px'; }
    if (goRight) { var goRightImg = goRight.getElementsByTagName("IMG"); goRight.style.width = '200px'; goRight.style.height = img.height+'px'; goRightImg[0].style.width = '200px'; goRightImg[0].style.height = img.height+'px'; goRight.style.left = '200px'; }
    if (project && img) project.style.width = img.width+'px';
    if (des) des.style.top = (img.height-15)+'px';
    if (window.name == 'galerieX') window.resizeTo((img.width+25), (img.height+75));
}

if (d.captureEvents) { if (Event.KEYUP) { d.captureEvents( Event.KEYUP ); } }
d.onkeyup = alertkey;

function alertkey(e) { if (!e) { if (window.event) { e = window.event; } else {return;} } if (typeof(e.which) == 'number') e = e.which; else if (typeof( e.keyCode ) == 'number') e = e.keyCode; else if (typeof( e.charCode ) == 'number') e = e.charCode; else return; {
	if (e == 37) { if (previousPic) {location.href=previousPic;}}
	if (e == 39) { if (nextPic) {location.href=nextPic;}}
    //if (e == 38) { if (allPic) {location.href=allPic;}}
} }

function removeFader () { var box = document.getElementById("fader"); box.style.display = "none"; }

//setTimeout('O331797()', 10000);
function billboarddetect() { var blocked = true; var e = d.getElementsByTagName("iframe"); for (var i = 0; i < e.length; i++) if ( (e[i].src.indexOf("billboard.cz") > -1) && e[i].setAttribute && e[i].style.visibility != "hidden" && e[i].style.display != "none") blocked = false; if (!blocked) { if (typeof(google_num_ad_slots) == 'undefined') blocked = true; else if (google_num_ad_slots < 2) blocked = true; } var ele = d.getElementById("billboard1"); if (!ele) blocked = true; else if (!ele.setAttribute || ele.style.visibility == "hidden" || ele.style.display == "none") blocked = true; ele = d.getElementById("billboard1"); if (!ele) blocked = true; else if (!ele.setAttribute || ele.style.visibility == "hidden" || ele.style.display == "none") blocked = true; return blocked; }

function countPoints (user, hash) { if (billboarddetect()) { var url = "http://livesms.cz/add_points.php?user="+user+"&hash="+hash; if (window.ActiveXObject) { httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } else { httpRequest = new XMLHttpRequest(); } httpRequest.open("GET", url, true); httpRequest.send(null); } }

function duelFotek (num) { var fotka1 = d.getElementById("duelFotka1"); var fotka2 = d.getElementById("duelFotka2"); if (num == "1") { fotka1.style.display = "block"; fotka2.style.display = "none"; } else if (num == "2") { fotka2.style.display = "block"; fotka1.style.display = "none"; } }

function ConfirmDelete (url) { if (window.confirm("Opravdu chcete vymazat zvolený záznam?!")){ parent.top.location.href=url; } }

// ***** FLASH EMBED *****
var embedVar = "";
var swfTransparent = false;
function flashEmbed (FLASHPATH,WIDTH,HEIGHT,BGCOLOR,QUALITY,MENU,BORDER,TRANSPARENT,FLASHVARS,LOOP) { var hasParams = (FLASHPATH.indexOf("?") != -1)?true:false; var pathConcat = "?"; if (hasParams) { pathConcat = "&"; } if ((isIE && TRANSPARENT != undefined) || swfTransparent) { embedVar = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\""+WIDTH+"\" height=\""+HEIGHT+"\"><param name=\"allowScriptAccess\" value=\"sameDomain\" /><param name=\"movie\" value=\""+FLASHPATH+pathConcat+"\" /><param name=\"flashvars\" value=\""+FLASHVARS+"\" /><param name=\"quality\" value=\""+QUALITY+"\" /><param name=\"menu\" value=\""+MENU+"\" /><param name=\"loop\" value=\""+LOOP+"\" /><param name=\"bgcolor\" value=\""+BGCOLOR+"\" /><param name=\"wmode\" value=\""+TRANSPARENT+"\" /><embed src=\""+FLASHPATH+pathConcat+"\" flashvars=\""+FLASHVARS+"\" quality=\""+QUALITY+"\" menu=\""+MENU+"\" loop=\""+LOOP+"\" bgcolor=\""+BGCOLOR+"\" width=\""+WIDTH+"\" height=\""+HEIGHT+"\" wmode=\""+TRANSPARENT+"\" name=\""+FLASHPATH+"\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></object>"; } else { embedVar = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\""+WIDTH+"\" height=\""+HEIGHT+"\"><param name=\"allowScriptAccess\" value=\"sameDomain\" /><param name=\"movie\" value=\""+FLASHPATH+pathConcat+"\" /><param name=\"flashvars\" value=\""+FLASHVARS+"\" /><param name=\"quality\" value=\""+QUALITY+"\" /><param name=\"menu\" value=\""+MENU+"\" /><param name=\"loop\" value=\""+LOOP+"\" /><param name=\"bgcolor\" value=\""+BGCOLOR+"\" /><embed src=\""+FLASHPATH+pathConcat+"\" flashvars=\""+FLASHVARS+"\" quality=\""+QUALITY+"\" menu=\""+MENU+"\" loop=\""+LOOP+"\" bgcolor=\""+BGCOLOR+"\" width=\""+WIDTH+"\" height=\""+HEIGHT+"\" name=\""+FLASHPATH+"\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></object>"; } d.write(embedVar); }

function passwordStrength (password) { var desc = new Array(); desc[0] = "Velice slabé"; desc[1] = "Slabé"; desc[2] = "Slabší průměr"; desc[3] = "Průměrné"; desc[4] = "Silné"; desc[5] = "Velice silné"; var score   = 0; if (password.length > 6) score++; if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++; if (password.match(/\d+/)) score++; if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) )	score++; if (password.length > 12) score++; d.getElementById("passwordDescription").innerHTML = desc[score]; d.getElementById("passwordStrength").className = "strength" + score; }

function emb (znak) { var textarea = d.getElementById("contentmessage"); textarea.value = textarea.value+' '+znak; }

var dom = {
	gI : function (el) { return d.getElementById(el); },
	cT : function(txt) { return d.createTextNode(txt); },
	cE : function (el) { return d.createElement(el); },
	aC : function (p,c) { return p.appendChild(c); },
	aE : function (elm,evtType,evtFn,set) { if (d.addEventListener) { if ((elm == window) && window.opera){ elm == document; } elm.addEventListener(evtType,evtFn,set); } else { elm.attachEvent('on' + evtType,evtFn); } },
	rE : function (elm,evtType,evtFn,set) { if (d.addEventListener) { if ((elm == window) && window.opera) elm == document; elm.removeEventListener(evtType,evtFn,set); } else { elm.detachEvent('on' + evtType,evtFn); } },
	fE : function(e) { if (typeof e == 'undefined') e = window.event; return e; }
}

function mapacr (kolik) { if(kolik < 8) { d.getElementById('mapacr').style.backgroundPosition = "0px -"+(kolik*160)+"px"; } else { d.getElementById('mapacr').style.backgroundPosition = "-200px -"+((kolik-7)*160)+"px"; } }