function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

/* fix to let IE support hover on li elements. IE-only. */
function ieHover() {
if (document.all && document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
  node = navRoot.childNodes[i];
  if (node.nodeName=="LI") {
  node.onmouseover=function() {
  this.className+=" over";
    }
  node.onmouseout=function() {
  this.className=this.className.replace
      (" over", "");
   }
   }
  }
 }
}

/* extension to the CSS hover menu to enable the hoverlock css class */
function addHoverLock() {
	if (document.getElementById) {
		var debugscreen = document.getElementById( "debuginfo" );
		// iterate over the top-level li elements of the menu.
		// each li gets an onmouseover that adds "hoverlock" to its class and removes "hoverlock"
		// from its siblings.
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					// first remove the hoverlock class at all toplevel menuitems.
					navRoot = document.getElementById("nav");
//					debugscreen.innerHTML= "this.classname: " + this.className + "\n" + debugscreen.innerHTML;
					for (i=0; i<navRoot.childNodes.length; i++) {
						node = navRoot.childNodes[i];
//						debugscreen.innerHTML= "class of current node: " + node.className + "\n" + debugscreen.innerHTML;
						if (node.nodeName =="LI" ) {
							node.className = node.className.replace(" hoverlock", "");
						}
					}
					// then give this item the hoverlock class. the "on" item (the currently selected topmenu item)
					// never gets a hoverlock because it's always on top anyway
					if(this.className.indexOf( "on" ) == -1 )
						this.className+=" hoverlock";					
//					debugscreen.innerHTML= "this.classname after replace: " + this.className + "\n" + debugscreen.innerHTML;
				}
			}
		}
	}
}

if (document.all && document.getElementById) {
	addLoadEvent(ieHover);	
}
addLoadEvent(addHoverLock);

