$(document).ready(function() {
    function megaHoverOver(){
        $(this).find(".sub").stop().fadeTo('fast', 1).show();         
        $width = 24;
        $height = 0;
        $(this).children('.sub').children('.menuCat').each(function()
        {
            if ($(this).height() > $height)
            {
                $height = $(this).height();
            }
            $width += $(this).width() + 16;
        });
        
        $(this).children('.sub').children('.menuCat').height($height);
        
        if ($.browser.msie  && parseInt($.browser.version) == 7) {
            $width+=1;//IE7 heeft 1 extra pixel nodig
        }
        
        $(this).children('.sub').width($width);
    }
   
    function megaHoverOut(){
      $(this).find(".sub").stop().fadeTo('fast', 0, function() {
          $(this).hide();
      });
    }
    var config = {  
         sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)  
         interval: 100, // number = milliseconds for onMouseOver polling interval  
         over: megaHoverOver, // function = onMouseOver callback (REQUIRED)  
         timeout: 500, // number = milliseconds delay before onMouseOut  
         out: megaHoverOut // function = onMouseOut callback (REQUIRED)  
    };
    $("ul#topnav li .sub").css({'opacity':'0'});
    $("ul#topnav li").hoverIntent(config);  
});
