// ## globalNav.js
// 	Contains the dynamic functionality for the drop down navigation found at the top of most templates.

// FUNCTION LIST:
// 	init();
// 	menuOn();
// 	menuOff();
//	menuLinkOn();
// 	menuLinkOff();
// 	linkSwap();
// 	arrowSwap();
// 	modelarrowSwap();

// TEMPLATE(S) USED:
// 	brochure_request.html
// 	coming_veh.html
// 	contact.html
// 	corporate.html
// 	dealer_results.html
// 	gallery.html
// 	line_up.html
// 	main.html
// 	performance.html
// 	specs.html
// 	vehicles_home.html

var menuTimeout;
var submenuTimeout;
var currentMenu;
var currentsubMenu;
var imgPathNav;
var imgPath;
var BaseHREF;
var PathName;

if (!PathName)
{
	PathName= '../m/static/i/default.htm';
}

if (BaseHREF) {
	var imgPathNav = BaseHREF + PathName; 	// Image path location for Global Nav menu images.
	var imgPath = BaseHREF + PathName; 	// Image path location for all other images.
} else {
	var imgPathNav = PathName; 	// Image path location for Global Nav menu images.
	var imgPath = PathName; 		// Image path location for all other images.
}

var navIsLoaded = false;

// 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
	//menuTimeout = setTimeout(currentMenu + '.hide()', 3000);		// set the timeout
}

function submenuOn(submenuName) {
	var thesubMenu
	if (!navIsLoaded) return;	// check if initialization is complete
	if (submenuTimeout) clearTimeout(submenuTimeout);	// clear the timeout

	if (currentsubMenu) {			// hide the current menu
		thesubMenu = eval(currentsubMenu);
		thesubMenu.hide();
	}
	currentsubMenu = submenuName;
	thesubMenu = eval(currentsubMenu);theMenu = eval(currentMenu);
	thesubMenu.show();theMenu.show();				// display menuName
	// Next line commented out to match Flash nav version
	//submenuTimeout = setTimeout(currentsubMenu + '.hide()', 3000);	// set the timeout
}

// 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()', 500);		// set the new timeout
}

function submenuOff(submenuName) {

	if (!navIsLoaded) return	// check if initialization is complete

	if (submenuTimeout) clearTimeout(submenuTimeout)	// clear the current timeout
	submenuTimeout = setTimeout(submenuName + '.hide()', 330);		// set the new timeout
}

