/* this method dynamicly attaches javascript(eventhandlers) to some
   Document Elements at Document Load. So we don't have to decorate
   every tag by hand... Also needed to keep code xhtml-valid
*/
insertJS = function() {
  if (document.all&&document.getElementById) { //Browserswitch catches IE look-a-likes
    navRoot = document.getElementById("navbar-top");
    for (i=0; i<navRoot.childNodes.length; i++) {
      node = navRoot.childNodes[i];
      if (node.className=="main-nav-pos") {
        node.onmouseover=function() {subOpen(this);}
        node.onmouseout=function() {subClose(this);}
        if (navigator.appName=="Microsoft Internet Explorer") { //Browserswitch just IE
        for (j=0; j<node.childNodes.length; j++) {
          subnode = node.childNodes[j];
          if (subnode.className=="main-nav-item") {
            subnode.onmouseover=function() {itemOn(this);}
            subnode.onmouseout=function() {itemOff(this);}
          } else if (subnode.className=="subnav") {
            for (k=0; k<subnode.childNodes.length; k++) {
              subnode.childNodes[k].onmouseover=function() {itemOn(this);}
              subnode.childNodes[k].onmouseout=function() {itemOff(this);}
            }
          }
        }
      }
    }
   }
   if (navigator.appName=="Microsoft Internet Explorer") { //Browserswitch just IE
    navRoot = document.getElementById("navblock-left");
    for (i=0; i<navRoot.childNodes.length; i++) {
        navRoot.childNodes[i].onmouseover=function() {itemOn(this);}
        navRoot.childNodes[i].onmouseout=function() {itemOff(this);}
    }
   }
  }
}
window.onload=insertJS;


function subOpen(oldnode) { // opens dropdown by changing the (style)class
 for (j=0; j<oldnode.childNodes.length; j++) {
  subnode = oldnode.childNodes[j];
  if (subnode.className=="subnav") {
    subnode.className="subnav-ie";
  }
 }
}

function subClose(oldnode) { // closes dropdown by changing the (style)class
 for (j=0; j<oldnode.childNodes.length; j++) {
  subnode = oldnode.childNodes[j];
  if (subnode.className=="subnav-ie") {
    subnode.className="subnav";
  }
 }
}

function itemOn(node) { //IE only: simulate not implemented :hover selector by by changing the (style)class
  node.className=node.className+"-ie";
}

function itemOff(node) { //IE only: simulate not implemented :hover selector by by changing the (style)class
  node.className=node.className.substring(0,node.className.length-3);
}