//Drop Down Menu Script
//Original idea from http://javascript-array.com 

var _menu_hidetimeout  = 250;
var _menu_hidetimer	   = 0;
var _menu_lastitem     = 0;

//Show menu
function menu_show(id)
{	
    // Cancel hide timer
    menu_cancelhidetimeout();

    // Hide old menu if it's visible
    if(_menu_lastitem!=0) _menu_lastitem.style.visibility = 'hidden';

    // Get new menu and show it
    _menu_lastitem = document.getElementById(id);
    _menu_lastitem.style.visibility = 'visible';

}

//Hide menu
function menu_hide()
{
    if(_menu_lastitem!=0) {
        _menu_lastitem.style.visibility = 'hidden';
        _menu_lastitem = 0;
    }
}

// Hide timeout
function menu_starthidetimeout()
{
    _menu_hidetimer = window.setTimeout(menu_hide, _menu_hidetimeout);
}

// Cancel hide timeout
function menu_cancelhidetimeout()
{
    if(_menu_hidetimer!=0)
    {
        window.clearTimeout(_menu_hidetimer);
        _menu_hidetimer = 0;
    }
}

// Close menu when the document is clicked
document.onclick = menu_hide; 
