// JavaScript Page

var mainNavOffset = 173;
var currentMenuNum = 0;
var newMenuNum = 0;
var currentSub = 0;
var newSub = "";

// Set Color Variables
var mainMenuRollColor = "#959595";
var mainMenuNormColor = "";
var subMenuRollColor = "#959595";
var subMenuNormColor = "#FFFFFF";
var subTextRollColor = "#FFFFFF";
var subTextNormColor = "#4E4E4E";

//  This function manages the submenu visibility, based on rolling over main menu items
function updateMenu(id, sub)
{
	if (currentSub == 0)
	{
		// Turn on the roll background color of the navItem
		document.getElementById("navItem" + id).style.backgroundColor = mainMenuRollColor;
		// Determine the x position for the submenu
		var navItem = document.getElementById("navItem" + id)
		var xLoc = mainNavOffset + navItem.offsetLeft
		document.getElementById("subNav" + id).style.left = xLoc + "px";
		//Turn on the submenu
		if(sub == 1) document.getElementById("subNav" + id).style.display = "block";
		// Set currentSub
		currentSub = id;
	}
	if (currentSub != 0 && currentSub != id)
	{
		// Turn off old submenu
		document.getElementById("navItem" + currentSub).style.backgroundColor = mainMenuNormColor;
		document.getElementById("subNav" + currentSub).style.display = "none";
		// Determine the x position for the new submenu
		var navItem = document.getElementById("navItem" + id)
		var xLoc = mainNavOffset + navItem.offsetLeft
		document.getElementById("subNav" + id).style.left = xLoc + "px";
		//Turn on new Submenu
		document.getElementById("navItem" + id).style.backgroundColor = mainMenuRollColor;
		if(sub == 1) document.getElementById("subNav" + id).style.display = "block";
		// Set currentSub
		currentSub = id;
	}
}

// This function turns off all submenus when the banner or content area is rolled over
function removeSubs(e)
{
	// This section captures the event and sets a variable (targ) = to the target of the event, works for all browsers
	var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;
		
	// This section removes the submenu if there is one visible	
	if (targ.parentNode.id != "mainNav" && currentSub != 0)
	{
		document.getElementById("navItem" + currentSub).style.backgroundColor = mainMenuNormColor;
		document.getElementById("subNav" + currentSub).style.display = "none";
		currentSub = 0;
	}
}

function itemRoll(e)
{
	var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) targ = targ.parentNode; // defeat Safari bug
	
	targ.style.backgroundColor = subMenuRollColor;
	targ.style.color = subTextRollColor;
}

function itemNorm(e)
{
	var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) targ = targ.parentNode; // defeat Safari bug
	
	targ.style.backgroundColor = subMenuNormColor;
	targ.style.color = subTextNormColor;
}

function linkTo(url)
{
	window.location = url;
}

function openTo(url)
{
	window.open(url);
}
