 jQuery(document).ready(function() {

    jQuery("#menu ul li ul ").hide();
//        
//        jQuery("#menu ul li").mouseover(function(){ //When mouse over ...
               //Following event is applied to the subnav itself (making height of subnav 60px)
//      
//      if(jQuery(this).find('ul').length > 0)
//      {
//      jQuery(this).find('ul').stop().animate({height: '60px', opacity:'1'},{queue:false, duration:300});
//           
//        if (jQuery('.clearmenu').length == 0){
//              jQuery('<div class="clearmenu"></div>').insertAfter('#menu').stop().animate({height: '15px', opacity:'1'},{queue:false, duration:300});
//                }
//              }
//        });

//        jQuery("#menu ul li").mouseout(function(){ //When mouse out ...
//              jQuery(this).find('ul').stop().animate({height:'0px', opacity:'0'}, 300, 'linear', function() {

//                    if (jQuery('.clearmenu').length == 1){
//                  jQuery('.clearmenu').slideUp('300', function(){
//                      jQuery(this).remove();
//                  });
//                  }
//          });
//          
//          jQuery("#menu").mouseout(function(){ 

//              if (jQuery('.clearmenu').length == 1){
//                  jQuery('.clearmenu').slideUp('300', function(){
//                      jQuery(this).remove();
//                  });
//                  }
//          });
//          
//          
//          
//      jQuery("#menu").mouseout(function (e) {
//    if(jQuery.contains(this, e.relatedTarget) == false) {
//              if (jQuery('.clearmenu').length == 1){
//                  jQuery('.clearmenu').slideUp('300', function(){
//                      jQuery(this).remove();
//                  });
//                  }    
//                }
//    });
           
/*            jQuery("#menu ul li")
                .mouseover( function() {
                        jQuery(this).children("ul").stop().animate({height: '60px', opacity:'1'},{queue:false, duration:300});
                })
                .mouseout( function() {
                        setInterval( function()
      {
        jQuery(this).fadeOut("fast");
      }, 500);


                });
*/

/*function hideSubmenu(){
    jQuery(this).children("ul").stop().animate({height: '0', opacity:'0'},{queue:false, duration:300});
}
    jQuery("#menu ul li")
        .mouseover( function() {
                    jQuery(this).children("ul").stop().animate({height: '60px', opacity:'1'},{queue:false, duration:300});
        })
        .mouseout( function() {

            t = setTimeout(hideSubmenu(), 500); // adjust your time here
        });*/
/*        jQuery(this).children("ul").hover(function(){

            clearTimeout(t);
//        },function(){
//            t = setTimeout(function(){
//                         jQuery(this).find('ul').stop().animate({height:'0px', opacity:'0'}, 300, 'linear');
//            }, 500); // adjust your time here
        });*/
    jQuery("ul#topnav li").hover(function() { //Hover over event on list item
                 if(jQuery(this).find("span").length==1)
                  {if (jQuery('.clearmenu').length == 0 ){
              jQuery('<div class="clearmenu"></div>').insertAfter('#menu').stop().animate({height: '15px', opacity:'1'},{queue:false, duration:300});
               
                  jQuery(this).find("span").fadeIn('fast');
                  }}
       
    } , function() { //on hover out...

          if (jQuery('.clearmenu').length == 1){
              jQuery(this).find("span").fadeOut('fast'); //Hide the subnav
              jQuery('.clearmenu').slideUp('300').remove();
          }
    });
     
});
        
//});



