/*

define global variables and initial routines. After the html page loads, 
both setDropdowns() and setDefautls() are executed.

*/

var globalNav = "";
var sideNav = "";
var numDropdowns = 10;

window.onload = init;

function init()
{
	setDropdowns();
	setDefaults();

	try
	{
		resizeFrame();
	}
	catch (e)
	{
		
	}

}

/*

after the html page loads, setDropdowns() inserts the proper javascript code in
the "nav" section to allow the drop down menu functionality. This allows the
javascript to remain seperate from the html code.

*/

function setDropdowns()
{
	try
	{
		for (j = 0; j < numDropdowns; j++)
		{
			lis = document.getElementById("drop" + j).getElementsByTagName("li");

			if (lis.length != 0)
			{
				lis[0].parentNode.parentNode.onmouseover=function(){navshow(this);}
				lis[0].parentNode.parentNode.onmouseout=function(){navhide(this);}

				for (i = 0; i < lis.length; i++)
				{
					lis[i].onmouseover=function(){navRoll(this,true);}
					lis[i].onmouseout=function(){navRoll(this,false);}
					lis[i].className="navDefault";
				}
			}
		}
	}
	catch (e)
	{
		
	}
}

/*

after the html page loads, setDefaults() reads the two gloabl variables, 
globalNav and sideNav, and sets the defaults. For the global navigation, it 
determines which section is the default by matching the value of globalNav 
with the value of the alt attribute of the images that comprise the global 
navigation. If they match, then the img is dnamically changed to its selected 
state.

for the side navigation, a match is determined simply by checking the value of 
sideNav against that of each li attribute in the sidenav div block. Then the 
class name is changed to reflect the selected state.

if there isn't any default for either the global navigation or side navigation, 
keep either or both gobalNav and sideNav as empty strings.

*/

/*

Tuan this is the code for the Safari Fix. It needs to be merged with the function below.

function setDefaults()
{
	navIMG = document.getElementById("nav").getElementsByTagName("img");

	for (i = 0; i < navIMG.length; i++)
	{
		alt = navIMG[i].getAttribute("alt");

		if (globalNav == alt)
		{
			nodeIMGsrc = navIMG[i].getAttribute("src");
			nodeIMGsrc = nodeIMGsrc.substring(0,nodeIMGsrc.length - 7);
			nodeIMGsrc = nodeIMGsrc + "sel.gif";
			navIMG[i].setAttribute("src",nodeIMGsrc);
		}
	}

	if (sideNav != "")
	{
		navLI = document.getElementById("sidenav").getElementsByTagName("li");

		for (i = 0; i < navLI.length; i++)
		{
			text = navLI[i].firstChild.innerHTML;

			if (text == sideNav)
			{
				navLI[i].className = "selected";
			}
		}
	}
}

*/

function setDefaults()
{
	var blnNav_Collapsible = new Boolean(false);

	var navUL_LI;

	navIMG = document.getElementById("nav").getElementsByTagName("img");

	for (i = 0; i < navIMG.length; i++)
	{
		alt = navIMG[i].getAttribute("alt");

		if (globalNav == alt)
		{
			nodeIMGsrc = navIMG[i].getAttribute("src");
			nodeIMGsrc = nodeIMGsrc.substring(0,nodeIMGsrc.length - 7);
			nodeIMGsrc = nodeIMGsrc + "sel.gif";

			navIMG[i].setAttribute("src", nodeIMGsrc);
		}
	}

	if ( document.getElementById("sidenav") && (sideNav != "") )
	{
		navLI = document.getElementById("sidenav").getElementsByTagName("li");

		for (i = 0; i < navLI.length; i++)
		{

			text = navLI[i].firstChild.innerHTML;

			if (text == sideNav)
			{
				navLI[i].className = "selected";

				if (blnNav_Collapsible == true)
				{
					navUL_LI = navLI[i];
				}
			}
			else
			{
				if (blnNav_Collapsible == true)
				{
					if ( (navLI[i].parentNode.id != "sidenav") && (navLI[i].parentNode.parentNode.id != "sidenav") )
					{
						navLI[i].style.display = "none";
					}
				}
			}
		}

		if (navUL_LI != undefined)
		{
			if (navUL_LI.parentNode.parentNode.id == "sidenav")
			{
				for (i = 0; i < navUL_LI.childNodes.length; i++)
				{
					if (navUL_LI.childNodes[i].tagName == "UL")
					{
						for (j = 0; j < navUL_LI.childNodes[i].childNodes.length; j++)
						{
							if (navUL_LI.childNodes[i].childNodes[j].tagName == "LI")
							{
								navUL_LI.childNodes[i].childNodes[j].style.display = "block";
							}
							
						}
					}
				}
			}
			else
			{
				for (i = 0; i < navUL_LI.parentNode.childNodes.length; i++)
				{
					try
					{
						//if  (navUL_LI.parentNode.childNodes[i].tagName == "LI")
						{
							navUL_LI.parentNode.childNodes[i].style.display = "block";
						}
					}
					catch (e)
					{
		                	
					}
		        	}
			}
		}

  	}
}

