!function(a,b,c,d){function e(b,c){this.element=b,this.options=a.extend({},g,c),this._defaults=g,this._name=f,this.init()}var f="imgSmartLoad",g={load_all_images_on_first_scroll:!1,attribute:["data-src","data-srcset"],excludeImg:"",threshold:200,fadeIn_options:{duration:400},delaySmartLoadEvent:0};e.prototype.init=function(){var c=this,d=a("img["+this.options.attribute[0]+"]:not("+this.options.excludeImg.join()+")",this.element);this.increment=1,this.timer=0,d.bind("load_img",{},function(){c._load_img(this)}),a(b).scroll(function(a){c._better_scroll_event_handler(d,a)}),a(b).resize(function(a){c._maybe_trigger_load(d,a)}),this._maybe_trigger_load(d)},e.prototype._better_scroll_event_handler=function(a,c){var d=this;0!==this.timer&&(this.increment++,b.clearTimeout(this.timer)),this.timer=b.setTimeout(function(){d._maybe_trigger_load(a,c)},d.increment>5?50:0)},e.prototype._maybe_trigger_load=function(b,c){var d=this;_visible_list=b.filter(function(a,b){return d._is_visible(b,c)}),_visible_list.map(function(b,c){a(c).trigger("load_img")})},e.prototype._is_visible=function(c,d){var e=a(c),f=a(b).scrollTop(),g=f+a(b).height(),h=e.offset().top,i=h+e.height(),j=this.options.threshold;return d&&"scroll"==d.type&&this.options.load_all_images_on_first_scroll?!0:i>=f-j&&g+j>=h},e.prototype._load_img=function(b){var c=a(b),d=c.attr(this.options.attribute[0]),e=c.attr(this.options.attribute[1]),f=this;c.parent().addClass("smart-loading"),c.unbind("load_img").hide().removeAttr(this.options.attribute.join(" ")).attr("srcset",e).attr("src",d).load(function(){if(c.hasClass("tc-smart-loaded")||c.fadeIn(f.options.fadeIn_options).addClass("tc-smart-loaded"),"undefined"!=typeof c.attr("data-tcjp-recalc-dims")&&!1!==c.attr("data-tcjp-recalc-dims")){var a=c.originalWidth();if(_height=c.originalHeight(),2!=_.size(_.filter([a,_height],function(a){return _.isNumber(parseInt(a,10))&&a>1})))return;c.removeAttr("data-tcjp-recalc-dims scale"),c.attr("width",a),c.attr("height",_height)}c.trigger("smartload")}),c[0].complete&&c.load(),c.parent().removeClass("smart-loading")},a.fn[f]=function(b){return this.each(function(){a.data(this,"plugin_"+f)||a.data(this,"plugin_"+f,new e(this,b))})}}(jQuery,window,document);