function manageMainNav(whichOne)
{
	if (document.getElementById)
	{
		clearAllNavElements();
		
		if (whichOne != 'noSubNav')
		{
			document.getElementById(whichOne).style.backgroundColor = 'black';
			document.getElementById('sub' + whichOne).style.display = 'block';
			
			if ((whichOne == 'Nav1')&&(dropDownExists == true)) hideDropDown('activate');
		}
	}
}

function clearAllNavElements()
{
	if (document.getElementById)
	{
		for (i=1;i<=1;i++)
		{
			document.getElementById('Nav' + i).style.backgroundColor = 'black';
			document.getElementById('subNav' + i).style.display = 'none';
		}
		
		clearAllSubNavs();
		
		if (dropDownExists == true) hideDropDown('deactivate');
	}
}

function clearAllSubNavs()
{
	if (document.getElementById)
	{
		var allElements = document.getElementsByTagName('ul'); 
		for (i = 0; i < allElements.length; i++)
		{
			if (allElements[i].className == 'tertNav') allElements[i].style.display='none';
			if (allElements[i].className == 'tertNavtwo') allElements[i].style.display='none';

		}
	}
}

function showPopup(thisOne,thisParent)
{
	if (document.getElementById)
	{
		document.getElementById(thisOne).style.top = getAbsoluteTop(thisParent) + 20 + 'px';
		document.getElementById(thisOne).style.left = getAbsoluteLeft(thisParent) - 100 + 'px';
		document.getElementById(thisOne).style.display = 'block';
	}
}

function closePopup(thisOne)
{
	document.getElementById(thisOne).style.display = 'none';
}

function subNav(thisOne)
{
	if (document.getElementById)
	{
		clearAllSubNavs();
		
		document.getElementById(thisOne + 'tert').style.top = getAbsoluteTop(thisOne) - subNavHeightFix + 'px';
		document.getElementById(thisOne + 'tert').style.left = getAbsoluteLeft(thisOne) + 199 - subNavLeftFix + 'px';
		document.getElementById(thisOne + 'tert').style.display = 'block';

	}
}


function getAbsoluteLeft(objectId)
{
	if (document.getElementById)
	{
		o = document.getElementById(objectId)
		oLeft = o.offsetLeft
		while(o.offsetParent!=null)
		{
			oParent = o.offsetParent 
			oLeft += oParent.offsetLeft
			o = oParent
		}
		
		return oLeft
	}
}

function getAbsoluteTop(objectId)
{
	if (document.getElementById)
	{
		o = document.getElementById(objectId)
		oTop = o.offsetTop;
		while(o.offsetParent!=null)
		{
			oParent = o.offsetParent
			oTop += oParent.offsetTop
			o = oParent
		}
		
		return oTop
	}
}

var useragent = navigator.userAgent;
var bSaf = useragent.indexOf('Safari');
var bIE = useragent.indexOf('MSIE');

var subNavLeftFix = 0;
var subNavHeightFix = 0;

if (bSaf > -1) subNavLeftFix = 8;
if (bSaf > -1) subNavHeightFix = 1;

var dropDownExists = false;

function hideDropDown(state)
{
	if ((document.getElementById)&&(bIE > -1))
	{
		if (state == 'activate') document.getElementById('dropDownDiv').style.display = 'none';
		else document.getElementById('dropDownDiv').style.display = 'block';
	}
}