/************************************************************
Autism Speaks.org

NAVIGATION SCRIPTS MODULE

This module contains all functions and variables used for 
rendering the global navigation drop-down menus
*************************************************************/

/************************************************************
GLOBAL VARIABLES
*************************************************************/
var navOver = null;			// name of the navigation button that the mouse is over
var menuOver = null;		// name of the menu that the mouse is over
var menuCloseDelay = 100;	// number of milliseconds after which to close a menu
var menuTimeout;			// id of timeout for closing menus
var debug = true;			// whether or not in debug mode

/************************************************************
ON-COMPILE EXECUTABLES
*************************************************************/

/************************************************************
FUNCTIONS
*************************************************************/

// global nav links
function overNav(name) {
	// special mouseover event handling for global navigation items
	show(name + "Menu");  	// show a menu of the given name
	setNavOver(name);		// record which nav link we are over
}

function outNav(name) {
	// Onmouseout of nav, hide the menu, waiting first
	setNavOver(null);
	menuTimeout = setTimeout("hideMenuDelayedFromNav('" + name + "');",menuCloseDelay);
}

function hideMenuDelayedFromNav(name) {
	// Onmouseout of nav, hide a menu of the given name, unless over the menu
	if (name!=menuOver) {
		hide(name + "Menu");
	}
}

// subnavigation menus
function outMenu(name) {
	// Onmouseout of menu, hide the menu, wating first
	setMenuOver(null);
	menuTimeout = setTimeout("hideMenuDelayedFromMenu('" + name + "');",menuCloseDelay);
}

function hideMenuDelayedFromMenu(name) {
	// Onmouseout of menu, hide a menu of the given name, unless over the corresponding global nav (hence the menu would be open already)
	if ((name!=navOver) && (name!=menuOver)) {
		hide(name + "Menu");
	}
}

// utilities
function setNavOver(name) {
	// keep track of what menu the mouse is over
	navOver = name;
}

function setMenuOver(name) {
	// keep track of what menu the mouse is over
	menuOver = name;
}
