/*!
 * skrollr core
 *
 * Alexander Prinzhorn - https://github.com/Prinzhorn/skrollr
 *
 * Free to use under terms of MIT license
 */
(function(n,t,i){"use strict";function c(i){var u,e;if(f=t.documentElement,y=t.body,nu(),r=this,i=i||{},at=i.constants||{},i.easing)for(u in i.easing)st[u]=i.easing[u];return hi=i.edgeStrategy||"set",p={beforerender:i.beforerender,render:i.render,keyframe:i.keyframe},rt=i.forceHeight!==!1,rt&&(ri=i.scale||1),vt=i.mobileDeceleration||vr,oi=i.smoothScrolling!==!1,pt=i.smoothScrollingDuration||pr,d={targetTop:r.getScrollTop()},a=(i.mobileCheck||function(){return/Android|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent||navigator.vendor||n.opera)})(),a?(l=t.getElementById(i.skrollrBody||yr),l&&lu(),ru(),w(f,[nt,pi],[ti])):w(f,[nt,yi],[ti]),r.refresh(),or(n,"resize orientationchange",function(){var n=f.clientWidth,t=f.clientHeight;(t!==ei||n!==fi)&&(ei=t,fi=n,yt=!0)}),e=tu(),function o(){eu();lr=e(o)}(),r}var v={get:function(){return r},init:function(n){return r||new c(n)},VERSION:"0.6.30"},bt=Object.prototype.hasOwnProperty,e=n.Math,kt=n.getComputedStyle,f,y,ci="touchstart",li="touchmove",ai="touchcancel",vi="touchend",ft="skrollable",dt=ft+"-before",gt=ft+"-between",ni=ft+"-after",nt="skrollr",ti="no-"+nt,yi=nt+"-desktop",pi=nt+"-mobile",wi="linear",ar=1e3,vr=.004,yr="skrollr-body",pr=200,wr="start",bi="end",ki="center",di="bottom",g="___skrollable_id",ii=/^(?:input|textarea|button|select)$/i,br=/^\s+|\s+$/g,kr=/^data(?:-(_\w+))?(?:-?(-?\d*\.?\d+p?))?(?:-?(start|end|top|center|bottom))?(?:-?(top|center|bottom))?$/,dr=/\s*(@?[\w\-\[\]]+)\s*:\s*(.+?)\s*(?:;|$)/gi,gr=/^(@?[a-z\-]+)\[(\w+)\]$/,gi=/-([a-z0-9_])/g,nr=function(n,t){return t.toUpperCase()},tr=/[\-+]?[\d]*\.?[\d]+/g,ir=/\{\?\}/g,rr=/rgba?\(\s*-?\d+\s*,\s*-?\d+\s*,\s*-?\d+/g,ur=/[a-z\-]+-gradient/g,o="",tt="",nu=function(){var i=/^(?:O|Moz|webkit|ms)|(?:-(?:o|moz|webkit|ms)-)/,t,n;if(kt){t=kt(y,null);for(n in t)if(o=n.match(i)||+n==n&&t[n].match(i),o)break;if(!o){o=tt="";return}o=o[0];o.slice(0,1)==="-"?(tt=o,o={"-webkit-":"webkit","-moz-":"Moz","-ms-":"ms","-o-":"O"}[o]):tt="-"+o.toLowerCase()+"-"}},tu=function(){var t=n.requestAnimationFrame||n[o.toLowerCase()+"RequestAnimationFrame"],i=it();return(a||!t)&&(t=function(t){var r=it()-i,u=e.max(0,1e3/60-r);return n.setTimeout(function(){i=it();t()},u)}),t},iu=function(){var t=n.cancelAnimationFrame||n[o.toLowerCase()+"CancelAnimationFrame"];return(a||!t)&&(t=function(t){return n.clearTimeout(t)}),t},st={begin:function(){return 0},end:function(){return 1},linear:function(n){return n},quadratic:function(n){return n*n},cubic:function(n){return n*n*n},swing:function(n){return-e.cos(n*e.PI)/2+.5},sqrt:function(n){return e.sqrt(n)},outCubic:function(n){return e.pow(n-1,3)+1},bounce:function(n){var t;if(n<=.5083)t=3;else if(n<=.8489)t=9;else if(n<=.96208)t=27;else if(n<=.99981)t=91;else return 1;return 1-e.abs(3*e.cos(n*t*1.028)/t)}};c.prototype.refresh=function(n){var o,a,b=!1,v,ot,e,c,f,nt,y,s,st,tt,it,l,p;for(n===i?(b=!0,h=[],si=0,n=t.getElementsByTagName("*")):n.length===i&&(n=[n]),o=0,a=n.length;o<a;o++){var u=n[o],k=u,d=[],rt=oi,ut=hi,et=!1;if(b&&g in u&&delete u[g],u.attributes){for(v=0,ot=u.attributes.length;v<ot;v++){if(e=u.attributes[v],e.name==="data-anchor-target"){if(k=t.querySelector(e.value),k===null)throw'Unable to find anchor target "'+e.value+'"';continue}if(e.name==="data-smooth-scrolling"){rt=e.value!=="off";continue}if(e.name==="data-edge-strategy"){ut=e.value;continue}if(e.name==="data-emit-events"){et=!0;continue}(c=e.name.match(kr),c!==null)&&(f={props:e.value,element:u,eventType:e.name.replace(gi,nr)},d.push(f),nt=c[1],nt&&(f.constant=nt.substr(1)),y=c[2],/p$/.test(y)?(f.isPercentage=!0,f.offset=(y.slice(0,-1)|0)/100):f.offset=y|0,s=c[3],st=c[4]||s,s&&s!==wr&&s!==bi?(f.mode="relative",f.anchors=[s,st]):(f.mode="absolute",s===bi?f.isEnd=!0:f.isPercentage||(f.offset=f.offset*ri)))}d.length&&(!b&&g in u?(l=u[g],tt=h[l].styleAttr,it=h[l].classAttr):(l=u[g]=si++,tt=u.style.cssText,it=hr(u)),h[l]={element:u,styleAttr:tt,classAttr:it,anchorTarget:k,keyFrames:d,smoothScrolling:rt,edgeStrategy:ut,emitEvents:et,lastFrameIndex:-1},w(u,[ft],[]))}}for(sr(),o=0,a=n.length;o<a;o++)(p=h[n[o][g]],p!==i)&&(ou(p),hu(p));return r};c.prototype.relativeToAbsolute=function(n,t,i){var o=f.clientHeight,e=n.getBoundingClientRect(),u=e.top,s=e.bottom-e.top;return t===di?u-=o:t===ki&&(u-=o/2),i===di?u+=s:i===ki&&(u+=s/2),u+=r.getScrollTop(),u+.5|0};c.prototype.animateTo=function(n,t){t=t||{};var f=it(),e=r.getScrollTop(),o=t.duration===i?ar:t.duration;return u={startTop:e,topDiff:n-e,targetTop:n,duration:o,startTime:f,endTime:f+o,easing:st[t.easing||wi],done:t.done},u.topDiff||(u.done&&u.done.call(r,!1),u=i),r};c.prototype.stopAnimateTo=function(){u&&u.done&&u.done.call(r,!0);u=i};c.prototype.isAnimatingTo=function(){return!!u};c.prototype.isMobile=function(){return a};c.prototype.setScrollTop=function(t,i){return ut=i===!0,a?et=e.min(e.max(t,0),s):n.scrollTo(0,t),r};c.prototype.getScrollTop=function(){return a?et:n.pageYOffset||f.scrollTop||y.scrollTop||0};c.prototype.getMaxScrollTop=function(){return s};c.prototype.on=function(n,t){return p[n]=t,r};c.prototype.off=function(n){return delete p[n],r};c.prototype.destroy=function(){var e=iu(),n,t;for(e(lr),vu(),w(f,[ti],[nt,yi,pi]),n=0,t=h.length;n<t;n++)ht(h[n].element);f.style.overflow=y.style.overflow="";f.style.height=y.style.height="";l&&v.setStyle(l,"transform","none");r=i;l=i;p=i;rt=i;s=0;ri=1;at=i;vt=i;b="down";k=-1;fi=0;ei=0;yt=!1;u=i;oi=i;pt=i;d=i;ut=i;si=0;hi=i;a=!1;et=0;ot=i};var ru=function(){var o,p,w,u,h,l,a,v,d,c,b,k;or(f,[ci,li,ai,vi].join(" "),function(n){var y=n.changedTouches[0],tt,nt;for(u=n.target;u.nodeType===3;)u=u.parentNode;h=y.clientY;l=y.clientX;c=n.timeStamp;ii.test(u.tagName)||n.preventDefault();switch(n.type){case ci:o&&o.blur();r.stopAnimateTo();o=u;p=a=h;w=l;d=c;break;case li:ii.test(u.tagName)&&t.activeElement!==u&&n.preventDefault();v=h-a;k=c-b;r.setScrollTop(et-v,!0);a=h;b=c;break;default:case ai:case vi:var ut=p-h,ft=w-l,ot=ft*ft+ut*ut;if(ot<49){ii.test(o.tagName)||(o.focus(),tt=t.createEvent("MouseEvents"),tt.initMouseEvent("click",!0,!0,n.view,1,y.screenX,y.screenY,y.clientX,y.clientY,n.ctrlKey,n.altKey,n.shiftKey,n.metaKey,0,null),o.dispatchEvent(tt));return}o=i;nt=v/k;nt=e.max(e.min(nt,3),-3);var g=e.abs(nt/vt),it=nt*g+.5*vt*g*g,f=r.getScrollTop()-it,rt=0;f>s?(rt=(s-f)/it,f=s):f<0&&(rt=-f/it,f=0);g=g*(1-rt);r.animateTo(f+.5|0,{easing:"outCubic",duration:g})}});n.scrollTo(0,0);f.style.overflow=y.style.overflow="hidden"},uu=function(){for(var b=f.clientHeight,p=yu(),u,y,w,o,t,l,n,c,v,i=0,a=h.length;i<a;i++)for(u=h[i],y=u.element,w=u.anchorTarget,o=u.keyFrames,t=0,l=o.length;t<l;t++)n=o[t],c=n.offset,v=p[n.constant]||0,n.frame=c,n.isPercentage&&(c=c*b,n.frame=c),n.mode==="relative"&&(ht(y),n.frame=r.relativeToAbsolute(w,n.anchors[0],n.anchors[1])-c,ht(y,!0)),n.frame+=v,rt&&!n.isEnd&&n.frame>s&&(s=n.frame);for(s=e.max(s,pu()),i=0,a=h.length;i<a;i++){for(u=h[i],o=u.keyFrames,t=0,l=o.length;t<l;t++)n=o[t],v=p[n.constant]||0,n.isEnd&&(n.frame=s-n.offset+v);u.keyFrames.sort(wu)}},fu=function(n,t){for(var k=0,et=h.length,a,f,s,y,p;k<et;k++){var i=h[k],u=i.element,c=i.smoothScrolling?n:t,e=i.keyFrames,d=e.length,g=e[0],nt=e[e.length-1],l=c<g.frame,rt=c>nt.frame,ut=l?g:nt,tt=i.emitEvents,it=i.lastFrameIndex,r,o;if(l||rt){if(l&&i.edge===-1||rt&&i.edge===1)continue;l?(w(u,[dt],[ni,gt]),tt&&it>-1&&(ct(u,g.eventType,b),i.lastFrameIndex=-1)):(w(u,[ni],[dt,gt]),tt&&it<d&&(ct(u,nt.eventType,b),i.lastFrameIndex=d));i.edge=l?-1:1;switch(i.edgeStrategy){case"reset":ht(u);continue;case"ease":c=ut.frame;break;default:case"set":a=ut.props;for(r in a)bt.call(a,r)&&(o=er(a[r].value),r.indexOf("@")===0?u.setAttribute(r.substr(1),o):v.setStyle(u,r,o));continue}}else i.edge!==0&&(w(u,[ft,gt],[dt,ni]),i.edge=0);for(f=0;f<d-1;f++)if(c>=e[f].frame&&c<=e[f+1].frame){s=e[f];y=e[f+1];for(r in s.props)bt.call(s.props,r)&&(p=(c-s.frame)/(y.frame-s.frame),p=s.props[r].easing(p),o=cu(s.props[r].value,y.props[r].value,p),o=er(o),r.indexOf("@")===0?u.setAttribute(r.substr(1),o):v.setStyle(u,r,o));tt&&it!==f&&(b==="down"?ct(u,s.eventType,b):ct(u,y.eventType,b),i.lastFrameIndex=f);break}}},eu=function(){var n,e,t,f,h,o,c;yt&&(yt=!1,sr());n=r.getScrollTop();t=it();u?(t>=u.endTime?(n=u.targetTop,e=u.done,u=i):(f=u.easing((t-u.startTime)/u.duration),n=u.startTop+f*u.topDiff|0),r.setScrollTop(n,!0)):ut||(h=d.targetTop-n,h&&(d={startTop:k,topDiff:n-k,targetTop:n,startTime:ui,endTime:ui+pt}),t<=d.endTime&&(f=st.sqrt((t-d.startTime)/pt),n=d.startTop+f*d.topDiff|0));(ut||k!==n)&&(b=n>k?"down":n<k?"up":b,ut=!1,o={curTop:n,lastTop:k,maxTop:s,direction:b},c=p.beforerender&&p.beforerender.call(r,o),c!==!1&&(fu(n,r.getScrollTop()),a&&l&&v.setStyle(l,"transform","translate(0, "+-et+"px) "+ot),k=n,p.render&&p.render.call(r,o)),e&&e.call(r,!1));ui=t},ou=function(n){for(var u=0,s=n.keyFrames.length,f,t,i,r,e,o;u<s;u++){for(f=n.keyFrames[u],e={};(o=dr.exec(f.props))!==null;)r=o[1],i=o[2],t=r.match(gr),t!==null?(r=t[1],t=t[2]):t=wi,i=i.indexOf("!")?su(i):[i.slice(1)],e[r]={value:i,easing:st[t]};f.props=e}},su=function(n){var t=[];return rr.lastIndex=0,n=n.replace(rr,function(n){return n.replace(tr,function(n){return n/255*100+"%"})}),tt&&(ur.lastIndex=0,n=n.replace(ur,function(n){return tt+n})),n=n.replace(tr,function(n){return t.push(+n),"{?}"}),t.unshift(n),t},hu=function(n){for(var i={},t=0,r=n.keyFrames.length;t<r;t++)fr(n.keyFrames[t],i);for(i={},t=n.keyFrames.length-1;t>=0;t--)fr(n.keyFrames[t],i)},fr=function(n,t){for(var i in t)bt.call(n.props,i)||(n.props[i]=t[i]);for(i in n.props)t[i]=n.props[i]},cu=function(n,t,i){var r,f=n.length,u;if(f!==t.length)throw"Can't interpolate between \""+n[0]+'" and "'+t[0]+'"';for(u=[n[0]],r=1;r<f;r++)u[r]=n[r]+(t[r]-n[r])*i;return u},er=function(n){var t=1;return ir.lastIndex=0,n[0].replace(ir,function(){return n[t++]})},ht=function(n,t){n=[].concat(n);for(var i,r,u=0,f=n.length;u<f;u++)(r=n[u],i=h[r[g]],i)&&(t?(r.style.cssText=i.dirtyStyleAttr,w(r,i.dirtyClassAttr)):(i.dirtyStyleAttr=r.style.cssText,i.dirtyClassAttr=hr(r),r.style.cssText=i.styleAttr,w(r,i.classAttr)))},lu=function(){ot="translateZ(0)";v.setStyle(l,"transform",ot);var n=kt(l),t=n.getPropertyValue("transform"),i=n.getPropertyValue(tt+"transform"),r=t&&t!=="none"||i&&i!=="none";r||(ot="")};v.setStyle=function(n,t,i){var r=n.style;if(t=t.replace(gi,nr).replace("-",""),t==="zIndex")r[t]=isNaN(i)?i:""+(i|0);else if(t==="float")r.styleFloat=r.cssFloat=i;else try{o&&(r[o+t.slice(0,1).toUpperCase()+t.slice(1)]=i);r[t]=i}catch(u){}};var or=v.addEvent=function(t,i,r){var o=function(t){return t=t||n.event,t.target||(t.target=t.srcElement),t.preventDefault||(t.preventDefault=function(){t.returnValue=!1;t.defaultPrevented=!0}),r.call(this,t)},u,f,e;for(i=i.split(" "),f=0,e=i.length;f<e;f++)u=i[f],t.addEventListener?t.addEventListener(u,r,!1):t.attachEvent("on"+u,o),wt.push({element:t,name:u,listener:r})},au=v.removeEvent=function(n,t,i){t=t.split(" ");for(var r=0,u=t.length;r<u;r++)n.removeEventListener?n.removeEventListener(t[r],i,!1):n.detachEvent("on"+t[r],i)},vu=function(){for(var n,t=0,i=wt.length;t<i;t++)n=wt[t],au(n.element,n.name,n.listener);wt=[]},ct=function(n,t,i){p.keyframe&&p.keyframe.call(r,n,t,i)},sr=function(){var n=r.getScrollTop();s=0;rt&&!a&&(y.style.height="");uu();rt&&!a&&(y.style.height=s+f.clientHeight+"px");a?r.setScrollTop(e.min(r.getScrollTop(),s)):r.setScrollTop(n,!0);ut=!0},yu=function(){var u=f.clientHeight,i={},t,n;for(t in at)n=at[t],typeof n=="function"?n=n.call(r):/p$/.test(n)&&(n=n.slice(0,-1)/100*u),i[t]=n;return i},pu=function(){var n=0,t;return l&&(n=e.max(l.offsetHeight,l.scrollHeight)),t=e.max(n,y.scrollHeight,y.offsetHeight,f.scrollHeight,f.offsetHeight,f.clientHeight),t-f.clientHeight},hr=function(t){var i="className";return n.SVGElement&&t instanceof n.SVGElement&&(t=t[i],i="baseVal"),t[i]},w=function(t,r,u){var e="className",o,h;if(n.SVGElement&&t instanceof n.SVGElement&&(t=t[e],e="baseVal"),u===i){t[e]=r;return}for(var f=t[e],s=0,c=u.length;s<c;s++)f=lt(f).replace(lt(u[s])," ");for(f=cr(f),o=0,h=r.length;o<h;o++)lt(f).indexOf(lt(r[o]))===-1&&(f+=" "+r[o]);t[e]=cr(f)},cr=function(n){return n.replace(br,"")},lt=function(n){return" "+n+" "},it=Date.now||function(){return+new Date},wu=function(n,t){return n.frame-t.frame},r,h,l,p,rt,s=0,ri=1,at,vt,b="down",k=-1,ui=it(),fi=0,ei=0,yt=!1,u,oi,pt,d,ut,si=0,hi,a=!1,et=0,ot,wt=[],lr;typeof define=="function"&&define.amd?define([],function(){return v}):typeof module!="undefined"&&module.exports?module.exports=v:n.skrollr=v})(window,document)