/* Global variables and initialization of variables */

var horizNavTimer;

function clearHorizNav() {
	var navRoot = document.getElementById('mainMenu');
	for (i=0; i<navRoot.childNodes.length; i++) {
		var node = navRoot.childNodes[i];
		if (node.nodeName == "LI") {
			node.className = node.className.replace(/ ?over/,"");
		}
	}
}

/* Parts that only work after page has loaded. */
window.onload = function() {
	/* Horizontal Navigation */
	// http://www.alistapart.com/articles/horizdropdowns
	if (document.getElementById && document.getElementById('mainMenu')) {
		var navRoot = document.getElementById('mainMenu');
		for (i=0; i<navRoot.childNodes.length; i++) {
			var node = navRoot.childNodes[i];
			if (node.nodeName == "LI") {
				node.onmouseover = function() {
					clearHorizNav();
					this.className = (this.className == "") ? "hover" : this.className + " hover";
					clearTimeout(horizNavTimer);
				}

				node.onmouseout = function() {
					horizNavTimer = setTimeout("clearHorizNav();",500)
				}
			}
		}
	}
}
