/*
 * Lazy Loader 0.9.2 - jQuery plugin for lazy loading images
 *
 * Copyright(c) 2006-2011 Xenophy.CO.,LTD All rights Reserved.
 * http://www.xenophy.com
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 */
(function(a){a.fn.lazyloader=function(c){var b={threshold:0,failurelimit:0,event:"scroll",effect:"show",imgSrcAttr:"original",container:window,beforeLoadCls:"loading"},d=this;if(c){a.extend(b,c)}if("scroll"==b.event){a(b.container).bind("scroll",function(h){var f=0,g;d.each(function(){var e=this;if(a.abovethetop(e,b)||a.leftofbegin(e,b)){}else{if(!a.belowthefold(e,b)&&!a.rightoffold(e,b)){a(e).trigger("appear")}else{if(f++>b.failurelimit){return false}}}});g=a.grep(d,function(e){return !e.loaded});d=a(g)})}d.each(function(){var e=this;a(e).addClass(b.beforeLoadCls);if(undefined==a(e).attr(b.imgSrcAttr)){a(e).attr(b.imgSrcAttr,a(e).attr("src"))}if("scroll"!=b.event||undefined==a(e).attr("src")||(a.abovethetop(e,b)||a.leftofbegin(e,b)||a.belowthefold(e,b)||a.rightoffold(e,b))){e.loaded=false}else{e.loaded=true}a(e).one("appear",function(){a("<img />").bind("load",function(){a(e).hide().removeClass(b.beforeLoadCls).attr("src",a(e).attr(b.imgSrcAttr))[b.effect](b.effectspeed);e.loaded=true}).attr("src",a(e).attr(b.imgSrcAttr)).attr(b.imgSrcAttr,"")});if("scroll"!=b.event){a(e).bind(b.event,function(f){if(!e.loaded){a(e).trigger("appear")}})}});a(b.container).trigger(b.event);return this};a.belowthefold=function(d,c){var b;if(c.container===undefined||c.container===window){b=a(window).height()+a(window).scrollTop()}else{b=a(c.container).offset().top+a(c.container).height()}return b<=a(d).offset().top-c.threshold};a.rightoffold=function(d,c){var b;if(c.container===undefined||c.container===window){b=a(window).width()+a(window).scrollLeft()}else{b=a(c.container).offset().left+a(c.container).width()}return b<=a(d).offset().left-c.threshold};a.abovethetop=function(d,c){var b;if(c.container===undefined||c.container===window){b=a(window).scrollTop()}else{b=a(c.container).offset().top}return b>=a(d).offset().top+c.threshold+a(d).height()};a.leftofbegin=function(d,c){var b;if(c.container===undefined||c.container===window){b=a(window).scrollLeft()}else{b=a(c.container).offset().left}return b>=a(d).offset().left+c.threshold+a(d).width()};a.extend(a.expr[":"],{"below-the-fold":"$.belowthefold(a, {threshold : 0, container: window})","above-the-fold":"!$.belowthefold(a, {threshold : 0, container: window})","right-of-fold":"$.rightoffold(a, {threshold : 0, container: window})","left-of-fold":"!$.rightoffold(a, {threshold : 0, container: window})"})})(jQuery);
