!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}(function(d){function t(){for(var t=u.scrollTop(),e=h.height(),i=e-y,r=i<t?i-t:0,n=0,s=g.length;n<s;n++){var o=g[n],c=o.stickyWrapper.offset().top-o.topSpacing-r;if(o.stickyWrapper.css("height",o.stickyElement.outerHeight()),t<=c)null!==o.currentTop&&(o.stickyElement.css({width:"",position:"",top:""}),o.stickyElement.parent().removeClass(o.className),o.stickyElement.trigger("sticky-end",[o]),o.currentTop=null);else{var p,a=e-o.stickyElement.outerHeight()-o.topSpacing-o.bottomSpacing-t-r;if(a<0?a+=o.topSpacing:a=o.topSpacing,o.currentTop!==a)o.getWidthFrom?p=d(o.getWidthFrom).width()||null:o.widthFromWrapper&&(p=o.stickyWrapper.width()),null==p&&(p=o.stickyElement.width()),o.stickyElement.css("width",p).css("position","fixed").css("top",a),o.stickyElement.parent().addClass(o.className),null===o.currentTop?o.stickyElement.trigger("sticky-start",[o]):o.stickyElement.trigger("sticky-update",[o]),o.currentTop===o.topSpacing&&o.currentTop>a||null===o.currentTop&&a<o.topSpacing?o.stickyElement.trigger("sticky-bottom-reached",[o]):null!==o.currentTop&&a===o.topSpacing&&o.currentTop<a&&o.stickyElement.trigger("sticky-bottom-unreached",[o]),o.currentTop=a;var l=o.stickyWrapper.parent();o.stickyElement.offset().top+o.stickyElement.outerHeight()>=l.offset().top+l.outerHeight()&&o.stickyElement.offset().top<=o.topSpacing?o.stickyElement.css("position","absolute").css("top","").css("bottom",0):o.stickyElement.css("position","fixed").css("top",a).css("bottom","")}}}function e(){y=u.height();for(var t=0,e=g.length;t<e;t++){var i=g[t],r=null;i.getWidthFrom?i.responsiveWidth&&(r=d(i.getWidthFrom).width()):i.widthFromWrapper&&(r=i.stickyWrapper.width()),null!=r&&i.stickyElement.css("width",r)}}var i=Array.prototype.slice,r=Array.prototype.splice,o={topSpacing:0,bottomSpacing:0,className:"is-sticky",wrapperClassName:"sticky-wrapper",center:!1,getWidthFrom:"",widthFromWrapper:!0,responsiveWidth:!1},u=d(window),h=d(document),g=[],y=u.height(),c={init:function(t){var s=d.extend({},o,t);return this.each(function(){var t=d(this),e=t.attr("id"),i=e?e+"-"+o.wrapperClassName:o.wrapperClassName,r=d("<div></div>").attr("id",i).addClass(s.wrapperClassName);t.wrapAll(r);var n=t.parent();s.center&&n.css({width:t.outerWidth(),marginLeft:"auto",marginRight:"auto"}),"right"===t.css("float")&&t.css({float:"none"}).parent().css({float:"right"}),s.stickyElement=t,s.stickyWrapper=n,s.currentTop=null,g.push(s),c.setWrapperHeight(this),c.setupChangeListeners(this)})},setWrapperHeight:function(t){var e=d(t),i=e.parent();i&&i.css("height",e.outerHeight())},setupChangeListeners:function(e){window.MutationObserver?new window.MutationObserver(function(t){(t[0].addedNodes.length||t[0].removedNodes.length)&&c.setWrapperHeight(e)}).observe(e,{subtree:!0,childList:!0}):(e.addEventListener("DOMNodeInserted",function(){c.setWrapperHeight(e)},!1),e.addEventListener("DOMNodeRemoved",function(){c.setWrapperHeight(e)},!1))},update:t,unstick:function(t){return this.each(function(){for(var t=d(this),e=-1,i=g.length;0<i--;)g[i].stickyElement.get(0)===this&&(r.call(g,i,1),e=i);-1!==e&&(t.unwrap(),t.css({width:"",position:"",top:"",float:""}))})}};window.addEventListener?(window.addEventListener("scroll",t,!1),window.addEventListener("resize",e,!1)):window.attachEvent&&(window.attachEvent("onscroll",t),window.attachEvent("onresize",e)),d.fn.sticky=function(t){return c[t]?c[t].apply(this,i.call(arguments,1)):"object"!=typeof t&&t?void d.error("Method "+t+" does not exist on jQuery.sticky"):c.init.apply(this,arguments)},d.fn.unstick=function(t){return c[t]?c[t].apply(this,i.call(arguments,1)):"object"!=typeof t&&t?void d.error("Method "+t+" does not exist on jQuery.sticky"):c.unstick.apply(this,arguments)},d(function(){setTimeout(t,0)})});