sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("TD");
	for (var i=0; i<sfEls.length; i++) 
	{	
		sfEls[i].onmouseover=function() {
			if (this.className.indexOf("sfhover") < 0)
			{
				this.className+=" sfhover";
			}
			subTable = document.getElementById("sub" + this.id);
			if (subTable)
			{
				subTable.style.display = "block";
				subDiv = document.getElementById("subnav");
				//subDiv.style.display = "block";
				subDiv.style.visibility = "visible";
			}
		}
		sfEls[i].onmouseout=function(e) {
			
			var relTarg;
			if (!e) var e = window.event;
			if (e.relatedTarget) relTarg = e.relatedTarget;
			else if (e.toElement) relTarg = e.toElement;
				
							
			if (this.parentNode.parentNode.parentNode.id.indexOf('sub') >= 0)
			{ //this part handles it if this is part of the sub menu
				thisParent = null; //if found will equal the tbody
				relTargParent = null; //if found will equal the tbody
				if (this.parentNode)
				{
					if (this.parentNode.parentNode)
					{
							thisParent = this.parentNode.parentNode;
					}	
				}
				if (relTarg.parentNode)
				{
					if (relTarg.parentNode.parentNode)
					{
						relTargParent = relTarg.parentNode.parentNode;
					}
				}
				if (relTargParent != thisParent)
				{
					thisParent.parentNode.style.display = "none";	
					subDiv = document.getElementById("subnav");
					//subDiv.style.display = "none";
					subDiv.style.visibility = "hidden";
					//hide all nodes
					var tblCells = document.getElementById("nav").getElementsByTagName("TD");
					for (var k=0; k<tblCells.length; k++) 
					{	
						tblCells[k].className = tblCells[k].className.replace(new RegExp("sfhover"), "");	
					}
				}
				else
				{//hide only this cell
					this.className=this.className.replace(new RegExp("sfhover"), "");
				}
				
			}
			else
			{ //this part handles it if this is part of the main menu
				subTable = document.getElementById("sub" + this.id);
				if(subTable)
				{
					subTableMatch = false;
					if (relTarg.parentNode)
					{
						if (relTarg.parentNode.parentNode)
						{
							if (relTarg.parentNode.parentNode.parentNode)
							{
								if (relTarg.parentNode.parentNode.parentNode == subTable)
								{
									subTableMatch = true;
								}
							}	
						}	
					}
					if (!subTableMatch)
					{
						//alert(this.className);
						this.className=this.className.replace(new RegExp("sfhover"), "");	
						//alert("subtable: " + subTable.nodeName + " relTarg: " + relTarg.parentNode.parentNode.ParentNode.nodeName);
						subTable.style.display = "none";	
						subDiv = document.getElementById("subnav");
						//subDiv.style.display = "none";
						subDiv.style.visibility = "hidden";
						
						
					}
				}
				else
				{
					this.className=this.className.replace(new RegExp("sfhover"), "");	

				}
			}
		}
	}
	
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
else if (window.addEventListener) window.addEventListener("load", sfHover, false);