jQuery(document).ready(function() {
 //Set custom configurations
 var config = {
   sensitivity: 2,
   interval: 100,
   over: megaHoverOver,
   timeout: 500,
   out: megaHoverOut
 };
 
 jQuery("ul#topnav li .sub").css({'display':'none'});
 jQuery("ul#topnav li").hoverIntent(config); //Trigger Hover intent
 jQuery("ul#topnav li .sub").each(function(index) {
  if(jQuery(this).children().get(0).tagName == "UL") {
   if(jQuery.trim(jQuery(this).children().html()) == "") {
    jQuery(this).remove();
   }
  }
 });
 
});

//On Hover Over
function megaHoverOver(){ 
	/*jQuery(this).find(".sub").css({'display':'block'});
    jQuery(this).find(".sub").topZIndex( { increment: 10 } );
	alert(jQuery.topZIndex());*/
	jQuery(this).find(".sub").stop().fadeTo('fast', 1).show();
}

//On Hover Out
function megaHoverOut(){
	//jQuery(this).find(".sub").css({'display':'none'});
  jQuery(this).find(".sub").stop().fadeTo('fast', 0, function() {
      jQuery(this).hide();
  });	
  
}
