(function(a){a.fn.megaMenu=function(){var b=null;a('<div id="overlay"></div>').prependTo("body");return this.each(function(){a(this).hoverIntent({interval:200,sensitivity:7,over:g,timeout:300,out:f});a('<div id="'+a(this).attr("id")+'-div" class="new-menu"></div>').prependTo("body");a(this).find("div.menu-content").appendTo("#"+a(this).attr("id")+"-div").css({backgroundColor:"#fff",position:"absolute",top:"-9999px",left:"-9999px",opacity:0}).bind("mouseenter",function(){clearTimeout(b)}).bind("mouseleave",function(){var a=this;b=setTimeout(function(){d(a)},300)});a(this).find("h4").clone(true).prependTo("#"+a(this).attr("id")+"-div").css({backgroundColor:"#fff",position:"absolute",top:"-9999px",left:"-9999px",width:a(this).width()+"px",opacity:0}).bind("mouseenter",function(){clearTimeout(b)}).bind("mouseleave",function(){var a=this;b=setTimeout(function(){d(a)},300)})});function g(){var f=e(),b=c(a(this).get(0));a("#overlay").css({position:"absolute",top:0,left:0,backgroundColor:"#000",opacity:.6,height:f.ph,width:f.pw,zIndex:2520});var d=0;switch(a(this).attr("id")){case "products":d=a(this).width()+2;break;case "applications":d=a(this).width()+4;break;case "education":d=a(this).width()*2;a("#brand-search").find("select").css("visibility","hidden")}a("#"+a(this).attr("id")+"-div").find("h4").css({left:b.x+"px",top:b.y+"px",width:a(this).width()+2+"px",zIndex:2521}).animate({opacity:1},{duration:500,queue:true});a("#"+a(this).attr("id")+"-div").find("div.menu-content").css({left:b.x-d+"px",top:b.y+a("#"+a(this).attr("id")+"-div").find("h4").height()+"px",zIndex:2521}).stop(true,true).animate({opacity:1},{duration:500,queue:true})}function f(){}function d(d){var b=a(d).parent("div").find("h4"),c=a(d).parent("div").find("div.menu-content");a("#overlay").animate({opacity:0},200,"swing",function(){a("#overlay").css({height:0,width:0,zIndex:0})});b.animate({opacity:0},500,"swing",function(){b.css({left:"-9999px"})});c.animate({opacity:0},500,"swing",function(){c.css({left:"-9999px"})});a("#brand-search").find("select").css("visibility","visible")}function e(){var c,d;if(window.innerHeight&&window.scrollMaxY){c=window.innerWidth+window.scrollMaxX;d=window.innerHeight+window.scrollMaxY}else if(document.body.scrollHeight>document.body.offsetHeight){c=document.body.scrollWidth;d=document.body.scrollHeight}else{c=document.body.offsetWidth;d=document.body.offsetHeight}var a,b;if(self.innerHeight){if(document.documentElement.clientWidth)a=document.documentElement.clientWidth;else a=self.innerWidth;b=self.innerHeight}else if(document.documentElement&&document.documentElement.clientHeight){a=document.documentElement.clientWidth;b=document.documentElement.clientHeight}else if(document.body){a=document.body.clientWidth;b=document.body.clientHeight}if(d<b)pageHeight=b;else pageHeight=d;if(c<a)pageWidth=c;else pageWidth=a;objPageSize={pw:pageWidth,ph:pageHeight,ww:a,wh:b};return objPageSize}function c(a){var f=0,g=0,d=/^div$/i.test(a.tagName);if(d&&a.scrollLeft)f=a.scrollLeft;if(d&&a.scrollTop)g=a.scrollTop;var b={x:a.offsetLeft-f,y:a.offsetTop-g};if(a.offsetParent){var e=c(a.offsetParent);b.x+=e.x;b.y+=e.y}return b}}})(jQuery);