﻿$(document).ready(function () {
    $(".topNavSub").appendTo($("#mainwrapper"));
    $(".topNav li a").hover(function () {
        $(".topNavSub").stop(true, true);
        if (!$(this).hasClass("menuopen")) {
            $('.topNavSub').fadeOut();
            $('.menuopen').removeClass('menuopen');
            $(this).addClass("menuopen");
            $(".nav" + $(this).attr("rev")).fadeIn();
        }
        clearTimer();

    }, function () {
        startTimer();
    });

    $(".topNavSub ul li a").hover(function () {
        clearTimer();
    }, function () {
        startTimer();
    });
});

function startTimer() {
    alertTimerId = setTimeout("$('.topNavSub').fadeOut();$('.menuopen').removeClass('menuopen');", 100);
}

function clearTimer() {

    clearTimeout(alertTimerId);
}

$(".topNav").bind("contextmenu", function (e) {
    return false;
});
$(".topNav").attr("unselectable", "on").css("MozUserSelect", "none");
