﻿var onItem = null;
var currentOffMenuTimer = null;
var currentOnMenuTimer = null;
var menuItems = new Array();
var arrow;
var rollOffDelay = 300;
var rollOnDelay = 300;

function InitMenuItems()
{
    menuItems[0] = new Object();
    menuItems[0].button = $get('templatesButton');
    menuItems[0].menu = $get('templatesMenu');
    menuItems[1] = new Object();
    menuItems[1].button = $get('trialButton');
    menuItems[1].menu = $get('trialMenu');
    menuItems[2] = new Object();
    menuItems[2].button = $get('aboutButton');
    menuItems[2].menu = $get('aboutMenu');
    menuItems[3] = new Object();
    menuItems[3].button = $get('supportButton');
    menuItems[3].menu = $get('supportMenu');
    arrow = $get('downArrow');
}


function MenuRollOver(menuIndex)
{
    /*
    var butLoc = Sys.UI.DomElement.getBounds(menuItems[menuIndex].button);
    var arrowX = butLoc.x + Math.round((butLoc.width / 2));
    var arrowY = butLoc.y + butLoc.height;
    */
    if (onItem != null)
    {
    
    }
    if (menuIndex != onItem)
    {
    }
        currentOnMenuTimer = setTimeout("TurnOnMenu('" + menuIndex + "')", rollOnDelay);
   
}

function MenuRollOff()
{
    if (currentOnMenuTimer != null)
    {
        clearTimeout(currentOnMenuTimer);
        currentOnMenuTimer = null;
    }
    if (currentOffMenuTimer != null) clearTimeout(currentOffMenuTimer);
    currentOffMenuTimer = setTimeout("TurnOffMenu()", rollOffDelay);
}

function TurnOnMenu(nextOn)
{
    if (currentOffMenuTimer != null)
    {
        clearTimeout(currentOffMenuTimer);
        currentOffMenuTimer = null;
    }
    
    if (onItem != nextOn)
    {
        TurnOffMenu();
       
    }
     menuItems[nextOn].button.style.backgroundImage = "url('/images/top-nav-gradient-on-test.png')";
    menuItems[nextOn].menu.style.display = "block";
    // arrow.style.display = "block";
    // Sys.UI.DomElement.setLocation(arrow, arrowX, arrowY);
    onItem = nextOn;

}

function TurnOffMenu()
{
    
    if (onItem != null)
    {
    
        menuItems[onItem].button.style.backgroundImage = "url('/images/top-nav-gradient.png')";
        menuItems[onItem].menu.style.display = "none";
       // arrow.style.display = "none";
    }
    onItem = null;
    currentOffMenuTimer = null;

}
