!function(e){e.fn.lazyload=function(t){var i={threshold:0,failure_limit:0,event:"scroll",effect:"show",container:window,skip_invisible:!0};t&&(null!==t.failurelimit&&(t.failure_limit=t.failurelimit,delete t.failurelimit),e.extend(i,t));var n=this;return 0==i.event.indexOf("scroll")&&e(i.container).bind(i.event,function(t){var o=0;n.each(function(){if(!i.skip_invisible||e(this).is(":visible"))if(e.abovethetop(this,i)||e.leftofbegin(this,i));else if(e.belowthefold(this,i)||e.rightoffold(this,i)){if(++o>i.failure_limit)return!1}else e(this).trigger("appear")});var r=e.grep(n,function(e){return!e.loaded});n=e(r)}),this.each(function(){var t=this;t.loaded=!1,e(t).one("appear",function(){this.loaded||e("").bind("load",function(){e(t).hide().attr("src",e(t).data("original"))[i.effect](i.effectspeed),t.loaded=!0}).attr("src",e(t).data("original"))}),0!=i.event.indexOf("scroll")&&e(t).bind(i.event,function(i){t.loaded||e(t).trigger("appear")})}),e(window).bind("resize",function(t){e(i.container).trigger(i.event)}),e(i.container).trigger(i.event),this},e.belowthefold=function(t,i){if(void 0===i.container||i.container===window)var n=e(window).height()+e(window).scrollTop();else var n=e(i.container).offset().top+e(i.container).height();return n<=e(t).offset().top-i.threshold},e.rightoffold=function(t,i){if(void 0===i.container||i.container===window)var n=e(window).width()+e(window).scrollLeft();else var n=e(i.container).offset().left+e(i.container).width();return n<=e(t).offset().left-i.threshold},e.abovethetop=function(t,i){if(void 0===i.container||i.container===window)var n=e(window).scrollTop();else var n=e(i.container).offset().top;return n>=e(t).offset().top+i.threshold+e(t).height()},e.leftofbegin=function(t,i){if(void 0===i.container||i.container===window)var n=e(window).scrollLeft();else var n=e(i.container).offset().left;return n>=e(t).offset().left+i.threshold+e(t).width()},e.extend(e.expr[":"],{"below-the-fold":function(t){return e.belowthefold(t,{threshold:0,container:window})},"above-the-fold":function(t){return!e.belowthefold(t,{threshold:0,container:window})},"right-of-fold":function(t){return e.rightoffold(t,{threshold:0,container:window})},"left-of-fold":function(t){return!e.rightoffold(t,{threshold:0,container:window})}})}(jQuery);