﻿/// <reference path ="jquery-1.3.2-vsdoc2.js" />
var menuItemHeight = 25;

$(document).ready(function() {

    /* sub menu start */
    //set height for entire menu:
    $("#main-menu ul li ul").css("height", getMaxHeight);

    var config = {
        sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)    
        interval: 100, // number = milliseconds for onMouseOver polling interval    
        over: showMenu, // function = onMouseOver callback (REQUIRED)    
        timeout: 500, // number = milliseconds delay before onMouseOut
        out: hideMenu // function = onMouseOut callback (REQUIRED)    
    };
    $("#main-menu").hoverIntent(config)

    function showMenu() {
        //mouse over show submenu
        jQuery("#main-menu ul li ul").css({ "display": "block", "opacity": 1 })
        /*.animate({ 'opacity': 1 }, 300);*/
    }

    function hideMenu() {
        //mouse out hide submenu
        jQuery("#main-menu ul li ul").animate({ 'opacity': 0 }, 400, function() { jQuery(this).css("display", "none"); });
    }

    function getMaxHeight() {
        //get height from biggest menu:
        var menus = $("#main-menu ul li ul");
        var maxItems = 0;
        
        for (var i = 0; i < menus.length; i++) {
            var menu = menus[i];
            if (menu.children.length > maxItems) {
                maxItems = menu.children.length;
            }
        }
        return (menuItemHeight * maxItems)
    }
    /* sub menu end */


});
