/* cshmenu: create dynamic menu
   parts are taken from http://www.javascriptkit.com/script/script2/csstopmenu.shtml
   Author: (2008) Laszlo Csirmaz http://www.ceu.hu/comp
   You are free to use this script
*/

function cssshow(){
//    this.style.zIndex=100;
    var ul=this.getElementsByTagName('ul')[0];
    var pt2=ul.parentNode; var offs=0;
    while(pt2){ 
           if(!isNaN(pt2.offsetLeft))offs += pt2.offsetLeft; 
           pt2=pt2.offsetParent; 
    }
    ul.style.left=offs+'px';
    ul.style.visibility='visible';
//    ul.style.zIndex=0;
}

function csshide(){
//    this.style.zIndex=0;
    var ul=this.getElementsByTagName('ul')[0];
    ul.style.visibility='hidden';
//    ul.style.zIndex=100;
}

function createcssmenu2(){
   var menu=document.getElementById('cssmenu');
   var ultags=menu.getElementsByTagName('ul');
   var newwidth=760/(1+ultags.length);
   for(var t=0; t<ultags.length; t++){
      var parent=ultags[t].parentNode;
      ultags[t].style.width=newwidth;
      ultags[t].style.visibility='hidden';
      var offs=0; var pt=parent;
      while(pt){ 
           offs += pt.offsetLeft; 
           pt=pt.offsetParent; 
      }
      ultags[t].style.left=offs+'px';
      if(parent.addEventListener){
          parent.addEventListener('mouseover',cssshow,true);
          parent.addEventListener('focus',cssshow,true);
          parent.addEventListener('mouseout',csshide,true);
          parent.addEventListener('blur',csshide,true);
          parent.addEventListener('active',cssshow,true);
      } else {
          parent.onmouseover=cssshow;
          parent.onfocus=cssshow;
          parent.onmouseout=csshide;
          parent.onblur=csshide;
      }
   }
}

if(window.addEventListener)
   window.addEventListener('load',createcssmenu2, false)
else if(window.attachEvent)
   window.attachEvent('onload',createcssmenu2)


