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 = "#CC33FF";
    }

    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 = "#CC33FF";
    }

    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 = "#660066";
            }

            if(start2 != undefined){
              projdi(start2.childNodes[x]);
            }
          } else {

          }

        } else {

        }
      }
      projdi(start1.childNodes[x]);
    }
  }

}