!function(e){e.fn.menuAim=function(t){return this.each(function(){(function(t){var n=e(this),i=null,o=[],u=null,r=null,c=e.extend({rowSelector:"> li",submenuSelector:"*",submenuDirection:"right",tolerance:75,enter:e.noop,exit:e.noop,activate:e.noop,deactivate:e.noop,exitMenu:e.noop},t),l=function(e){e!=i&&(i&&c.deactivate(i),c.activate(e),i=e)},f=function(e){var t=a();t?r=setTimeout(function(){f(e)},t):l(e)},a=function(){if(!i||!e(i).is(c.submenuSelector))return 0;var t=n.offset(),r={x:t.left,y:t.top-c.tolerance},l={x:t.left+n.outerWidth(),y:r.y},f={x:t.left,y:t.top+n.outerHeight()+c.tolerance},a={x:t.left+n.outerWidth(),y:f.y},s=o[o.length-1],h=o[0];if(!s)return 0;if(h||(h=s),h.x<t.left||h.x>a.x||h.y<t.top||h.y>a.y)return 0;if(u&&s.x==u.x&&s.y==u.y)return 0;function m(e,t){return(t.y-e.y)/(t.x-e.x)}var x=l,y=a;"left"==c.submenuDirection?(x=f,y=r):"below"==c.submenuDirection?(x=a,y=f):"above"==c.submenuDirection&&(x=r,y=l);var v=m(s,x),p=m(s,y),b=m(h,x),d=m(h,y);return v<b&&p>d?(u=s,300):(u=null,0)};n.mouseleave(function(){r&&clearTimeout(r);c.exitMenu(this)&&(i&&c.deactivate(i),i=null)}).find(c.rowSelector).mouseenter(function(){r&&clearTimeout(r);c.enter(this),f(this)}).mouseleave(function(){c.exit(this)}).click(function(){l(this)}),e(document).mousemove(function(e){o.push({x:e.pageX,y:e.pageY}),o.length>3&&o.shift()})}).call(this,t)}),this}}(jQuery);