!function(a,b,c,d){a.fn.sticky=function(c){var e,f=a(this),g=f.selector||"",h=(new Date).getTime(),i=[],j=arguments[0],k="string"==typeof j,l=[].slice.call(arguments,1);return f.each(function(){var f,m,n,o=a.extend(!0,{},a.fn.sticky.settings,c),p=o.className,q=o.namespace,r=o.error,s="."+q,t="module-"+q,u=a(this),v=a(b),w=u.offsetParent(),x=a(o.scrollContext),y=(u.selector||"",u.data(t)),z=b.requestAnimationFrame||b.mozRequestAnimationFrame||b.webkitRequestAnimationFrame||b.msRequestAnimationFrame||function(a){setTimeout(a,0)},A=this;n={initialize:function(){return u.is(":visible")||n.error(r.visible,u),f=o.context?a(o.context):w,0===f.size()?void n.error(r.invalidContext,o.context,u):(n.supports.sticky(),v.on("resize"+s,n.event.resize),x.on("scroll"+s,n.event.scroll),n.verbose("Initializing sticky",o,w),n.save.positions(),n.observeChanges(),void n.instantiate())},instantiate:function(){n.verbose("Storing instance of module",n),y=n,u.data(t,n)},destroy:function(){n.verbose("Destroying previous module"),n.reset(),v.off("resize",n.event.resize).off("scroll",n.event.scroll),u.removeData(t)},observeChanges:function(){var a=f[0];MutationObserver!==d&&(m=new MutationObserver(function(){clearTimeout(n.timer),n.timer=setTimeout(function(){n.verbose("DOM tree modified, updating sticky menu"),n.refresh()},200)}),m.observe(A,{childList:!0,subtree:!0}),m.observe(a,{childList:!0,subtree:!0}),n.debug("Setting up mutation observer",m))},event:{resize:function(){z(n.refresh)},scroll:function(){z(function(){n.stick(),a.proxy(o.onScroll,A)()})}},refresh:function(b){n.reset(),b&&(w=u.offsetParent()),n.save.positions(),a.proxy(o.onReposition,A)()},supports:{sticky:function(){{var b=a("
");b.get()}return b.addClass(p.supported),b.css("position").match("sticky")}},save:{scroll:function(a){n.lastScroll=a},positions:function(){var a={height:v.height()},b={margin:{top:parseInt(u.css("margin-top"),10),bottom:parseInt(u.css("margin-bottom"),10)},offset:u.offset(),width:u.outerWidth(),height:u.outerHeight()},c={offset:f.offset(),height:f.outerHeight()};n.cache={fits:b.heighta&&(b="up")),b},currentOffset:function(){return n.is.top()?parseInt(u.css("top"),10)||0:parseInt(u.css("bottom"),10)||0},offsetChange:function(a){return a=a||x.scrollTop(),n.lastScroll?Math.abs(a-n.lastScroll):0},newOffset:function(a){a=a||x.scrollTop();var b=n.get.currentOffset(),c=n.get.offsetChange(a);return Math.abs(b-c)}},set:{containerSize:function(){var a=w.get(0).tagName;"HTML"===a||"body"==a?(n.error(r.container,a,u),w=u.offsetParent()):(n.debug("Settings container size",n.cache.context.height),w.height(n.cache.context.height))},size:function(){0!==n.cache.element.height&&0!==n.cache.element.width&&u.css({width:n.cache.element.width,height:n.cache.element.height})}},is:{top:function(){return u.hasClass(p.top)},bottom:function(){return u.hasClass(p.bottom)},bound:function(){return u.hasClass(p.bound)},fixed:function(){return u.hasClass(p.fixed)}},stick:function(){var a=n.cache,b=a.fits,c=a.element,d=a.window,e=a.context,f=x.scrollTop(),g={top:f+o.offset,bottom:f+d.height+o.offset},h=n.get.direction(f),i=(n.get.currentOffset(),n.get.newOffset(f)),j=g.bottom>c.top+c.height,k=a.element.height+g.top;n.save.scroll(f),0!==c.height&&(n.is.fixed()?b?(n.is.top()&&(g.tope.bottom&&(n.debug("Top attached rail has reached bottom of container"),n.bindBottom())),n.is.bottom()&&(g.bottom-c.heighte.bottom&&(n.debug("Bottom attached rail has reached bottom of container"),n.bindBottom())),k>e.bottom&&n.bindBottom()):g.bottom>e.bottom?n.bindBottom():j?(n.is.top()&&"down"==h&&(n.debug("Stuck content at bottom edge"),i>=c.height-d.height?(u.css("top",""),n.stickBottom()):u.css("top",-i)),n.is.bottom()&&"up"==h&&(n.debug("Stuck content at top edge"),i>=c.height-d.height?(u.css("bottom",""),n.stickTop()):u.css("bottom",-i))):n.unfix():(g.top+c.height>e.bottom&&n.bindBottom(),b?n.is.bottom()?o.pushing?n.is.bound()&&g.bottom=c.top&&g.top0&&(console.groupCollapsed(b),console.table?console.table(i):a.each(i,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),i=[]}},invoke:function(b,c,f){var g,h,i,j=y;return c=c||l,f=A||f,"string"==typeof b&&j!==d&&(b=b.split(/[\. ]/),g=b.length-1,a.each(b,function(c,e){var f=c!=g?e+b[c+1].charAt(0).toUpperCase()+b[c+1].slice(1):b;if(a.isPlainObject(j[f])&&c!=g)j=j[f];else{if(j[f]!==d)return h=j[f],!1;if(!a.isPlainObject(j[e])||c==g)return j[e]!==d?(h=j[e],!1):!1;j=j[e]}})),a.isFunction(h)?i=h.apply(f,c):h!==d&&(i=h),a.isArray(e)?e.push(i):e!==d?e=[e,i]:i!==d&&(e=i),h}},k?(y===d&&n.initialize(),n.invoke(j)):(y!==d&&n.destroy(),n.initialize())}),e!==d?e:this},a.fn.sticky.settings={name:"Sticky",namespace:"sticky",verbose:!1,debug:!1,performance:!1,pushing:!1,context:!1,scrollContext:b,offset:0,onReposition:function(){},onScroll:function(){},onStick:function(){},onUnstick:function(){},onTop:function(){},onBottom:function(){},error:{container:"Sticky element must be inside a relative container",visible:"Element is hidden, you must call refresh after element becomes visible",method:"The method you called is not defined.",invalidContext:"Context specified does not exist"},className:{bound:"bound",fixed:"fixed",supported:"native",top:"top",bottom:"bottom"}}}(jQuery,window,document);