var arrDisp = new Array();
var iDisp = 0;
var actelmarr = new Array();
var elmTextAct = "";
var tim;
var aid;

function showulelmCler(elmchil, elmthis){

  clearTimeout(tim);
  tim = setTimeout("hideulelm('" + elmchil + "', '" + elmthis + "')", 600); 
}

function showulelm(elmchil, elmthis){

  clearTimeout(tim);
  tim = setTimeout("hideulelm('" + elmchil + "', '" + elmthis + "')", 200); 
}

function hideulelm(elmchil, elmthis){
  clearTimeout(tim);
  if(document.getElementById(elmchil)){
    document.getElementById(elmchil).style.display = "";

    aid = "aid" + elmchil.substring(2);
    if(document.getElementById(aid)){
      document.getElementById(aid).style.backgroundColor = "#a4c800";
    }

    elmTextAct = elmchil;
  } else if (document.getElementById(elmthis)) {
    document.getElementById(elmthis).style.display = "";

    aid = "aid" + elmthis.substring(2);
    if(document.getElementById(aid)){
      document.getElementById(aid).style.backgroundColor = "#a4c800";
    }

    elmTextAct = elmthis;
  } else {
    elmTextAct = "hlavni";
  }
  
  actelmarr[1] = elmTextAct;

  var ia = 2;
  while(ia < 1000){

    obj = document.getElementById(elmTextAct).parentNode;
    if(obj.id != ''){
      actelmarr[ia] = obj.id;
      elmTextAct = obj.id;
      if(obj.id == "hlavni"){
        break;
      }
      ia ++ ;
    } else {
      break;
    }
  }
  
  var hlavni = document.getElementById('hlavni');
  arrDisp = new Array();
  iDisp = 0;
  projdi(hlavni);
  
  pocetElmI = arrDisp.length;
  while(pocetElmI > 0){
    if(document.getElementById(arrDisp[pocetElmI])){
      document.getElementById(arrDisp[pocetElmI]).style.display = "none";
    }
    pocetElmI -- ;
  }
  
  actelmarr = new Array();

}

function projdi(start1){
  var elmToArr;
  var a = 0;
  if(start1 != undefined){
    for(var x=0; x < start1.childNodes.length; x++){
      if((start1.childNodes[x].id != '') && (start1.childNodes[x].id != undefined)){ 
        if(document.getElementById(start1.childNodes[x].id).tagName == 'UL'){
          if (actelmarr.toString().indexOf(start1.childNodes[x].id) == -1){
            elmToArr = start1.childNodes[x].id;
            arrDisp[iDisp] = elmToArr;
            iDisp ++ ;
            start2 = document.getElementById(start1.childNodes[x].id);

            //var aidx = start1.childNodes[x].id;
            aid = "aid" + start1.childNodes[x].id.substring(2);
            if(document.getElementById(aid)){
              document.getElementById(aid).style.backgroundColor = "#585858";
            }

            if(start2 != undefined){
              projdi(start2.childNodes[x]);
            }
          } else {

          }

        } else {

        }
      }
      projdi(start1.childNodes[x]);
    }
  }

}

function setFontSize(velikost){

  document.getElementById('cms_stranka').style.fontSize = velikost;  
  setCookie('public4uFontSize', velikost, '999', '/');
  if(document.cookie == ''){
    alert('Tato funkce vyžaduje zapnuté cookies!');
  }
  
}


function setCookie(key, value, days, path) {
  value = encodeURIComponent(value);
  value+='; domain='+location.host;
  value+='; path='+path;
  var date = new Date();
  date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
  value+='; expires=' + date.toGMTString();
    document.cookie = key + '=' + value;
}




var actualLoad = "img_zah1";
var waitLoad = "img_zah2";
var adresarObr = "19339";
var actualLoadTmp = "";
var obnova = 3000;

function rotateImgLoad(){

  myDiv = document.getElementById(actualLoad);
  if (xmlHttp)
  {
    try
    {

      var params = "&adresarObr=" + adresarObr +
                   "&subakce=randoimg";
      xmlHttp.open('GET', 'http://' + document.location.host + '/redakce/ajax.php?akce=nahodnyobrp11' + params, true);
      xmlHttp.onreadystatechange = handleRequestStateChange;
      xmlHttp.send(null);


    }
    catch (e)
    {
      alert("Can't connect to server 2:\n" + e.toString());
    }
  }
  actualLoadTmp = actualLoad;
  actualLoad = waitLoad;
  waitLoad = actualLoadTmp;

}

function rotateImg(){
  if(document.getElementById(actualLoad)){
    document.getElementById(actualLoad).style.display = "none";
    document.getElementById(waitLoad).style.display = "";
    rotateImgLoad();
    setTimeout('rotateImg()', obnova);
  }
}

