// globalNav.js
// 	Contains the dynamic functionality for the drop down navigation found at the top of most templates.

// FUNCTION LIST:
// 	init();
// 	menuOn();
// 	menuOff();


var menuTimeout;
var currentMenu;

var navIsLoaded = false;

//used to display content div.
var divTop='<table cellspacing="8"><tr><td height="29" style="vertical-align: middle;">';
var divBottom='</td></tr></table>';
var divDetailsTop='<a href="javascript:showDetails(\'';
var divDetailsBottom='\');"><img src="../images/spacer.gif" width="57" height="21" alt="" /></a>';

//used to display details div
var detailsTop='<table cellspacing="0" style="border-left: 1px solid white; border-right: 1px solid white; border-bottom: 1px solid white;"><tr><td width="223" style="background:#071D44;"><p style="margin: 0px; padding: 8px 8px 0px 8px; " >';
var detailsBottom='</p><a href="javascript:hideDetails();" style="float: right;"><img src="../images/sub_btn_close.gif" width="56" height="25" alt="" /></a></td></tr></table>';
    

// Initializing the global navigation

// change init() to globalNavInit()
function init() {
	DynLayerInit()
	navIsLoaded = true;	// boolean to true when initialization is complete
}

// Display the dropdown menu.  // inputs: menuName  - name of the menu DIV layer without the Div.  ie. vehicles  // output: none
function menuOn(menuName) {
	var theMenu
	if (!navIsLoaded) return;	// check if initialization is complete
	if (menuTimeout) clearTimeout(menuTimeout);	// clear the timeout

	if (currentMenu) {			// hide the current menu
		theMenu = eval(currentMenu);
		theMenu.hide();
	}
	currentMenu = menuName;
	theMenu = eval(currentMenu);
	theMenu.show();				// display menuName
	// Next line commented out to match Flash nav version
}

// Hides the dropdown menus  // inputs: menuName - name of the menu DIV layer without the Div.  ie. vehicles  // outputs: none
function menuOff(menuName) {
	if (!navIsLoaded) return;	// check if initialization is complete

	if (menuTimeout) clearTimeout(menuTimeout);	// clear the current timeout
	menuTimeout = setTimeout(menuName + '.hide()', 0);		// set the new timeout
}

function showContent(divTitle,divImage,divDetails) {
	if (!navIsLoaded) return; //check if initialization is complete.
	temp.hide();
    if (divDetails=='') {
        divText=divTop+divTitle+divBottom;
    }
    else {
        divText=divTop+divTitle+divBottom+divDetailsTop+divDetails+divDetailsBottom;
    }
   
    Content.write(divText);
	document.getElementById('body_content_lt').style.background='url(' + divImage + ')';
	
}

function showDetails(detailsText) {
    
    temp.write(detailsTop+detailsText+detailsBottom);
    temp.show();
}

function hideDetails() {
    temp.hide();
    temp.write('');
}

//Used to open popup windows
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

