NAV_HIDE_DELAY = 500; // wait to hide navigation (ms)

navTimeout = null;
currentNav = "";
currentSubnav = "";
defaultNav = "";

rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
isIframe = (rslt != null && Number(rslt[1]) <= 6);
isIE55 = (rslt != null && Number(rslt[1]) == 5.5);

function showNav(navName) {
	if (pageLoaded && (navName != currentNav || navTimeout != null)) {
	
		resetDelayedHide();
		
		if (currentNav != "") {
			hideAllNav();
		}
		
		if (defaultNav != "" && navName != defaultNav) {
			hideLayer(defaultNav + "Dhtmlnav");
		}

		if (defaultNav != navName) {
	        navSwap(navName, "On");
		}

		showLayer("hideDhtml");
		showLayer(navName + "Dhtmlnav");

		if (isIframe) {
			setIframe(navName + "Dhtmlnav");
			showLayer(navName + "DhtmlnavIFrame");
		}

		currentNav = navName;
	}
}

function showSubnav(subnavName) {
	if (pageLoaded && (subnavName != currentSubnav || navTimeout != null)) {

		resetDelayedHide();
		
		if (currentSubnav != "") {
			hideAllSubnav();
		}
		
		showLayer("hideDhtml");
		swapStyle(document.getElementById(subnavName + "DhtmlNavitem"), "dhtmlnavitemOn");
		showLayer(subnavName + "DhtmlSubnav");

		if (isIframe) {
			setIframe(subnavName + "DhtmlSubnav");
			showLayer(subnavName + "DhtmlSubnavIFrame");
		}

		currentSubnav = subnavName;
	}
}


function resetDelayedHide() {
	if (navTimeout != null) {
		clearTimeout(navTimeout);
		navTimeout = null;
	}
}

function delayedNavHide() {
	if (pageLoaded && currentNav != "" && navTimeout == null) {
		hideLayer("hideDhtml");
		navTimeout = setTimeout("hideAllNav()", NAV_HIDE_DELAY);
	}
}

function hideAllNav() {
	if (currentNav != "") {
	    navSwap(currentNav, "Off");
		hideLayer(currentNav + "Dhtmlnav");
		if (isIframe) {
			hideLayer(currentNav + "DhtmlnavIFrame");
		}
		currentNav = "";
		
		if (defaultNav != "") {
			navSwap(defaultNav, "On");
			// showLayer(defaultNav + "Dhtmlnav");
		}
		
		navTimeout = null;
		hideAllSubnav();
	}
}

function hideAllSubnav() {
	if (currentSubnav != "") {
		swapStyle(document.getElementById(currentSubnav + "DhtmlNavitem"), "dhtmlnavitem");
		hideLayer(currentSubnav + "DhtmlSubnav");
		if (isIframe) {
			hideLayer(currentSubnav + "DhtmlSubnavIframe");
		}
		currentSubnav = "";
		navTimeout = null;
	}
}

function swapStyle(element, className) {
	element.className = className;
}

function showLayer(layerId) {
	if (pageLoaded && document.getElementById(layerId)) {
		document.getElementById(layerId).style.visibility = "visible";
		document.getElementById(layerId).style.display = "block";
	}
}

function hideLayer(layerId) {
	if (pageLoaded && document.getElementById(layerId)) {
		document.getElementById(layerId).style.visibility = "hidden";
		document.getElementById(layerId).style.display = "none";
	}
}


// Uses the arguments[] array to get the ID's of each layer to hide.
function hideDropdowns() {
	for (var i = 0; i < arguments.length; i++) {
		document.getElementById(arguments[i]).style.visibility = "hidden";
	}
}

function navSwap(prefix, onOff) {
	if (document[prefix + "Image"]) {
		document[prefix + "Image"].src = eval(prefix + "Image" + onOff).src;
	}
	if (document.getElementById(prefix + "Link")) {
		swapStyle(document.getElementById(prefix + "Link"), "navLink" + onOff);
	}
}

function setIframe(layerName) {
	if (isIframe && document.getElementById(layerName + "IFrame")) {
		obj = document.getElementById(layerName);
		ifrm = document.getElementById(layerName + "IFrame");
		
		ifrm.style.top = obj.offsetTop;
		ifrm.style.left = obj.offsetLeft;
		ifrm.style.height = obj.offsetHeight;
		ifrm.style.width = obj.offsetWidth;
	}
}

function fixHideDhtml() {
	if (document.body.scrollHeight > document.body.offsetHeight) {
		document.getElementById("hideDhtml").style.height = document.body.scrollHeight;
	} else {
		document.getElementById("hideDhtml").style.height = document.body.offsetHeight * .99;
	}
}

// document.write("<div id=\"hideDhtml\" onmousedown=\"hideLayer('hideDhtml'); return false;\"><img src=\"/common/images/spacer.gif\" width=\"99%\" height=\"99%\" border=\"0\" alt=\"\" galleryimg=\"no\"></div>");

//addOnLoad(fixHideDhtml);



