// Created a long, long time ago by Tanny O'Haley
// Update history.
// 24 Oct 2006 - Added to http://tanny.ica.com
// 14 Jul 2006 - Modified the way the iframe is added to the DOM. I no longer use 
//			innerHTML but use DOM methods.
// 15 Sep 2006 - Added a check to see if the target element onmouseout is contained
//			in the onmouseout element. If it is then I dont' remove the
//			sfhover class. I made use of the Microsoft proprietary
//			obj.contains() method.
//		 Added check to make sure that the sfhover class is not already in
//			the li element.
//

function hide_selects()
{
	var select1=document.getElementById("cti");
	var select2=document.getElementById("mnm");
	select1.style.visibility="hidden";
	select2.style.visibility="hidden";
}

function show_selects()
{
	var select1=document.getElementById("cti");
	var select2=document.getElementById("mnm");
	select1.style.visibility="visible";
	select2.style.visibility="visible";
}

sfHover = function() {
	// Support the standard nav without a class of nav.
	var el = document.getElementById("nav");
	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" && navigator.appVersion.substr(22,3)!="7.0") {
		
		// 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 sfhover class to the li.
			ieLIs[i].onmouseover=function() {
				if(!/\bsfhover\b/.test(this.className))
				{
					this.className+=" sfhover";
					hide_selects();
				}
			}
			ieLIs[i].onmouseout=function() {
				if(!this.contains(event.toElement))
				{
					this.className=this.className.replace(' sfhover', '');
					show_selects();
				}
			}
		}
	} 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('nav').getElementsByTagName('li');
		for (var i=0; i<ieLIs.length; i++) if (ieLIs[i]) {
			ieLIs[i].onmouseover=function() {this.className+=" sfhover";hideSelects();}
			ieLIs[i].onmouseout=function() {this.className=this.className.replace(' sfhover', '');showSelects()}
		}
	}
}

// If IE 5.0 hide and show the select statements.
function hideSelects(){
    if (document.getElementById("cti"))
    {
        var select1=document.getElementById("cti");
        select1.style.display="block";
	}
	if (document.getElementById("mnm"))
	{
	    var select2=document.getElementById("mnm");
		select2.style.display="block";
    }
}

function showSelects(){
	
}

// Run this only for IE.
if (window.attachEvent) window.attachEvent('onload', sfHover);
// end
