var classe = null;
var menuBGColor = null;

function checkHover(thatClass) {
    if (thatClass != classe) {
        $("." + thatClass).find('ul').fadeOut('fast');
        classe = null;
    }
}

$(document).ready(function() {
    $('#nav-menus > li').hover(function() {
        $(this).find('ul').fadeIn();
        classe = $(this).attr("class");

    }, function(e) {
        classe = null;
        // tem de se usar com time out pois caso o cursor passe naquela margem entre o menu e submenu o
        // a funcao checkHover e' chamada mas logo a seguir e' chamada a hover. Por isso, 
        setTimeout("checkHover('" + $(this).attr("class") + "')", 200);
    });

    $('.submenu > li').hover(function() {
            menuBGColor = $(this).css("background-color");
            $(this).css("background-color", "#FFEAC5");
            $(this).find("a").css("color", "#EB9500");
        }, function () {
            $(this).css("background-color", menuBGColor);
            $(this).find("a").css("color", "#F6F6F6");
        }
    );

    $('.submenu > li').click(function () {
       document.location.href = $(this).find("a").attr("href");
    });

});


