﻿var alertTimerId;

$(document).ready(function() {

    $(".navigation .nav li .navitem").hover(
            function() { },
            function() { startTimer();  })

    $(".subnav").hover(
            function() { clearTimer(); },
            function() { startTimer(); })

});

function navmenuover(id,mainnavid) {
    clearTimer();
    if (id != "0") {
        if (id != "navyellowsub") {
            $("#navyellowsub").fadeOut();
        }
        if (id != "navredsub") {
            $("#navredsub").fadeOut();
        }
        if (id != "navbluesub") {
            $("#navbluesub").fadeOut();
        }
        if (id != "navgraysub") {
            $("#navgraysub").fadeOut();
        }
        $("#" + id).fadeIn();
        $('.navitem').removeClass('selected');
        $("#" + mainnavid).addClass("selected");
    }
    else {
        $(".subnav").fadeOut();
    }
}

function startTimer() {
    alertTimerId = setTimeout("$('.subnav').fadeOut();$('.navitem').removeClass('selected');", 0);
}

function clearTimer() {

    clearTimeout(alertTimerId);
}
