
	NAV_HIDE_DELAY = 500; // wait to hide navigation (ms)
	
	navTimeout = null;
	currentNav = "";
	currentSubnav = "";
	defaultNav = "";
	
	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");
	
			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");
	
			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");
			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");
			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);
		}
	}
	
	$(document).ready(function() {
		var hd = $("<div id='hideDhtml'>");
		$(hd).mouseover(
			function() {
				hideLayer('hideDhtml');
				delayedNavHide();
			}
		)
		$(hd).html('<img src="http://www.redrover.org/common/images/spacer.gif" width="99%" height="99%" border="0" alt="" galleryimg="no" />');
		$(document.body).prepend(hd);
	});

