(function(e,t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],function(o){return t(o,e,e.document)}):"object"==typeof module&&module.exports?module.exports=t(require("jquery"),e,e.document):t(jquery,e,e.document)})("undefined"!=typeof window?window:this,function(e,t,o,n){"use strict";function r(){return b.height()+r.offset}function s(o,n,s,i){if(w===o&&(s=!1),d===!0)return!0;if(m[o]){if(m=!1,k===!0&&(r.afterrender(),k=!1),s&&"function"==typeof r.before&&r.before(o,g)===!1)return!0;if(s=1,o=p[o],k===!1&&w>o&&i===!1&&v[o]&&(l=r(),s=parseint(g[o].outerheight()/l),o=parseint(p[o])+(g[o].outerheight()-l)),r.updatehash&&r.sectionname&&(k!==!0||0!==o))if(history.pushstate)try{history.replacestate(null,null,m[o])}catch(e){t.console&&console.warn("scrollify warning: page must be hosted to manipulate the hash value.")}else t.location.hash=m[o];if(w=o,n)e(r.target).stop().scrolltop(o),s&&r.after(o,g);else{if(x=!0,e().velocity?e(r.target).stop().velocity("scroll",{duration:r.scrollspeed,easing:r.easing,offset:o,mobileha:!1}):e(r.target).stop().animate({scrolltop:o},r.scrollspeed,r.easing),t.location.hash.length&&r.sectionname&&t.console)try{e(t.location.hash).length&&console.warn("scrollify warning: id matches hash value - this will cause the page to anchor.")}catch(e){}e(r.target).promise().done(function(){x=!1,k=!1,s&&r.after(o,g)})}}}function i(e){function t(t){for(var o=0,n=e.slice(math.max(e.length-t,1)),r=0;r=n}function a(e,t){for(var o=m.length;o>=0;o--)"string"==typeof e?m[o]===e&&(y=o,s(o,t,!0,!0)):o===e&&(y=o,s(o,t,!0,!0))}var c,u,l,h,d,f,p=[],m=[],g=[],v=[],y=0,w=0,s=1,h=!1,b=e(t),e=b.scrolltop(),m=!1,x=!1,t=!1,d=!1,i=[],n=(new date).gettime(),k=!0,l=!1,o=0,z="onwheel"in o?"wheel":o.onmousewheel!==n?"mousewheel":"dommousescroll",r={section:".section",sectionname:"section-name",interstitialsection:"",easing:"easeoutexpo",scrollspeed:1100,offset:0,scrollbars:!0,target:"html,body",standardscrollelements:!1,setheights:!0,overflowscroll:!0,updatehash:!0,touchscroll:!0,before:function(){},after:function(){},afterresize:function(){},afterrender:function(){}},j=function(n){function a(t){e().velocity?e(r.target).stop().velocity("scroll",{duration:r.scrollspeed,easing:r.easing,offset:t,mobileha:!1}):e(r.target).stop().animate({scrolltop:t},r.scrollspeed,r.easing)}function w(t){t&&(e=b.scrolltop());var o=r.section;v=[],r.interstitialsection.length&&(o+=","+r.interstitialsection),r.scrollbars===!1&&(r.overflowscroll=!1),l=r(),e(o).each(function(t){var o=e(this);r.setheights?o.is(r.interstitialsection)?v[t]=!1:o.css("height","auto").outerheight()0?p[o]=parseint(n.offset().top)+r.offset:p[o]=parseint(n.offset().top),r.sectionname&&n.data(r.sectionname)?m[o]="#"+n.data(r.sectionname).tostring().replace(/ /g,"-"):n.is(r.interstitialsection)===!1?m[o]="#"+(o+1):(m[o]="#",o===e(r).length-1&&o>1&&(p[o]=p[o-1]+(parseint(e(e(r)[o-1]).outerheight())-parseint(e(t).height()))+parseint(n.outerheight()))),g[o]=n;try{e(m[o]).length&&t.console&&console.warn("scrollify warning: section names can't match ids - this will cause the browser to anchor.")}catch(e){}t.location.hash===m[o]&&(y=o,h=!0)}),!0===o&&s(y,!1,!1,!1)}function o(){return!v[y]||(e=b.scrolltop(),!(e>parseint(p[y])))}function j(){return!v[y]||(e=b.scrolltop(),l=r(),!(ey||o())&&(y=i,s(i,e,t,!1))},wheelhandler:function(o){if(d===!0)return!0;if(r.standardscrollelements&&(e(o.target).is(r.standardscrollelements)||e(o.target).closest(r.standardscrollelements).length))return!0;v[y]||o.preventdefault();var n=(new date).gettime();o=o||t.event;var r=o.originalevent.wheeldelta||-o.originalevent.deltay||-o.originalevent.detail,a=math.max(-1,math.min(1,r));if(i.length>149&&i.shift(),i.push(math.abs(r)),n-n>200&&(i=[]),n=n,x)return!1;if(a<0){if(y0&&y>0&&o()){if(!i(i))return!1;o.preventdefault(),y--,x=!0,s(y,!1,!0,!1)}},keyhandler:function(t){return d===!0||o.activeelement.readonly===!1||(!(!r.standardscrollelements||!e(t.target).is(r.standardscrollelements)&&!e(t.target).closest(r.standardscrollelements).length)||x!==!0&&void(38==t.keycode||33==t.keycode?y>0&&o()&&(t.preventdefault(),y--,s(y,!1,!0,!1)):40!=t.keycode&&34!=t.keycode||ymath.abs(d.touches.touchstart.x-d.touches.touchmove.x)&&(t.preventdefault(),d.touches.direction="y",d.options.timestamp+d.options.timegap<(new date).gettime()&&0==d.touches.touchend&&(d.touches.touchend=!0,d.touches.touchstart.y>-1&&math.abs(d.touches.touchmove.y-d.touches.touchstart.y)>d.options.distance&&(d.touches.touchstart.y-1&&d.touches.touchmove.y>-1&&"y"===d.touches.direction&&(math.abs(d.touches.touchmove.y-d.touches.touchstart.y)>d.options.distance&&(d.touches.touchstart.ys?(a(parseint(p[y])+l*s),s+=1):a(parseint(p[y])+(g[y].outerheight()-l))))},up:function(){y>=0&&(o()&&y>0?(y--,s(y,!1,!0,!1)):s>2?(l=r(),s-=1,a(parseint(p[y])+l*s)):(s=1,a(parseint(p[y]))))},init:function(){if(o.addeventlistener&&r.touchscroll){var e={passive:!1};o.addeventlistener("touchstart",d.touchhandler,e),o.addeventlistener("touchmove",d.touchhandler,e),o.addeventlistener("touchend",d.touchhandler,e)}}},f={refresh:function(e,t){cleartimeout(u),u=settimeout(function(){w(!0),k(t,!1),e&&r.afterresize()},400)},handleupdate:function(){f.refresh(!1,!1)},handleresize:function(){f.refresh(!0,!1)},handleorientation:function(){f.refresh(!0,!0)}},r=e.extend(r,n),w(!1),k(!1,!0),!0===h?s(y,!1,!0,!0):settimeout(function(){h.calculatenearest(!0,!1)},200),p.length&&(h.init(),d.init(),b.on("resize",f.handleresize),o.addeventlistener&&t.addeventlistener("orientationchange",f.handleorientation,!1))};return j.move=function(t){return t!==n&&(t.originalevent&&(t=e(this).attr("href")),void a(t,!1))},j.instantmove=function(e){return e!==n&&void a(e,!0)},j.next=function(){y0&&(y-=1,s(y,!1,!0,!0))},j.instantnext=function(){y0&&(y-=1,s(y,!0,!0,!0))},j.destroy=function(){return!!l&&(r.setheights&&e(r.section).each(function(){e(this).css("height","auto")}),b.off("resize",f.handleresize),r.scrollbars&&(b.off("mousedown",h.handlemousedown),b.off("mouseup",h.handlemouseup),b.off("scroll",h.handlescroll)),b.off(z,h.wheelhandler),b.off("keydown",h.keyhandler),o.addeventlistener&&r.touchscroll&&(o.removeeventlistener("touchstart",d.touchhandler,!1),o.removeeventlistener("touchmove",d.touchhandler,!1),o.removeeventlistener("touchend",d.touchhandler,!1)),p=[],m=[],g=[],void(v=[]))},j.update=function(){return!!l&&void f.handleupdate()},j.current=function(){return g[y]},j.currentindex=function(){return y},j.disable=function(){d=!0},j.enable=function(){d=!1,l&&h.calculatenearest(!1,!1)},j.isdisabled=function(){return d},j.setoptions=function(o){return!!l&&void("object"==typeof o?(r=e.extend(r,o),f.handleupdate()):t.console&&console.warn("scrollify warning: setoptions expects an object."))},e.scrollify=j,j});