(function(){var a=[].indexof||function(a){for(var b=0,c=this.length;b=0,h={horizontal:{},vertical:{}},i=1,k={},j="waypoints-context-id",o="resize.waypoints",p="scroll.waypoints",q=1,r="waypoints-waypoint-ids",s="waypoint",t="waypoints",f=function(){function a(a){var b=this;this.$element=a,this.element=a[0],this.didresize=!1,this.didscroll=!1,this.id="context"+i++,this.oldscroll={x:a.scrollleft(),y:a.scrolltop()},this.waypoints={horizontal:{},vertical:{}},a.data(j,this.id),k[this.id]=this,a.bind(p,function(){var a;if(!b.didscroll&&!l)return b.didscroll=!0,a=function(){return b.doscroll(),b.didscroll=!1},d.settimeout(a,c[t].settings.scrollthrottle)}),a.bind(o,function(){var a;if(!b.didresize)return b.didresize=!0,a=function(){return c[t]("refresh"),b.didresize=!1},d.settimeout(a,c[t].settings.resizethrottle)})}return a.prototype.doscroll=function(){var a,b=this;return a={horizontal:{newscroll:this.$element.scrollleft(),oldscroll:this.oldscroll.x,forward:"right",backward:"left"},vertical:{newscroll:this.$element.scrolltop(),oldscroll:this.oldscroll.y,forward:"down",backward:"up"}},!l||a.vertical.oldscroll&&a.vertical.newscroll||c[t]("refresh"),c.each(a,function(a,d){var e,f,g;return g=[],f=d.newscroll>d.oldscroll,e=f?d.forward:d.backward,c.each(b.waypoints[a],function(a,b){var c,e;return d.oldscroll<(c=b.offset)&&c<=d.newscroll?g.push(b):d.newscroll<(e=b.offset)&&e<=d.oldscroll?g.push(b):void 0}),g.sort(function(a,b){return a.offset-b.offset}),f||g.reverse(),c.each(g,function(a,b){if(b.options.continuous||a===g.length-1)return b.trigger([e])})}),this.oldscroll={x:a.horizontal.newscroll,y:a.vertical.newscroll}},a.prototype.refresh=function(){var a,b,d,e=this;return d=c.iswindow(this.element),b=this.$element.offset(),this.doscroll(),a={horizontal:{contextoffset:d?0:b.left,contextscroll:d?0:this.oldscroll.x,contextdimension:this.$element.width(),oldscroll:this.oldscroll.x,forward:"right",backward:"left",offsetprop:"left"},vertical:{contextoffset:d?0:b.top,contextscroll:d?0:this.oldscroll.y,contextdimension:d?c[t]("viewportheight"):this.$element.height(),oldscroll:this.oldscroll.y,forward:"down",backward:"up",offsetprop:"top"}},c.each(a,function(a,b){return c.each(e.waypoints[a],function(a,d){var e,f,g,h,i;if(e=d.options.offset,g=d.offset,f=c.iswindow(d.element)?0:d.$element.offset()[b.offsetprop],c.isfunction(e)?e=e.apply(d.element):"string"==typeof e&&(e=parsefloat(e),d.options.offset.indexof("%")>-1&&(e=math.ceil(b.contextdimension*e/100))),d.offset=f-b.contextoffset+b.contextscroll-e,(!d.options.onlyonscroll||null==g)&&d.enabled)return null!==g&&g<(h=b.oldscroll)&&h<=d.offset?d.trigger([b.backward]):null!==g&&g>(i=b.oldscroll)&&i>=d.offset?d.trigger([b.forward]):null===g&&b.oldscroll>=d.offset?d.trigger([b.forward]):void 0})})},a.prototype.checkempty=function(){if(c.isemptyobject(this.waypoints.horizontal)&&c.isemptyobject(this.waypoints.vertical))return this.$element.unbind([o,p].join(" ")),delete k[this.id]},a}(),g=function(){function a(a,b,d){var e,f;d=c.extend({},c.fn[s].defaults,d),"bottom-in-view"===d.offset&&(d.offset=function(){var a;return a=c[t]("viewportheight"),c.iswindow(b.element)||(a=b.$element.height()),a-c(this).outerheight()}),this.$element=a,this.element=a[0],this.axis=d.horizontal?"horizontal":"vertical",this.callback=d.handler,this.context=b,this.enabled=d.enabled,this.id="waypoints"+q++,this.offset=null,this.options=d,b.waypoints[this.axis][this.id]=this,h[this.axis][this.id]=this,e=null!=(f=a.data(r))?f:[],e.push(this.id),a.data(r,e)}return a.prototype.trigger=function(a){if(this.enabled)return null!=this.callback&&this.callback.apply(this.element,a),this.options.triggeronce?this.destroy():void 0},a.prototype.disable=function(){return this.enabled=!1},a.prototype.enable=function(){return this.context.refresh(),this.enabled=!0},a.prototype.destroy=function(){return delete h[this.axis][this.id],delete this.context.waypoints[this.axis][this.id],this.context.checkempty()},a.getwaypointsbyelement=function(a){var b,d;return(d=c(a).data(r))?(b=c.extend({},h.horizontal,h.vertical),c.map(d,function(a){return b[a]})):[]},a}(),n={init:function(a,b){return null==b&&(b={}),null==b.handler&&(b.handler=a),this.each(function(){var a,d,e,h;return a=c(this),e=null!=(h=b.context)?h:c.fn[s].defaults.context,c.iswindow(e)||(e=a.closest(e)),e=c(e),d=k[e.data(j)],d||(d=new f(e)),new g(a,d,b)}),c[t]("refresh"),this},disable:function(){return n._invoke(this,"disable")},enable:function(){return n._invoke(this,"enable")},destroy:function(){return n._invoke(this,"destroy")},prev:function(a,b){return n._traverse.call(this,a,b,function(a,b,c){if(b>0)return a.push(c[b-1])})},next:function(a,b){return n._traverse.call(this,a,b,function(a,b,c){if(ba.oldscroll.y})},left:function(a){return null==a&&(a=d),m._filter(a,"horizontal",function(a,b){return b.offset<=a.oldscroll.x})},right:function(a){return null==a&&(a=d),m._filter(a,"horizontal",function(a,b){return b.offset>a.oldscroll.x})},enable:function(){return m._invoke("enable")},disable:function(){return m._invoke("disable")},destroy:function(){return m._invoke("destroy")},extendfn:function(a,b){return n[a]=b},_invoke:function(a){var b;return b=c.extend({},h.vertical,h.horizontal),c.each(b,function(b,c){return c[a](),!0})},_filter:function(a,b,d){var e,f;return(e=k[c(a).data(j)])?(f=[],c.each(e.waypoints[b],function(a,b){if(d(e,b))return f.push(b)}),f.sort(function(a,b){return a.offset-b.offset}),c.map(f,function(a){return a.element})):[]}},c[t]=function(){var a,c;return c=arguments[0],a=2<=arguments.length?b.call(arguments,1):[],m[c]?m[c].apply(null,a):m.aggregate.call(null,c)},c[t].settings={resizethrottle:100,scrollthrottle:30},e.load(function(){return c[t]("refresh")})})}).call(this);