if (window.attachEvent){ window.attachEvent("onload", navOptionalHover);}
else if (window.addEventListener){ window.addEventListener("load", navOptionalHover, false);}
var previouslyOpenOptNav = null; //Tracks the last Nav LI to be opened.
var optSecondaryNavToKeepOpen = null; //Tracks the Nav LI of the current page, which should never be closed.
function navOptionalHover(){
	var primaryNavLIs = document.getElementById("optMainNav").childNodes;
	for( var i = 0; i < primaryNavLIs.length; i++ ){
		primaryNavLIs[i].onmouseover=function(){
			//Close the previously opened navigation item, in this optional navigation menu, by removing the over and active states.
			if( previouslyOpenOptNav != null ){
				previouslyOpenOptNav.className = previouslyOpenOptNav.className.replace(new RegExp("\\s?optMainNavOverState\\b"), "");
				previouslyOpenOptNav.className = previouslyOpenOptNav.className.replace(new RegExp("\\s?optMainNavActive\\b"), "");
			}
			//Close the previously opened navigation item (if any) in the main nav.
			if( typeof previouslyOpenMainNav != "undefined" && previouslyOpenMainNav != null ){
				previouslyOpenMainNav.className = previouslyOpenMainNav.className.replace(new RegExp("\\s?primaryNavOverState\\b"), "");
				previouslyOpenMainNav.className = previouslyOpenMainNav.className.replace(new RegExp("\\s?mainNavActive\\b"), "");
			}
			//Open the current nav being moused over by adding over and active states.
			this.className+=" optMainNavOverState"; //Opens the primary nav to show the secondary.
			this.className+=" optMainNavActive"; //Replaces the primary nav's arrow with a down arrow.
			previouslyOpenOptNav = this;
		}
	}
}
function showOptionalSecondaryNav( strNavID ){
	document.getElementById( strNavID ).className+= " optMainNavOverState"; //Opens the primary nav to show the secondary.
	document.getElementById( strNavID ).className+= " optMainNavActive"; //Replaces the primary nav's arrow with a down arrow.
	optSecondaryNavToKeepOpen = document.getElementById( strNavID ); //We never want to close the Secondary Nav we just opened, because it is the navigation for the current page.
}
function showOptionalTertiaryNav( strNavID ){
	document.getElementById( strNavID ).className+= " showTertiaryNav"; //Shows the tertiary nav, beneath the secondary.
	document.getElementById( strNavID ).className+= " optMainNavSecondaryNavActive"; //Replaces the secondary nav's arrow with a down arrow, to indicate that it's open.
	if( document.getElementById( strNavID ).getElementsByTagName( "ul" ).length > 0 ) { //Finding a UL here tells us that there are tertiary nav links.
		//Loop through each tertiary a tag. See if one of them links to the page we're currently on. If so, give that a tag the over state, indicating it's the current page.
		var tertiaryLinks = document.getElementById( strNavID ).getElementsByTagName( "ul" )[0].getElementsByTagName( "a" );
		for( var i = 0; i < tertiaryLinks.length; i++ ){
			if( tertiaryLinks[i].href == document.URL ){
				tertiaryLinks[i].parentNode.className += " tertiaryNavActive"; //This class actually needs to be applied to the LI wrapping the tertiary A link.
				break;
			}
		}
	}
}