var timeout	= 500;
var closetimer	= 0;
var theMenuItem	= 0;

// open hidden layer
function menuOpen(id)
{	
	stopMenuClose();

	// closes old menu dropdown
	if(theMenuItem) theMenuItem.style.visibility = 'hidden';

	// opens new menu dropdown
	theMenuItem = document.getElementById(id);
	theMenuItem.style.visibility = 'visible';

}
// closes the menu dropdown
function menuClose()
{
	if(theMenuItem) theMenuItem.style.visibility = 'hidden';
}

// Starts the timer to close the menu dropdown
function startMenuClose()
{
	closetimer = window.setTimeout(menuClose, timeout);
}

// Stops the timer to close the menu dropdown
function stopMenuClose()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close menu dropdown on a click-out
document.onclick = menuClose; 
