(function(e){e.fn.pin=function(a){var g=0,h=[],n=!1,k=e(window),a=a||{},m=function(){for(var i=0,d=h.length;i"); var g=e.extend({top:0,bottom:0},a.padding||{});b.data("pin",{pad:g,from:(a.containerSelector?j.top:f.top)-g.top,to:j.top+c.height()-b.outerHeight()-g.bottom,end:j.top+c.height(),parentTop:l.top});b.css({width:b.outerWidth()});b.parent().css("height",b.outerHeight())}}},o=function(){if(!n){g=k.scrollTop();for(var i=[],d=0,b=h.length;df.end?c.css("position",""):jg?("fixed"!=c.css("position")&&c.css({left:c.offset().left, top:f.pad.top}).css("position","fixed"),a.activeClass&&c.addClass(a.activeClass)):g>=l?(c.css({left:"",top:l-f.parentTop+f.pad.top}).css("position","absolute"),a.activeClass&&c.addClass(a.activeClass)):(c.css({position:"",top:"",left:""}),a.activeClass&&c.removeClass(a.activeClass))}}h=i}},p=function(){m();o()};this.each(function(){var a=e(this),d=e(this).data("pin")||{};if(!d||!d.update)h.push(a),e("img",this).one("load",m),d.update=p,e(this).data("pin",d)});k.scroll(o);k.resize(function(){m()}); m();k.load(p);return this}})(jQuery);