NAV_HIDE_DELAY = 500; // wait to hide navigation (ms)

navTimeout = null;
currentNav = "";
defaultNav = "";
function showNav(navName) {
	if (!document.layers && pageLoaded && (navName != currentNav || navTimeout != null)) {

		resetDelayedHide();
		
		if (currentNav != "") {
			hideAllNav();
		}
		
		if (defaultNav != "" && navName != defaultNav) {
	        navSwap(defaultNav, "Behind");
			hideLayer(defaultNav + "Dhtmlnav");
		}

		if (defaultNav != navName) {
	        navSwap(navName, "On");
		}

		showLayer("hideDhtml");
		showLayer(navName + "Dhtmlnav");
		currentNav = navName;
	}
}

function resetDelayedHide() {
	if (navTimeout != null && !document.layers) {
		clearTimeout(navTimeout);
		navTimeout = null;
	}
}

function delayedNavHide() {
	if (pageLoaded && currentNav != "" && navTimeout == null && !document.layers) {
		hideLayer("hideDhtml");
		navTimeout = setTimeout("hideAllNav()", NAV_HIDE_DELAY);
	}
}

function hideAllNav() {
	if (currentNav != "" && !document.layers) {
	    navSwap(currentNav, "Off");
		hideLayer(currentNav + "Dhtmlnav");
		currentNav = "";
		
		if (defaultNav != "") {
			navSwap(defaultNav, "In");
			showLayer(defaultNav + "Dhtmlnav");
		}
		
		navTimeout = null;
	}
}

function swapStyle(element, className) {
	if (!document.layers) {
		element.className = className;
	}
}

function showLayer(layerId) {
	if (!document.layers && pageLoaded) {
		document.getElementById(layerId).style.visibility = "visible";
		document.getElementById(layerId).style.display = "block";
	}
}

function hideLayer(layerId) {
	if (!document.layers && pageLoaded) {
		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() {
    if (!document.layers) {
        for (var i = 0; i < arguments.length; i++) {
            document.getElementById(arguments[i]).style.visibility = "hidden";
        }
    }
}

function navSwap(prefix, onOff) {
	if (!document.layers) {
		document[prefix + "Image"].src = eval(prefix + "Image" + onOff).src;
	}
}
