﻿// JScript File

var hoverConfig = {    
     sensitivity: 1, 
     interval: 1, 
     over: showSubmenu,
     timeout: 500, 
     out: hideSubmenu 
};

var subHoverConfig = {
     sensitivity: 1, 
     interval: 10, 
     over: holdMenu, 
     timeout: 300, 
     out: releaseMenu
};

var mouseOver = false;

$(document).ready(function() {
    $(".link").each(function(i) {
        $(this).hoverIntent(hoverConfig);
    });
    $(".submenu").each(function(i) {
        $(this).hoverIntent(subHoverConfig);
    });
});

function showSubmenu()
{
    $(".submenu").each(function(i) {
        $(this).hide();
    });
    var submenu = $(this).parent().find(".submenu");
    mouseOver = false;
    submenu.show();
}

function holdMenu()
{
    mouseOver = true;    
}

function releaseMenu()
{
    mouseOver = false;
    $(".submenu").each(function(i) {
        $(this).hide();
    });
}

function hideSubmenu()
{
    var submenu = $(this).parent().find(".submenu");
    if(!mouseOver)
    {
        submenu.hide();
        mouseOver = false;
    }
}