/*
 * SmartMenus jQuery v1.0.1+
 * http://www.smartmenus.org/
 *
 * Copyright Vasil Dinkov, Vadikom Web Ltd.
 * http://vadikom.com/
 *
 * Released under the MIT license:
 * http://www.opensource.org/licenses/MIT
 */

 !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&"object"==typeof module.exports?module.exports=a(require("jquery")):a(jQuery)}(function($){function initMouseDetection(a){var b=".smartmenus_mouse";if(mouseDetectionEnabled||a)mouseDetectionEnabled&&a&&($(document).unbind(b),mouseDetectionEnabled=!1);else{var c=!0,d=null;$(document).bind(getEventsNS([["mousemove",function(a){var b={x:a.pageX,y:a.pageY,timeStamp:(new Date).getTime()};if(d){var e=Math.abs(d.x-b.x),f=Math.abs(d.y-b.y);if((e>0||f>0)&&e<=2&&f<=2&&b.timeStamp-d.timeStamp<=300&&(mouse=!0,c)){var g=$(a.target).closest("a");g.is("a")&&$.each(menuTrees,function(){if($.contains(this.$root[0],g[0]))return this.itemEnter({currentTarget:g[0]}),!1}),c=!1}}d=b}],[touchEvents?"touchstart":"pointerover pointermove pointerout MSPointerOver MSPointerMove MSPointerOut",function(a){isTouchEvent(a.originalEvent)&&(mouse=!1)}]],b)),mouseDetectionEnabled=!0}}function isTouchEvent(a){return!/^(4|mouse)$/.test(a.pointerType)}function getEventsNS(a,b){b||(b="");var c={};return $.each(a,function(a,d){c[d[0].split(" ").join(b+" ")+b]=d[1]}),c}var menuTrees=[],IE=!!window.createPopup,mouse=!1,touchEvents="ontouchstart"in window,mouseDetectionEnabled=!1,requestAnimationFrame=window.requestAnimationFrame||function(a){return setTimeout(a,1e3/60)},cancelAnimationFrame=window.cancelAnimationFrame||function(a){clearTimeout(a)};return $.SmartMenus=function(a,b){this.$root=$(a),this.opts=b,this.rootId="",this.accessIdPrefix="",this.$subArrow=null,this.activatedItems=[],this.visibleSubMenus=[],this.showTimeout=0,this.hideTimeout=0,this.scrollTimeout=0,this.clickActivated=!1,this.focusActivated=!1,this.zIndexInc=0,this.idInc=0,this.$firstLink=null,this.$firstSub=null,this.disabled=!1,this.$disableOverlay=null,this.$touchScrollingSub=null,this.cssTransforms3d="perspective"in a.style||"webkitPerspective"in a.style,this.wasCollapsible=!1,this.init()},$.extend($.SmartMenus,{hideAll:function(){$.each(menuTrees,function(){this.menuHideAll()})},destroy:function(){for(;menuTrees.length;)menuTrees[0].destroy();initMouseDetection(!0)},prototype:{init:function(a){var b=this;if(!a){menuTrees.push(this),this.rootId=((new Date).getTime()+Math.random()+"").replace(/\D/g,""),this.accessIdPrefix="sm-"+this.rootId+"-",this.$root.hasClass("sm-rtl")&&(this.opts.rightToLeftSubMenus=!0);var c=".smartmenus";this.$root.data("smartmenus",this).attr("data-smartmenus-id",this.rootId).dataSM("level",1).bind(getEventsNS([["mouseover focusin",$.proxy(this.rootOver,this)],["mouseout focusout",$.proxy(this.rootOut,this)],["keydown",$.proxy(this.rootKeyDown,this)]],c)).delegate("a",getEventsNS([["mouseenter",$.proxy(this.itemEnter,this)],["mouseleave",$.proxy(this.itemLeave,this)],["mousedown",$.proxy(this.itemDown,this)],["focus",$.proxy(this.itemFocus,this)],["blur",$.proxy(this.itemBlur,this)],["click",$.proxy(this.itemClick,this)]],c)),c+=this.rootId,this.opts.hideOnClick&&$(document).bind(getEventsNS([["touchstart",$.proxy(this.docTouchStart,this)],["touchmove",$.proxy(this.docTouchMove,this)],["touchend",$.proxy(this.docTouchEnd,this)],["click",$.proxy(this.docClick,this)]],c)),$(window).bind(getEventsNS([["resize orientationchange",$.proxy(this.winResize,this)]],c)),this.opts.subIndicators&&(this.$subArrow=$("<span/>").addClass("sub-arrow"),this.opts.subIndicatorsText&&this.$subArrow.html(this.opts.subIndicatorsText)),initMouseDetection()}if(this.$firstSub=this.$root.find("ul").each(function(){b.menuInit($(this))}).eq(0),this.$firstLink=this.$root.find("a").eq(0),this.opts.markCurrentItem){var d=/(index|default)\.[^#\?\/]*/i,e=/#.*/,f=window.location.href.replace(d,""),g=f.replace(e,"");this.$root.find("a").each(function(){var a=this.href.replace(d,""),c=$(this);a!=f&&a!=g||(c.addClass("current"),b.opts.markCurrentTree&&c.parentsUntil("[data-smartmenus-id]","ul").each(function(){$(this).dataSM("parent-a").addClass("current")}))})}this.wasCollapsible=this.isCollapsible()},destroy:function(a){if(!a){var b=".smartmenus";this.$root.removeData("smartmenus").removeAttr("data-smartmenus-id").removeDataSM("level").unbind(b).undelegate(b),b+=this.rootId,$(document).unbind(b),$(window).unbind(b),this.opts.subIndicators&&(this.$subArrow=null)}this.menuHideAll();var c=this;this.$root.find("ul").each(function(){var a=$(this);a.dataSM("scroll-arrows")&&a.dataSM("scroll-arrows").remove(),a.dataSM("shown-before")&&((c.opts.subMenusMinWidth||c.opts.subMenusMaxWidth)&&a.css({width:"",minWidth:"",maxWidth:""}).removeClass("sm-nowrap"),a.dataSM("scroll-arrows")&&a.dataSM("scroll-arrows").remove(),a.css({zIndex:"",top:"",left:"",marginLeft:"",marginTop:"",display:""})),0==(a.attr("id")||"").indexOf(c.accessIdPrefix)&&a.removeAttr("id")}).removeDataSM("in-mega").removeDataSM("shown-before").removeDataSM("ie-shim").removeDataSM("scroll-arrows").removeDataSM("parent-a").removeDataSM("level").removeDataSM("beforefirstshowfired").removeAttr("role").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeAttr("aria-expanded"),this.$root.find("a.has-submenu").each(function(){var a=$(this);0==a.attr("id").indexOf(c.accessIdPrefix)&&a.removeAttr("id")}).removeClass("has-submenu").removeDataSM("sub").removeAttr("aria-haspopup").removeAttr("aria-controls").removeAttr("aria-expanded").closest("li").removeDataSM("sub"),this.opts.subIndicators&&this.$root.find("span.sub-arrow").remove(),this.opts.markCurrentItem&&this.$root.find("a.current").removeClass("current"),a||(this.$root=null,this.$firstLink=null,this.$firstSub=null,this.$disableOverlay&&(this.$disableOverlay.remove(),this.$disableOverlay=null),menuTrees.splice($.inArray(this,menuTrees),1))},disable:function(a){if(!this.disabled){if(this.menuHideAll(),!a&&!this.opts.isPopup&&this.$root.is(":visible")){var b=this.$root.offset();this.$disableOverlay=$('<div class="sm-jquery-disable-overlay"/>').css({position:"absolute",top:b.top,left:b.left,width:this.$root.outerWidth(),height:this.$root.outerHeight(),zIndex:this.getStartZIndex(!0),opacity:0}).appendTo(document.body)}this.disabled=!0}},docClick:function(a){return this.$touchScrollingSub?void(this.$touchScrollingSub=null):void((this.visibleSubMenus.length&&!$.contains(this.$root[0],a.target)||$(a.target).closest("a").length)&&this.menuHideAll())},docTouchEnd:function(a){if(this.lastTouch){if(this.visibleSubMenus.length&&(void 0===this.lastTouch.x2||this.lastTouch.x1==this.lastTouch.x2)&&(void 0===this.lastTouch.y2||this.lastTouch.y1==this.lastTouch.y2)&&(!this.lastTouch.target||!$.contains(this.$root[0],this.lastTouch.target))){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0);var b=this;this.hideTimeout=setTimeout(function(){b.menuHideAll()},350)}this.lastTouch=null}},docTouchMove:function(a){if(this.lastTouch){var b=a.originalEvent.touches[0];this.lastTouch.x2=b.pageX,this.lastTouch.y2=b.pageY}},docTouchStart:function(a){var b=a.originalEvent.touches[0];this.lastTouch={x1:b.pageX,y1:b.pageY,target:b.target}},enable:function(){this.disabled&&(this.$disableOverlay&&(this.$disableOverlay.remove(),this.$disableOverlay=null),this.disabled=!1)},getClosestMenu:function(a){for(var b=$(a).closest("ul");b.dataSM("in-mega");)b=b.parent().closest("ul");return b[0]||null},getHeight:function(a){return this.getOffset(a,!0)},getOffset:function(a,b){var c;"none"==a.css("display")&&(c={position:a[0].style.position,visibility:a[0].style.visibility},a.css({position:"absolute",visibility:"hidden"}).show());var d=a[0].getBoundingClientRect&&a[0].getBoundingClientRect(),e=d&&(b?d.height||d.bottom-d.top:d.width||d.right-d.left);return e||0===e||(e=b?a[0].offsetHeight:a[0].offsetWidth),c&&a.hide().css(c),e},getStartZIndex:function(a){var b=parseInt(this[a?"$root":"$firstSub"].css("z-index"));return!a&&isNaN(b)&&(b=parseInt(this.$root.css("z-index"))),isNaN(b)?1:b},getTouchPoint:function(a){return a.touches&&a.touches[0]||a.changedTouches&&a.changedTouches[0]||a},getViewport:function(a){var b=a?"Height":"Width",c=document.documentElement["client"+b],d=window["inner"+b];return d&&(c=Math.min(c,d)),c},getViewportHeight:function(){return this.getViewport(!0)},getViewportWidth:function(){return this.getViewport()},getWidth:function(a){return this.getOffset(a)},handleEvents:function(){return!this.disabled&&this.isCSSOn()},handleItemEvents:function(a){return this.handleEvents()&&!this.isLinkInMegaMenu(a)},isCollapsible:function(){return"static"==this.$firstSub.css("position")},isCSSOn:function(){return"inline"!=this.$firstLink.css("display")},isFixed:function(){var a="fixed"==this.$root.css("position");return a||this.$root.parentsUntil("body").each(function(){if("fixed"==$(this).css("position"))return a=!0,!1}),a},isLinkInMegaMenu:function(a){return $(this.getClosestMenu(a[0])).hasClass("mega-menu")},isTouchMode:function(){return!mouse||this.opts.noMouseOver||this.isCollapsible()},itemActivate:function(a,b){var c=a.closest("ul"),d=c.dataSM("level");if(d>1&&(!this.activatedItems[d-2]||this.activatedItems[d-2][0]!=c.dataSM("parent-a")[0])){var e=this;$(c.parentsUntil("[data-smartmenus-id]","ul").get().reverse()).add(c).each(function(){e.itemActivate($(this).dataSM("parent-a"))})}if(this.isCollapsible()&&!b||this.menuHideSubMenus(this.activatedItems[d-1]&&this.activatedItems[d-1][0]==a[0]?d:d-1),this.activatedItems[d-1]=a,this.$root.triggerHandler("activate.smapi",a[0])!==!1){var f=a.dataSM("sub");f&&(this.isTouchMode()||!this.opts.showOnClick||this.clickActivated)&&this.menuShow(f)}},itemBlur:function(a){var b=$(a.currentTarget);this.handleItemEvents(b)&&this.$root.triggerHandler("blur.smapi",b[0])},itemClick:function(a){var b=$(a.currentTarget);if(this.handleItemEvents(b)){if(this.$touchScrollingSub&&this.$touchScrollingSub[0]==b.closest("ul")[0])return this.$touchScrollingSub=null,a.stopPropagation(),!1;if(this.$root.triggerHandler("click.smapi",b[0])===!1)return!1;var c=$(a.target).is("span.sub-arrow"),d=b.dataSM("sub"),e=!!d&&2==d.dataSM("level");if(d&&!d.is(":visible")){if(this.opts.showOnClick&&e&&(this.clickActivated=!0),this.itemActivate(b),d.is(":visible"))return this.focusActivated=!0,!1}else if(this.isCollapsible()&&c)return this.itemActivate(b),this.menuHide(d),!1;return!(this.opts.showOnClick&&e||b.hasClass("disabled")||this.$root.triggerHandler("select.smapi",b[0])===!1)&&void 0}},itemDown:function(a){var b=$(a.currentTarget);this.handleItemEvents(b)&&b.dataSM("mousedown",!0)},itemEnter:function(a){var b=$(a.currentTarget);if(this.handleItemEvents(b)){if(!this.isTouchMode()){this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=0);var c=this;this.showTimeout=setTimeout(function(){c.itemActivate(b)},this.opts.showOnClick&&1==b.closest("ul").dataSM("level")?1:this.opts.showTimeout)}this.$root.triggerHandler("mouseenter.smapi",b[0])}},itemFocus:function(a){var b=$(a.currentTarget);this.handleItemEvents(b)&&(!this.focusActivated||this.isTouchMode()&&b.dataSM("mousedown")||this.activatedItems.length&&this.activatedItems[this.activatedItems.length-1][0]==b[0]||this.itemActivate(b,!0),this.$root.triggerHandler("focus.smapi",b[0]))},itemLeave:function(a){var b=$(a.currentTarget);this.handleItemEvents(b)&&(this.isTouchMode()||(b[0].blur(),this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=0)),b.removeDataSM("mousedown"),this.$root.triggerHandler("mouseleave.smapi",b[0]))},menuHide:function(a){if(this.$root.triggerHandler("beforehide.smapi",a[0])!==!1&&(a.stop(!0,!0),"none"!=a.css("display"))){var b=function(){a.css("z-index","")};this.isCollapsible()?this.opts.collapsibleHideFunction?this.opts.collapsibleHideFunction.call(this,a,b):a.hide(this.opts.collapsibleHideDuration,b):this.opts.hideFunction?this.opts.hideFunction.call(this,a,b):a.hide(this.opts.hideDuration,b),a.dataSM("ie-shim")&&a.dataSM("ie-shim").remove().css({"-webkit-transform":"",transform:""}),a.dataSM("scroll")&&(this.menuScrollStop(a),a.css({"touch-action":"","-ms-touch-action":"","-webkit-transform":"",transform:""}).unbind(".smartmenus_scroll").removeDataSM("scroll").dataSM("scroll-arrows").hide()),a.dataSM("parent-a").removeClass("highlighted").attr("aria-expanded","false"),a.attr({"aria-expanded":"false","aria-hidden":"true"});var c=a.dataSM("level");this.activatedItems.splice(c-1,1),this.visibleSubMenus.splice($.inArray(a,this.visibleSubMenus),1),this.$root.triggerHandler("hide.smapi",a[0])}},menuHideAll:function(){this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=0);for(var a=this.opts.isPopup?1:0,b=this.visibleSubMenus.length-1;b>=a;b--)this.menuHide(this.visibleSubMenus[b]);this.opts.isPopup&&(this.$root.stop(!0,!0),this.$root.is(":visible")&&(this.opts.hideFunction?this.opts.hideFunction.call(this,this.$root):this.$root.hide(this.opts.hideDuration),this.$root.dataSM("ie-shim")&&this.$root.dataSM("ie-shim").remove())),this.activatedItems=[],this.visibleSubMenus=[],this.clickActivated=!1,this.focusActivated=!1,this.zIndexInc=0,this.$root.triggerHandler("hideAll.smapi")},menuHideSubMenus:function(a){for(var b=this.activatedItems.length-1;b>=a;b--){var c=this.activatedItems[b].dataSM("sub");c&&this.menuHide(c)}},menuIframeShim:function(a){IE&&this.opts.overlapControlsInIE&&!a.dataSM("ie-shim")&&a.dataSM("ie-shim",$("<iframe/>").attr({src:"javascript:0",tabindex:-9}).css({position:"absolute",top:"auto",left:"0",opacity:0,border:"0"}))},menuInit:function(a){if(!a.dataSM("in-mega")){a.hasClass("mega-menu")&&a.find("ul").dataSM("in-mega",!0);for(var b=2,c=a[0];(c=c.parentNode.parentNode)!=this.$root[0];)b++;var d=a.prevAll("a").eq(-1);d.length||(d=a.prevAll().find("a").eq(-1)),d.addClass("has-submenu").dataSM("sub",a),a.dataSM("parent-a",d).dataSM("level",b).parent().dataSM("sub",a);var e=d.attr("id")||this.accessIdPrefix+ ++this.idInc,f=a.attr("id")||this.accessIdPrefix+ ++this.idInc;d.attr({id:e,"aria-haspopup":"true","aria-controls":f,"aria-expanded":"false"}),a.attr({id:f,role:"group","aria-hidden":"true","aria-labelledby":e,"aria-expanded":"false"}),this.opts.subIndicators&&d[this.opts.subIndicatorsPos](this.$subArrow.clone())}},menuPosition:function(a){var v,w,b=a.dataSM("parent-a"),c=b.closest("li"),d=c.parent(),e=a.dataSM("level"),f=this.getWidth(a),g=this.getHeight(a),h=b.offset(),i=h.left,j=h.top,k=this.getWidth(b),l=this.getHeight(b),m=$(window),n=m.scrollLeft(),o=m.scrollTop(),p=this.getViewportWidth(),q=this.getViewportHeight(),r=d.parent().is("[data-sm-horizontal-sub]")||2==e&&!d.hasClass("sm-vertical"),s=this.opts.rightToLeftSubMenus&&!c.is("[data-sm-reverse]")||!this.opts.rightToLeftSubMenus&&c.is("[data-sm-reverse]"),t=2==e?this.opts.mainMenuSubOffsetX:this.opts.subMenusSubOffsetX,u=2==e?this.opts.mainMenuSubOffsetY:this.opts.subMenusSubOffsetY;if(r?(v=s?k-f-t:t,w=this.opts.bottomToTopSubMenus?-g-u:l+u):(v=s?t-f:k-t,w=this.opts.bottomToTopSubMenus?l-u-g:u),this.opts.keepInViewport){var x=i+v,y=j+w;if(s&&x<n?v=r?n-x+v:k-t:!s&&x+f>n+p&&(v=r?n+p-f-x+v:t-f),r||(g<q&&y+g>o+q?w+=o+q-g-y:(g>=q||y<o)&&(w+=o-y)),r&&(y+g>o+q+.49||y<o)||!r&&g>q+.49){var z=this;a.dataSM("scroll-arrows")||a.dataSM("scroll-arrows",$([$('<span class="scroll-up"><span class="scroll-up-arrow"></span></span>')[0],$('<span class="scroll-down"><span class="scroll-down-arrow"></span></span>')[0]]).bind({mouseenter:function(){a.dataSM("scroll").up=$(this).hasClass("scroll-up"),z.menuScroll(a)},mouseleave:function(b){z.menuScrollStop(a),z.menuScrollOut(a,b)},"mousewheel DOMMouseScroll":function(a){a.preventDefault()}}).insertAfter(a));var A=".smartmenus_scroll";a.dataSM("scroll",{y:this.cssTransforms3d?0:w-l,step:1,itemH:l,subH:g,arrowDownH:this.getHeight(a.dataSM("scroll-arrows").eq(1))}).bind(getEventsNS([["mouseover",function(b){z.menuScrollOver(a,b)}],["mouseout",function(b){z.menuScrollOut(a,b)}],["mousewheel DOMMouseScroll",function(b){z.menuScrollMousewheel(a,b)}]],A)).dataSM("scroll-arrows").css({top:"auto",left:"0",marginLeft:v+(parseInt(a.css("border-left-width"))||0),width:f-(parseInt(a.css("border-left-width"))||0)-(parseInt(a.css("border-right-width"))||0),zIndex:a.css("z-index")}).eq(r&&this.opts.bottomToTopSubMenus?0:1).show(),this.isFixed()&&a.css({"touch-action":"none","-ms-touch-action":"none"}).bind(getEventsNS([[touchEvents?"touchstart touchmove touchend":"pointerdown pointermove pointerup MSPointerDown MSPointerMove MSPointerUp",function(b){z.menuScrollTouch(a,b)}]],A))}}a.css({top:"auto",left:"0",marginLeft:v,marginTop:w-l}),this.menuIframeShim(a),a.dataSM("ie-shim")&&a.dataSM("ie-shim").css({zIndex:a.css("z-index"),width:f,height:g,marginLeft:v,marginTop:w-l})},menuScroll:function(a,b,c){var g,d=a.dataSM("scroll"),e=a.dataSM("scroll-arrows"),f=d.up?d.upEnd:d.downEnd;if(!b&&d.momentum){if(d.momentum*=.92,g=d.momentum,g<.5)return void this.menuScrollStop(a)}else g=c||(b||!this.opts.scrollAccelerate?this.opts.scrollStep:Math.floor(d.step));var h=a.dataSM("level");if(this.activatedItems[h-1]&&this.activatedItems[h-1].dataSM("sub")&&this.activatedItems[h-1].dataSM("sub").is(":visible")&&this.menuHideSubMenus(h-1),d.y=d.up&&f<=d.y||!d.up&&f>=d.y?d.y:Math.abs(f-d.y)>g?d.y+(d.up?g:-g):f,a.add(a.dataSM("ie-shim")).css(this.cssTransforms3d?{"-webkit-transform":"translate3d(0, "+d.y+"px, 0)",transform:"translate3d(0, "+d.y+"px, 0)"}:{marginTop:d.y}),mouse&&(d.up&&d.y>d.downEnd||!d.up&&d.y<d.upEnd)&&e.eq(d.up?1:0).show(),d.y==f)mouse&&e.eq(d.up?0:1).hide(),this.menuScrollStop(a);else if(!b){this.opts.scrollAccelerate&&d.step<this.opts.scrollStep&&(d.step+=.2);var i=this;this.scrollTimeout=requestAnimationFrame(function(){i.menuScroll(a)})}},menuScrollMousewheel:function(a,b){if(this.getClosestMenu(b.target)==a[0]){b=b.originalEvent;var c=(b.wheelDelta||-b.detail)>0;a.dataSM("scroll-arrows").eq(c?0:1).is(":visible")&&(a.dataSM("scroll").up=c,this.menuScroll(a,!0))}b.preventDefault()},menuScrollOut:function(a,b){mouse&&(/^scroll-(up|down)/.test((b.relatedTarget||"").className)||(a[0]==b.relatedTarget||$.contains(a[0],b.relatedTarget))&&this.getClosestMenu(b.relatedTarget)==a[0]||a.dataSM("scroll-arrows").css("visibility","hidden"))},menuScrollOver:function(a,b){if(mouse&&!/^scroll-(up|down)/.test(b.target.className)&&this.getClosestMenu(b.target)==a[0]){this.menuScrollRefreshData(a);var c=a.dataSM("scroll"),d=$(window).scrollTop()-a.dataSM("parent-a").offset().top-c.itemH;a.dataSM("scroll-arrows").eq(0).css("margin-top",d).end().eq(1).css("margin-top",d+this.getViewportHeight()-c.arrowDownH).end().css("visibility","visible")}},menuScrollRefreshData:function(a){var b=a.dataSM("scroll"),c=$(window).scrollTop()-a.dataSM("parent-a").offset().top-b.itemH;this.cssTransforms3d&&(c=-(parseFloat(a.css("margin-top"))-c)),$.extend(b,{upEnd:c,downEnd:c+this.getViewportHeight()-b.subH})},menuScrollStop:function(a){if(this.scrollTimeout)return cancelAnimationFrame(this.scrollTimeout),this.scrollTimeout=0,a.dataSM("scroll").step=1,!0},menuScrollTouch:function(a,b){if(b=b.originalEvent,isTouchEvent(b)){var c=this.getTouchPoint(b);if(this.getClosestMenu(c.target)==a[0]){var d=a.dataSM("scroll");if(/(start|down)$/i.test(b.type))this.menuScrollStop(a)?(b.preventDefault(),this.$touchScrollingSub=a):this.$touchScrollingSub=null,this.menuScrollRefreshData(a),$.extend(d,{touchStartY:c.pageY,touchStartTime:b.timeStamp});else if(/move$/i.test(b.type)){var e=void 0!==d.touchY?d.touchY:d.touchStartY;if(void 0!==e&&e!=c.pageY){this.$touchScrollingSub=a;var f=e<c.pageY;void 0!==d.up&&d.up!=f&&$.extend(d,{touchStartY:c.pageY,touchStartTime:b.timeStamp}),$.extend(d,{up:f,touchY:c.pageY}),this.menuScroll(a,!0,Math.abs(c.pageY-e))}b.preventDefault()}else void 0!==d.touchY&&((d.momentum=15*Math.pow(Math.abs(c.pageY-d.touchStartY)/(b.timeStamp-d.touchStartTime),2))&&(this.menuScrollStop(a),this.menuScroll(a),b.preventDefault()),delete d.touchY)}}},menuShow:function(a){if((a.dataSM("beforefirstshowfired")||(a.dataSM("beforefirstshowfired",!0),this.$root.triggerHandler("beforefirstshow.smapi",a[0])!==!1))&&this.$root.triggerHandler("beforeshow.smapi",a[0])!==!1&&(a.dataSM("shown-before",!0).stop(!0,!0),!a.is(":visible"))){var b=a.dataSM("parent-a");if((this.opts.keepHighlighted||this.isCollapsible())&&b.addClass("highlighted"),this.isCollapsible())a.removeClass("sm-nowrap").css({zIndex:"",width:"auto",minWidth:"",maxWidth:"",top:"",left:"",marginLeft:"",marginTop:""});else{if(a.css("z-index",this.zIndexInc=(this.zIndexInc||this.getStartZIndex())+1),(this.opts.subMenusMinWidth||this.opts.subMenusMaxWidth)&&(a.css({width:"auto",minWidth:"",maxWidth:""}).addClass("sm-nowrap"),this.opts.subMenusMinWidth&&a.css("min-width",this.opts.subMenusMinWidth),this.opts.subMenusMaxWidth)){var c=this.getWidth(a);a.css("max-width",this.opts.subMenusMaxWidth),c>this.getWidth(a)&&a.removeClass("sm-nowrap").css("width",this.opts.subMenusMaxWidth)}this.menuPosition(a),a.dataSM("ie-shim")&&a.dataSM("ie-shim").insertBefore(a)}var d=function(){a.css("overflow","")};this.isCollapsible()?this.opts.collapsibleShowFunction?this.opts.collapsibleShowFunction.call(this,a,d):a.show(this.opts.collapsibleShowDuration,d):this.opts.showFunction?this.opts.showFunction.call(this,a,d):a.show(this.opts.showDuration,d),b.attr("aria-expanded","true"),a.attr({"aria-expanded":"true","aria-hidden":"false"}),this.visibleSubMenus.push(a),this.$root.triggerHandler("show.smapi",a[0])}},popupHide:function(a){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0);var b=this;this.hideTimeout=setTimeout(function(){b.menuHideAll()},a?1:this.opts.hideTimeout)},popupShow:function(a,b){if(!this.opts.isPopup)return void alert('SmartMenus jQuery Error:\n\nIf you want to show this menu via the "popupShow" method, set the isPopup:true option.');if(this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0),this.$root.dataSM("shown-before",!0).stop(!0,!0),!this.$root.is(":visible")){this.$root.css({left:a,top:b}),this.menuIframeShim(this.$root),this.$root.dataSM("ie-shim")&&this.$root.dataSM("ie-shim").css({zIndex:this.$root.css("z-index"),width:this.getWidth(this.$root),height:this.getHeight(this.$root),left:a,top:b}).insertBefore(this.$root);var c=this,d=function(){c.$root.css("overflow","")};this.opts.showFunction?this.opts.showFunction.call(this,this.$root,d):this.$root.show(this.opts.showDuration,d),this.visibleSubMenus[0]=this.$root}},refresh:function(){this.destroy(!0),this.init(!0)},rootKeyDown:function(a){if(this.handleEvents())switch(a.keyCode){case 27:var b=this.activatedItems[0];if(b){this.menuHideAll(),b[0].focus();var c=b.dataSM("sub");c&&this.menuHide(c)}break;case 32:var d=$(a.target);if(d.is("a")&&this.handleItemEvents(d)){var c=d.dataSM("sub");c&&!c.is(":visible")&&(this.itemClick({currentTarget:a.target}),a.preventDefault())}}},rootOut:function(a){if(this.handleEvents()&&!this.isTouchMode()&&a.target!=this.$root[0]&&(this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0),!this.opts.showOnClick||!this.opts.hideOnClick)){var b=this;this.hideTimeout=setTimeout(function(){b.menuHideAll()},this.opts.hideTimeout)}},rootOver:function(a){this.handleEvents()&&!this.isTouchMode()&&a.target!=this.$root[0]&&this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0)},winResize:function(a){if(this.handleEvents()){if(!("onorientationchange"in window)||"orientationchange"==a.type){var c=this.isCollapsible();this.wasCollapsible&&c||(this.activatedItems.length&&this.activatedItems[this.activatedItems.length-1][0].blur(),this.menuHideAll()),this.wasCollapsible=c}}else if(this.$disableOverlay){var b=this.$root.offset();this.$disableOverlay.css({top:b.top,left:b.left,width:this.$root.outerWidth(),height:this.$root.outerHeight()})}}}}),$.fn.dataSM=function(a,b){return b?this.data(a+"_smartmenus",b):this.data(a+"_smartmenus")},$.fn.removeDataSM=function(a){return this.removeData(a+"_smartmenus")},$.fn.smartmenus=function(options){if("string"==typeof options){var args=arguments,method=options;return Array.prototype.shift.call(args),this.each(function(){var a=$(this).data("smartmenus");a&&a[method]&&a[method].apply(a,args)})}return this.each(function(){var dataOpts=$(this).data("sm-options")||null;if(dataOpts)try{dataOpts=eval("("+dataOpts+")")}catch(a){dataOpts=null,alert('ERROR\n\nSmartMenus jQuery init:\nInvalid "data-sm-options" attribute value syntax.')}new $.SmartMenus(this,$.extend({},$.fn.smartmenus.defaults,options,dataOpts))})},$.fn.smartmenus.defaults={isPopup:!1,mainMenuSubOffsetX:0,mainMenuSubOffsetY:0,subMenusSubOffsetX:0,subMenusSubOffsetY:0,subMenusMinWidth:"10em",subMenusMaxWidth:"20em",subIndicators:!0,subIndicatorsPos:"prepend",subIndicatorsText:"+",scrollStep:30,scrollAccelerate:!0,showTimeout:250,hideTimeout:500,showDuration:0,showFunction:null,hideDuration:0,hideFunction:function(a,b){a.fadeOut(200,b)},collapsibleShowDuration:0,collapsibleShowFunction:function(a,b){a.slideDown(200,b)},collapsibleHideDuration:0,collapsibleHideFunction:function(a,b){a.slideUp(200,b)},showOnClick:!1,hideOnClick:!0,noMouseOver:!1,keepInViewport:!0,keepHighlighted:!0,markCurrentItem:!1,markCurrentTree:!0,rightToLeftSubMenus:!1,bottomToTopSubMenus:!1,overlapControlsInIE:!0},$});
