/* jQuery Dropdown Menus */

//////////////// JQUERY INIT

$(document).ready(function() {
							 
		//get nav  
        var nav = $(".dropdown");  
  
        //add indicators and hovers to submenu parents  
        nav.find("li").each(function() {  
            if ($(this).find("ul").length > 0) {  
  
                //show subnav on hover  
                $(this).mouseenter(function(e) { 
                    menuItemHover($(this));  
                });  
  
                //hide submenus on exit  
                $(this).mouseleave(function(e) {  
                     menuItemExit($(this)); 
                }); 
				
				//
				$(this).click(function(e) { 
					e.stopPropagation(); 
                });  
            }  
        });
		
		//detect clicks outside the menu
		$('body > div').click(function() {
			nav.find("li").each(function(){
				menuItemExit($(this));
			});
		});


});


//////////////// JS FUNCTIONS

function menuItemHover(listElement){
	$(listElement).addClass("hover").find("ul").stop(true, true).show();
};

function menuItemExit(listElement){
	$(listElement).removeClass("hover").find("ul").stop(true, true).hide();
};
