!function(e){"use strict";window.menuResizeTimeoutHandler=!1;var t=navigator.userAgent.toLowerCase(),n=navigator.platform.toLowerCase(),i=t.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/)||[null,"unknown",0];"ie"==i[1]&&document.documentMode;function o(e){if(e.getBoundingClientRect&&"ios"!=window.swmBrowser.platform.name){var t=e.getBoundingClientRect(),n=e.ownerDocument.documentElement,i={x:window.pageXOffset||document.documentElement.scrollLeft,y:window.pageYOffset||document.documentElement.scrollTop},o=function(e){var t=e.parentNode,n={x:0,y:0};for(;t&&!u(t);)n.x+=t.scrollLeft,n.y+=t.scrollTop,t=t.parentNode;return n}(e),a="fixed"==r(e,"position");return{x:parseInt(t.left)+o.x+(a?0:i.x)-n.clientLeft,y:parseInt(t.top)+o.y+(a?0:i.y)-n.clientTop}}var f=e,l={x:0,y:0};if(u(e))return l;for(;f&&!u(f);){if(l.x+=f.offsetLeft,l.y+=f.offsetTop,"firefox"==window.swmBrowser.name){s(f)||(l.x+=m(f),l.y+=d(f));var w=f.parentNode;w&&"visible"!=r(w,"overflow")&&(l.x+=m(w),l.y+=d(w))}else f!=e&&"safari"==window.swmBrowser.name&&(l.x+=m(f),l.y+=d(f));f=f.offsetParent}return"firefox"!=window.swmBrowser.name||s(e)||(l.x-=m(e),l.y-=d(e)),l}function r(t,n){return e(t).css(n)}function a(e,t){return parseInt(r(e,t))||0}function s(e){return"border-box"==r(e,"-moz-box-sizing")}function d(e){return a(e,"border-top-width")}function m(e){return a(e,"border-left-width")}function u(e){return/^(?:body|html)$/i.test(e.tagName)}function f(t){var n=e("> ul",t);if(0!=n.length){var i=n.get(0);n.addClass("megamenu-item-inited");var r={width:"auto",height:"auto",left:0};n.removeClass("megamenu-fullwidth").css(r),e(" > li",n).css({left:0,top:0}).each(function(){var t=e(this).data("old-width")||-1;-1!=t&&e(this).width(t).data("old-width",-1)});var a=n.closest(".header-main"),s=a.width(),d=parseInt(a.css("padding-left")),m=parseInt(a.css("padding-right")),u=n.parent().outerWidth(),f=n.outerWidth();if(f>s){f=s;var l=s,w=n.data("megamenu-columns")||4,c=parseFloat(l-w*parseInt(e(" > li.menu-item:first",n).css("margin-left")))/w,h=parseInt(c);e(" > li",n).each(function(){e(this).data("old-width",e(this).width()).css("width",h)}),n.addClass("megamenu-fullwidth").width(l-(c-h)*w)}if(f>u)var p=-(f-u)/2;else p=0;var g=o(a[0]),v=o(i);v.x-g.x-d+p<0&&(p=-(v.x-g.x-d)),v.x+f+p>g.x+a.outerWidth()-m&&(p-=v.x+f+p-(g.x+a.outerWidth()-m)),n.css("left",p).css("left"),n.addClass("megamenu-inited")}}window.swmBrowser={name:"version"==i[1]?i[3]:i[1],version:i[2],platform:{name:t.match(/ip(?:ad|od|hone)/)?"ios":(t.match(/(?:webos|android)/)||n.match(/mac|win|linux/)||["other"])[0]}},e(".swm-primary-nav > li.megamenu-on").hover(function(){f(this)}),e(".swm-primary-nav > li.megamenu-on:hover").each(function(){f(this)}),e(".swm-primary-nav > li.megamenu-on").each(function(){var t=e("> ul",this);0!=t.length&&t.addClass("megamenu-item-inited")}),e(function(){e(window).resize(function(){window.menuResizeTimeoutHandler&&clearTimeout(window.menuResizeTimeoutHandler)})})}(jQuery);