
//Browser Checks
var browser = navigator.userAgent.toLowerCase();
isGecko = (browser .indexOf("gecko") != -1);
isSafari = (browser .indexOf("safari") != -1);
isKonqueror = (browser.indexOf("konqueror") != -1);

//Main two checks used
var isIE	= (navigator.appName == "Microsoft Internet Explorer" && window.print);
var isBrowserDOM = (document.getElementById && document.getElementsByTagName);



//Helps out with the primary navigation
BindNavGoodness = function() 
{
	if (isBrowserDOM) 
	{
		var navRoot = document.getElementById("nav");
		if (navRoot != null)
		{
			for (i=0; i<navRoot.childNodes.length; i++) 
			{
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI")
				{
					//sets mouseover states on all navitems
					node.onmouseover=function() 
					{
						if (isIE)
						{
							this.className+=" over"; 
							SI_toggleSelects('hidden'); 
						}
					}
					
					node.onmouseout=function()
					{
						if (isIE)
						{
							this.className=this.className.replace(" over", "");
							SI_toggleSelects('visible');
						}
					}
					
					var links = node.getElementsByTagName("A");
					
					for (k=0; k<links.length; k++)
					{
						if (!(links[k].className && links[k].className == "navlink"))
						{
							links[k].onmouseover=function(){SetNavParent(this, true);}
							links[k].onmouseout=function(){SetNavParent(this, false);}
						}
					}
				}
			}
		}
	}
}

//Nice function to hide Select input boxes when in IE
//Thank you Sean Inman
function SI_toggleSelects(state) 
{
	if (isIE || isSafari) 
	{
		for (var i = 0; (sel = document.getElementsByTagName('select')[i]); i++)
		{
			sel.style.visibility = state;
		}
	}
}

function SetNavParent(subnavitem, isSelected)
{
	//get the parent LI tag
	nav = subnavitem.parentNode.parentNode.parentNode;
	//alert(nav.nodeName);
	if (nav.nodeName == "LI")
	{
		nav.className = (isSelected) ? "over" : "";
	}
}
