(function(n){var o={topSpacing:0,bottomSpacing:0,className:"is-sticky",wrapperClassName:"sticky-wrapper",center:!1,getWidthFrom:""},i=n(window),s=n(document),r=[],f=i.height(),t=function(){for(var u,e=i.scrollTop(),h=s.height(),c=h-f,l=e>c?c-e:0,o=0;o<r.length;o++){var t=r[o],a=t.stickyWrapper.offset().top,v=a-t.topSpacing-l;e<=v?t.currentTop!==null&&(t.stickyElement.css("position","").css("top",""),t.stickyElement.parent().removeClass(t.className),t.currentTop=null):(u=h-t.stickyElement.outerHeight()-t.topSpacing-t.bottomSpacing-e-l,u=u<0?u+t.topSpacing:t.topSpacing,t.currentTop!=u&&(t.stickyElement.css("position","fixed").css("z-index","999999").css("top",u),typeof t.getWidthFrom!="undefined"&&t.stickyElement.css("width",n(t.getWidthFrom).width()),t.stickyElement.parent().addClass(t.className),t.currentTop=u))}},e=function(){f=i.height()},u={init:function(t){var i=n.extend(o,t);return this.each(function(){var t=n(this),f=t.attr("id"),e=n("<div><\/div>").attr("id",f+"-sticky-wrapper").addClass(i.wrapperClassName),u;t.wrapAll(e);i.center&&t.parent().css({width:t.outerWidth(),marginLeft:"auto",marginRight:"auto"});t.css("float")=="right"&&t.css({float:"none"}).parent().css({float:"right"});u=t.parent();u.css("height",t.outerHeight());r.push({topSpacing:i.topSpacing,bottomSpacing:i.bottomSpacing,stickyElement:t,currentTop:null,stickyWrapper:u,className:i.className,getWidthFrom:i.getWidthFrom})})},update:t};window.addEventListener?(window.addEventListener("scroll",t,!1),window.addEventListener("resize",e,!1)):window.attachEvent&&(window.attachEvent("onscroll",t),window.attachEvent("onresize",e));n.fn.sticky=function(t){if(u[t])return u[t].apply(this,Array.prototype.slice.call(arguments,1));if(typeof t!="object"&&t)n.error("Method "+t+" does not exist on jQuery.sticky");else return u.init.apply(this,arguments)};n(function(){setTimeout(t,0)})})(jQuery)