﻿
var activePanel = null;
var leaveOpen = null
var animating = false;

function mainmenu() {

    var config = {
        sensitivity: 5, // number = sensitivity threshold (must be 1 or higher)    
        interval: 200, // number = milliseconds for onMouseOver polling interval    
        over: function () {
            if (!animating) {
                hoverPanel = $(this).find('ul');
                //parent = hoverPanel.parent();

                if (activePanel == null || activePanel.attr('id') != hoverPanel.attr('id')) {
                    animating = true;
                    if (activePanel) {
                        if (leaveOpen && (activePanel.attr('id') != leaveOpen.attr('id'))) {
                            activePanel.hide('slow');
                            activePanel.parent().removeClass('active');
                        } else if (!leaveOpen) {
                            activePanel.hide('slow');
                            activePanel.parent().removeClass('active');
                        }
                    }
                    activePanel = hoverPanel;
                    hoverPanel.show(1800, function () {
                        hoverPanel.parent().addClass('active');
                        animating = false;
                    });
                }
            }
        },
        timeout: 100, // number = milliseconds delay before onMouseOut    
        out: function () { }
    };

    //$("#subnav ul li").find("ul").hide();
    //$("#subnav ul li.heading").hoverIntent(config);
    $("#subnav ul li").not(".active").find("ul").hide();
    $("#subnav ul li.heading").not(".active").hoverIntent(config);

}

$(document).ready(function () {

    mainmenu();

});
