(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" }) });