navTimeout = 0;
startList = function() 
{
	if (document.all&&document.getElementById("topNavigation")) 
	{
//		preloadImages();
		
		navRoot = document.getElementById("topNavigation");
		timeToOpen=false;
		opencount = 0;
		navRoot.onmouseover=function()
		{
			if(!timeToOpen)
				navTimeout = setTimeout("setTimeToOpen()", 300);						
		}
		navRoot.onmouseout=function()
		{
			if(!timeToOpen)
			{
				clearTimeout(navTimeout);
			}
			setTimeout("resetTimeToOpen()", 1000);
		}

		for (i=0; i<navRoot.childNodes.length; i++) 
		{
			node = navRoot.childNodes[i];

			if (node.nodeName=="LI") 
			{
				node.onmouseover=function() 
				{
					activeElement = this;
					if (timeToOpen)
					{
						opencount++;
						this.className+=" over";
						hideSelectBoxes(true);
						
						nextNode = this.nextSibling;
						if (nextNode && nextNode.nodeName=="LI")
						{
							nextNode.className+=" rightOfOver";					
						}
					}
				}
				node.onmouseout=function() 
				{
					opencount--;
					this.className=this.className.replace(" over", "");
					hideSelectBoxes(false);
					
					nextNode = this.nextSibling;
					if (nextNode && nextNode.nodeName=="LI")
					{
						nextNode.className=nextNode.className.replace(" rightOfOver", "");
					}					
				}
				for (j=0; j<node.childNodes.length; j++) 
				{
					child = node.childNodes[j];
					if (child.nodeName=="UL")
					{
						for (k=0; k<child.childNodes.length; k++)
						{
							grandChild = child.childNodes[k];						
							if (grandChild.nodeName=="LI") 
							{
								grandChild.onmouseover=function() 
								{
									this.className+=" over";
									hideSelectBoxes(true);
								}
								grandChild.onmouseout=function() 
								{
									this.className=this.className.replace(" over", "");
									hideSelectBoxes(false);
								}
							}						
						}
					}
				}
			}			
		}
	}
	
	
	if (document.getElementById("topNavigation")) 
	{
		navRoot = document.getElementById("topNavigation");

		for (i=0; i<navRoot.childNodes.length; i++) 
		{
			node = navRoot.childNodes[i];

			if (node.nodeName=="LI") 
			{
				for (j=0; j<node.childNodes.length; j++) 
				{
					child = node.childNodes[j];
					if (child.nodeName=="UL")
					{
						for (k=0; k<child.childNodes.length; k++)
						{
							grandChild = child.childNodes[k];						
							if (grandChild.nodeName=="LI") 
							{
								grandChild.onclick=function()
								{
									if (this.childNodes[0].nodeName=="A")
									{
										document.location.href=this.childNodes[0].href;
									}
								}
							}						
						}
					}
				}
			}			
		}
	}
}

function setTimeToOpen()
{
	timeToOpen = true;
	opencount = 0;
	activeElement.onmouseover();
}

function resetTimeToOpen()
{
	if (!opencount || opencount < 0)
		timeToOpen = false;
}

function hideSelectBoxes(hide)
{
	inputs = document.getElementsByTagName("select");
	var inputsLength = inputs.length;

	for (j = 0; j < inputsLength; j++)
	{
		if (inputs[j].className.indexOf("navHide") >= 0)
		{
			if (hide)
			{
				inputs[j].style.visibility = "hidden";
			}
			else
			{
				inputs[j].style.visibility = "visible";
			}
		}
	}	
}
/*
function preloadImages()
{
	image1 = new Image();
	image1.src = "/images/navigation/brand-tab-background.gif";

	image2 = new Image();
	image2.src = "/images/navigation/brand-tab-background-right-over.gif";

	image3 = new Image();
	image3.src = "/images/navigation/leftmost-tab.gif";

	image4 = new Image();
	image4.src = "/images/navigation/leftmost-tab-over.gif";

	image5 = new Image();
	image5.src = "/images/navigation/rightmost-tab.gif";

	image6 = new Image();
	image6.src = "/images/navigation/tab-background.gif";

	image7 = new Image();
	image7.src = "/images/navigation/tab-seperator.gif";

	image8 = new Image();
	image8.src = "/images/navigation/tab-seperator-left-over.gif";

	image9 = new Image();
	image9.src = "/images/navigation/tab-seperator-right-over.gif";
}
*/
$(document).ready(function() {
	startList();
});
