// Copyright 2011 Psylotech
// Written by Charles Spellma
// Adapted from http://javascript-array.com

var timeout	= 250;
var hidetimeout	= 0;
var menuitem	= 0;

// Show Hidden Dropdown
function show(id)
{	
	// Cancel the hide
	cancelhidetimer();

	// Close other menu
	if(menuitem)
	{
		menuitem.style.visibility = 'hidden';
	}

	// Show selected dropdown
	menuitem = document.getElementById(id);
	menuitem.style.visibility = 'visible';

}
// Hide Menu
function hide()
{
	if(menuitem)
	{
		menuitem.style.visibility = 'hidden';
	}
}

// Hide the Menu timer
function hidetimer()
{
	hidetimeout = window.setTimeout(hide, timeout);
}

// Cancel Hiding the Menu Timer
function cancelhidetimer()
{
	if(hidetimeout)
	{
		window.clearTimeout(hidetimeout);
		hidetimeout = null;
	}
}

// Hide when a click occurs out of bounds
document.onclick = hide; 
