+ }
+
+ menu.find('li.wp-has-submenu').hoverIntent({
+ over: function(e){
+ var b, h, o, f, m = $(this).find('.wp-submenu'), menutop, wintop, maxtop, top = parseInt( m.css('top'), 10 );
+
+ if ( isNaN(top) || top > -5 ) // meaning the submenu is visible
+ return;
+
+ menutop = $(this).offset().top;
+ wintop = $(window).scrollTop();
+ maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar
+
+ b = menutop + m.height() + 1; // Bottom offset of the menu
+ h = $('#wpwrap').height(); // Height of the entire page
+ o = 60 + b - h;
+ f = $(window).height() + wintop - 15; // The fold
+
+ if ( f < (b - o) )
+ o = b - f;
+
+ if ( o > maxtop )
+ o = maxtop;
+
+ if ( o > 1 )
+ m.css('margin-top', '-'+o+'px');
+ else
+ m.css('margin-top', '');
+
+ menu.find('li.menu-top').removeClass('opensub');
+ $(this).addClass('opensub');
+ },
+ out: function(){
+ $(this).removeClass('opensub').find('.wp-submenu').css('margin-top', '');
+ },
+ timeout: 200,
+ sensitivity: 7,
+ interval: 90