$(document).ready(function (){
    $(".nav-top-link").mouseenter(function(){    	
    	aTestAndWait.call(this);
    }).mouseleave(function() {    		
    	$(this).oneTime(300, function() {
    		if(!$(this).next().hasClass("nav-ul-active")) {    			    			
    			$(this).next().slideUp("fast");  
    			$(this).removeClass("nav-active");
    		}
  		});
    });
});

function aTestAndWait()
{
	if($(".nav .nav-active").length > 0){
		$(this).oneTime(300, aTestAndWait);
		return;
	}
		
	aMouseEnter.call(this);
}

function aMouseEnter()
{
	if(!$(this).next().hasClass("nav-ul-active")) {    		
		$(this).next().stop(true, true);    		
		$(this).next().slideDown("fast");
		$(this).addClass("nav-active");
	}    	
	
	$(this).next().mouseenter(function() {
		$(this).addClass("nav-ul-active");
	});
	
	$(this).next().mouseleave(function() {
        $(this).slideUp("fast");
        $(this).oneTime(300, function(){
        	$(this).removeClass("nav-ul-active");
        	$(this).prev().removeClass("nav-active");
        });
	});    
}