function theHover() {
	// Support the standard nav without a class of nav.
	var el = document.getElementById("menu");
	if(!/\bnav\b/.test(el.className) && el.tagName == "UL")
		setHover(el);

	// Find all unordered lists.
	var ieNavs = document.getElementsByTagName('ul');
	for(i=0; i<ieNavs.length; i++) {
		var ul = ieNavs[i];
		// If they have a class of nav add the menu hover.
		if(/\bnav\b/.test(ul.className))
			setHover(ul);
	}
}

function setHover(nav) {
	var ieULs = nav.getElementsByTagName('ul');
	if (navigator.appVersion.substr(22,3)!="5.0") {
		// IE script to cover <select> elements with <iframe>s
		for (j=0; j<ieULs.length; j++) {
			var ieMat=document.createElement('iframe');
			if(document.location.protocol == "https:")
				ieMat.src="javascript:false;";
			else if(window.opera != "undefined")
				ieMat.src="";
			else
				ieMat.src="javascript:false;";
			
			ieMat.scrolling="no";
			ieMat.frameBorder="0";
			ieMat.style.width=ieULs[j].offsetWidth+3+"px";
			ieMat.style.height=ieULs[j].offsetHeight+3+"px";
			ieMat.style.zIndex="-1";
			ieULs[j].insertBefore(ieMat, ieULs[j].childNodes[0]);
			ieULs[j].style.zIndex="3";
		}
		// IE script to change class on mouseover
		var ieLIs = nav.getElementsByTagName('li');
		for (var i=0; i<ieLIs.length; i++) if (ieLIs[i]) {
			// Add a theHover class to the li.
			ieLIs[i].onmouseover=function() {
				var browser = navigator.appName;
	
				if (browser == "Microsoft Internet Explorer") {
					if(!/\btheHover\b/.test(this.className))
						this.className+=" theHover";
				}
			}
			ieLIs[i].onmouseout=function() {
				var browser = navigator.appName;
	
				if (browser == "Microsoft Internet Explorer") {
					if(!this.contains(event.toElement))
						this.className=this.className.replace(' theHover', '');	
				}
			}
		}
	} else {
		// IE 5.0 doesn't support iframes so hide the select statements on hover and show on mouse out.
		// IE script to change class on mouseover
		var ieLIs = document.getElementById('menu').getElementsByTagName('li');
		for (var i=0; i<ieLIs.length; i++) if (ieLIs[i]) {
			ieLIs[i].onmouseover=function() {this.className+=" theHover";hideSelects();}
			ieLIs[i].onmouseout=function() {this.className=this.className.replace(' theHover', '');showSelects()}
		}
	}
}

// If IE 5.0 hide and show the select statements.
function hideSelects(){
	var oSelects=document.getElementsByTagName("select");
	for(var i=0;i<oSelects.length;i++)
		oSelects[i].className+=" hide";
}

function showSelects(){
	var oSelects=document.getElementsByTagName("select");
	for(var i=0;i<oSelects.length;i++)
		oSelects[i].className=oSelects[i].className.replace(" hide","");
}

window.onload = function() {
	theHover();
}