var sfHover;
sfHover = function()
{
	var pNav = document.getElementById("pNav");
	var sNav = document.getElementById("sNav");
	var sfEls = pNav.getElementsByTagName("span");
	var i;
	// exit if no primary navigation is found
	if (!pNav)
		return;

	for (i=0; i<sfEls.length; i++)
	{
		sfEls[i].onmouseover=function()
		{
			this.className+=" hover";
		} // onmouseover

		sfEls[i].onmouseout=function()
		{
		//alert(this.className);
			this.className = this.className.replace(new RegExp(" hover\\b"), "");
			this.className = this.className.replace(new RegExp("hover\\b"), "");
		} // onmouseout
		
		sfEls[i].onclick = function()
		{
			if (this.parentNode.className.match(new RegExp("openMenu\\b")))
			{
				this.parentNode.className = this.parentNode.className.replace(new RegExp("openMenu\\b"), "");
			} // if
			else
			{
				this.parentNode.className += " openMenu";
			} // else
		} // onclick
		

	}
	
	// exit if no secondary nav exists
	if (!sNav)
		return;
	
	sfEls = sNav.getElementsByTagName("span");

	for (i=0; i<sfEls.length; i++) {
		sfEls[i].onclick=function() {
			if (this.parentNode.className.match(new RegExp("openMenu\\b")))
			{
				this.parentNode.className=this.parentNode.className.replace(new RegExp("openMenu\\b"), "");
			} // if
			else
			{
					this.parentNode.className+=" openMenu";
			} // else
		} // onclick
		
		sfEls[i].onmouseover=function() {
			this.className+=" hover";
		} // onmouseover
		
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp("hover\\b"), "");
		} // onmouseout
	}
}

try
{
	window.addEventListener("load", sfHover, true);
}
catch(ex)
{
	window.attachEvent("onload", sfHover);
}

/* This is for DOM compliant browsers */
/*if (window.addEventListener)
	window.addEventListener("load", sfHover, true);*/
/* This is for IE on PC */
/*else if (window.attachEvent)
	window.attachEvent("onload", sfHover);*/
/* Now IE on Mac */
/*else if (document.getElementById)
	window.onload=sfHover;*/



