var hideDelay = false;
var menu = false;

function hideMenu() {
    $(menu).find("ul:first").stop(true, true).slideUp();
}

$(document).ready(function () {
    $(".menu > ul > li").hover(
    function () {
        if (hideDelay) {
            clearInterval(hideDelay);
            hideDelay = false;

            if (menu != this) {
                hideMenu();
            }
        }

        $(this).find("ul:first").stop(true, true).slideDown();
    }, function () {
        if (hideDelay) {
            clearTimeout(hideDelay);
            hideMenu();
        }

        hideDelay = setTimeout('hideMenu()', 200);
        menu = this;
    });
});

