(function (c) { c.fn.lazyload = function (d) { var f = { threshold: 0, autoLoad: true, autoLoadTime: 100, event: "scroll", effect: "show", attr: "_src", autoCount: 0, container: window }; if (d) { c.extend(f, d) } if (this.length < 1) { return } var g = this; var e = null; var b = null; scrollFn = function (i) { f.autoCount = 0; if (i.preventDefault) { i.preventDefault() } i.returnValue = false; var h = 0; g.each(function () { if (c.belowthefold(this, f)) { c(this).trigger("appear") } }); if (b == null) { b = new Date().getTime() } else { if (new Date().getTime() - b < 50) { return } b = new Date().getTime() } if (e) { clearTimeout(e); e = null } autoLoadFn(f.autoLoad) }; autoLoadFn = function (i) { if (i == undefined || i != true) { i = false } var h = c.grep(g, function (j) { return !j.loaded }); g = c(h); if (g.length > 0) { g.each(function () { if (c.autoVertical(this, f)) { c(this).trigger("appear") } }); if (i) { f.autoCount++; e = setTimeout("autoLoadFn(" + f.autoLoad + ")", f.autoLoadTime) } } else { c(f.container).unbind("scroll", scrollFn) } }; if ("scroll" == f.event) { c(f.container).scroll(scrollFn) } this.each(function () { var h = this; c(h).one("appear", function () { if (!this.loaded) { c("").bind("load", function () { c(h).hide().attr("src", c(h).attr("_src"))[f.effect](f.effectspeed); h.loaded = true }).attr("src", c(h).attr("_src")) } }); if ("scroll" != f.event) { c(h).bind(f.event, function (i) { if (!h.loaded) { c(h).trigger("appear") } }) } }); autoLoadFn(f.autoLoad) }; var a = true; c.autoVertical = function (f, h) { var j; var e; if (h.container === undefined || h.container === window) { j = c(window).scrollTop(); e = c(window).height() } else { j = c(h.container).offset().top; e = c(h.container).height() } var i = h.autoCount; if (i < 1) { i = 1 } var g = j + (e * (i - 1) + e); var d = j - (e * (i - 1) + e); if (d < 0) { d = 0 } var b = c(f).offset().top; return (b <= g + h.threshold) && (b >= d - h.threshold) }; c.autoHorizontal = function (f, g) { var e; var b; if (g.container === undefined || g.container === window) { e = c(window).scrollLeft(); b = c(window).width() } else { e = c(g.container).offset().left; b = c(g.container).width() } var j = g.autoCount; if (j < 1) { j = 1 } var h = e + (b * (j - 1) + b); var d = e - (b * (j - 1) + b); var i = c(f).offset().left; return (i <= h + g.threshold) && (i >= d - g.threshold) }; c.belowthefold = function (f, g) { var h; var e; if (g.container === undefined || g.container === window) { h = c(window).scrollTop(); e = c(window).height() } else { h = c(g.container).offset().top; e = c(g.container).height() } var d = h + e; var b = c(f).offset().top; return (b <= d + g.threshold) && (b >= h - g.threshold) }; c.rightoffold = function (f, g) { var e; var b; if (g.container === undefined || g.container === window) { e = c(window).scrollLeft(); b = c(window).width() } else { e = c(g.container).offset().left; b = c(g.container).width() } var d = e + b; var h = c(f).offset().left; return (h <= d + g.threshold) && (h >= e - g.threshold) } })(jQuery); $(function () { $("img[_src]").lazyload({ placeholder: "/images/grey.gif", threshold: 100, autoLoadTime: 200, effect: "fadeIn" }) });