/*

these drop down menu routines are activated by the rollover states in the
gloabl navigation. They not only show and hide the drop down menu, but also
set the rollover state for the main navigation.

*/

function show(which)
{
	document.getElementById(which).style.display = "block";

	node = document.getElementById(which).parentNode.firstChild.firstChild;

	if (node != undefined)
	{
		try
		{
			nodeImg = node.getAttribute("src");
  
			if (!(/_sel/.test(nodeImg)))
			{
				nodeImg = nodeImg.substring(0, nodeImg.length - 7);
				nodeImg = nodeImg + "on.gif";

				node.setAttribute("src", nodeImg);
			}
		}
		catch (e)
		{
			
		}
	}
}

function hide(which)
{
	document.getElementById(which).style.display = "none";

	node = document.getElementById(which).parentNode.firstChild.firstChild;

	if (node != undefined)
	{
		try
		{
			nodeImg = node.getAttribute("src");

			if (!(/_sel/.test(nodeImg)))
			{
				nodeImg = nodeImg.substring(0, nodeImg.length - 6);
				nodeImg = nodeImg + "off.gif";

				node.setAttribute("src", nodeImg);
			}
		}
		catch (e)
		{
			
		}
	}
}

function navshow(obj)
{
	nodeUL = obj.getElementsByTagName("ul")[0];

	if (nodeUL != undefined)
	{
		nodeUL.style.display = "block";
		nodeIMG = obj.getElementsByTagName("img")[0];
		nodeIMGsrc = nodeIMG.getAttribute("src");
		navState = nodeIMGsrc.substring(nodeIMGsrc.length - 7, nodeIMGsrc.length - 4);

		if (navState == "off")
		{
			nodeIMGsrc = nodeIMGsrc.substring(0, nodeIMGsrc.length - 7);
			nodeIMGsrc = nodeIMGsrc + "on.gif";
			nodeIMG.setAttribute("src", nodeIMGsrc);
		}
	}
}

function navhide(obj)
{
	nodeUL = obj.getElementsByTagName("ul")[0];

	if (nodeUL != undefined)
	{
		nodeUL.style.display = "none";
		nodeIMG = obj.getElementsByTagName("img")[0];
		nodeIMGsrc = nodeIMG.getAttribute("src");
		navState = nodeIMGsrc.substring(nodeIMGsrc.length - 7, nodeIMGsrc.length - 4);

		if (navState == "_on")
		{
			nodeIMGsrc = nodeIMGsrc.substring(0, nodeIMGsrc.length - 6);
			nodeIMGsrc = nodeIMGsrc + "off.gif";
			nodeIMG.setAttribute("src", nodeIMGsrc);
		}
	}
}

function navRoll(obj,status)
{
	if (status)
	{
		obj.className = "navRoll"; 
	}
	else
	{
		obj.className = "navDefault";
	}
}

/*

productIndustryRoll() is the routine that handles the functionality on the 
products by industry page. Each rollover state has a link associated with it -- 
these are defined in the industryLinks[] array. What's below are obviously 
placeholder links.



industryLinks = new Array(9);

industryLinks[1] = "/industries/aerospaceanddefense.asp";
industryLinks[2] = "/industries/architectureandengineering.asp";
industryLinks[3] = "/industries/governmentagency.asp";
industryLinks[4] = "/industries/governmentcontractors.asp";
industryLinks[5] = "/industries/itconsulting.asp";
industryLinks[6] = "/industries/projectmanufacturing.asp";
industryLinks[7] = "/industries/professionalservices.asp";
industryLinks[8] = "/industries/nonprofit.asp";

function productIndustryRoll(which)
{
	prodImg = document.getElementById("prodImage").getAttribute("src");
	prodSrc = prodImg.substring(0, prodImg.length - 5);
	prodSrc = prodSrc + which + ".gif";
	document.getElementById("prodImage").setAttribute("src", prodSrc);
	document.getElementById("prodImage").parentNode.parentNode.className = "bgroundRoll";
  
	nodeLI = document.getElementById("productIndustries").getElementsByTagName("li");

	for (i = 0; i < nodeLI.length; i++)
	{
		if (i == (which - 1))
		{
			nodeLI[i].className = "roll";
			document.getElementById("prodImage").parentNode.setAttribute("href", industryLinks[which]);
		}
		else
		{
			nodeLI[i].className = "default";
		}
	}
}*/