﻿var timeOut = 300;
var closeTimer = 0;
var subNavItem = 0;

function navClose() {
    if (subNavItem) {
        subNavItem.css("display", "none");
    }
}

function navTimer() {
    closeTimer = window.setTimeout(navClose, timeOut);
}

function navCancelTimer() {
    if (closeTimer) {
        window.clearTimeout(closeTimer);
        closeTimer = null;
    }
}

$(document).ready(function () {

    $(".first").hover(function () {
        navCancelTimer();
        navClose();
        subNavItem = $(this).parent().find(".second").css({ "display": "block", "top": "33px" });

    }, function () {
        navTimer();
    });

    $(".second").hover(function () {
        navCancelTimer();
    }, function () {
        navTimer();
    });
});
