/*
    Global navigation drop down code
*/

//-----------------------------------------------
// Constants
//-----------------------------------------------
var expandSpeed = 300;                  // Menu expand speed
var menuShouldBeClosed_Delay = 500;     // Time before menu status is polled

//-----------------------------------------------
// Globals
//-----------------------------------------------
var menuExpanded = false;
var menuMouseIn = false;    // if true, mouse is somewhere on the menu and menu shouldn't be hidden
var menuHideTimer = null;
var menuInProgress = false;

function showNav(navid)
{
    // ADDED BY LUKE: Fri-11-9-2009
    // Instruct the T1 element to stop playing
    home_header_control(-99, 0, 0);

    menuMouseIn = true;
    if (menuInProgress)
        return;
    // Close all menus
    $(".subnav_off").not("#" + navid).hide();
    if (!menuExpanded) {
        menuInProgress = true;
        $("#" + navid).slideDown(expandSpeed);
        window.setTimeout("menuInProgress = false",expandSpeed + 100);
     }
    else   
        $("#" + navid).show();
    
    menuExpanded = true;
}

function setMouseInMenuAreaMode()
{
    menuMouseIn = true;
}

function hideNav(navid)
{
    document.getElementById(navid).className = navid + '_off';
}

function hideAllNav()
{
    // Mark menuMouseIn as false, mouse outside any menus
    menuMouseIn = false;
    // Hidemenu delay in progress, return
    if (menuHideTimer != null)
        return;
    // Schedule hide menu;
    menuHideTimer = window.setTimeout("internal_hideAllNav()",menuShouldBeClosed_Delay);
}

function internal_hideAllNav()
{
    // Clear timer
    menuHideTimer = null;
    if (menuMouseIn)
        return;
    // If still outside menu, hide all
    $(".subnav_off").hide();
    menuExpanded = false;

    // ADDED BY LUKE: Fri-11-9-2009
    // Instruct the T1 element to start playing
    //alert ("in internal_hideAllNav");
   // home_header_control(1, 1, 1);
}
