
// This code is to show and hide the navigation submenus

var dicNavMenuTimers = new Object();
var dicMenuVisible = new Object();

// show a menu immediately and hide all the others
function showNavMenu(intMenuID)
{
	// get the nav menu - they are labelled submenuN
	var objNavMenu = _getNavMenu(intMenuID);
	// hide any other visible menus immediately
	for(var intOtherMenuID in dicMenuVisible)
	{
		if(intOtherMenuID != intMenuID && dicMenuVisible[intOtherMenuID])
		{
			_hideNavMenu(intOtherMenuID)
		}
	}
	// show the menu (if it exists)
	if (objNavMenu != null)
	{
		objNavMenu.style.display = 'inline';
		dicMenuVisible[intMenuID] = true;
	}
	// cancel any hide timers associated with the menu
	keepNavMenu(intMenuID)
}

// hide a menu after a half-second delay
function hideNavMenu(intMenuID)
{
	// create a timer to hide the menu after half a second
	dicNavMenuTimers[intMenuID] = setTimeout("_hideNavMenu(" + intMenuID + ")", 500);
}

// cancel any hiding action associated with a menu
function keepNavMenu(intMenuID)
{
	if(dicNavMenuTimers[intMenuID] != null)
	{
		clearTimeout(dicNavMenuTimers[intMenuID]);
		delete dicNavMenuTimers[intMenuID];
	}
}

// hide a navigation menu immediately
function _hideNavMenu(intMenuID)
{
	// hide the menu (if it exists on the page)
	var objNavMenu = _getNavMenu(intMenuID);
	if (objNavMenu != null)
	{
		objNavMenu.style.display = 'none';
		dicMenuVisible[intMenuID] = false;
	}
	// delete the entry in the timeouts dictionary if there is one
	if(dicNavMenuTimers[intMenuID] != null)
	{
		delete dicNavMenuTimers[intMenuID];
	}
}

function _getNavMenu(intMenuID)
{
	// get the nav menu - they are labelled submenuN
	var objNavMenu = document.getElementById('submenu' + intMenuID);
	return objNavMenu;
}
