(function($){$.fn.lazyload=function(options){var elements=this;$(window).bind('scroll',function(event){var counter=0;elements.each(function(){if($.abovethetop(this)){}else if(!$.belowthefold(this)){$(this).trigger('appear')}else{if(counter++>0){return false}}});var temp=$.grep(elements,function(element){return!element.loaded});elements=$(temp)});this.each(function(){var self=this;var placeholder='/thumbnail.gif';if(undefined==$(self).attr('original')){$(self).attr('original',$(self).attr('src'))}if(undefined==$(self).attr('src')||placeholder==$(self).attr('src')||($.abovethetop(self)||$.belowthefold(self))){$(self).attr('src',placeholder);self.loaded=false}else{self.loaded=true}$(self).one('appear',function(){if(!this.loaded){$('<img />').bind('load',function(){$(self).hide().attr('src',$(self).attr('original'))['show']();self.loaded=true}).attr('src',$(self).attr('original'))}})});$(window).trigger('scroll');return this};$.belowthefold=function(element){if(window===undefined||window===window){var fold=$(window).height()+$(window).scrollTop()}else{var fold=$(window).offset().top+$(window).height()}return fold<=$(element).offset().top};$.abovethetop=function(element){if(window===undefined||window===window){var fold=$(window).scrollTop()}else{var fold=$(window).offset().top}return fold>=$(element).offset().top+$(element).height()};$.extend($.expr[':'],{'below-the-fold':'$.belowthefold(a, {threshold : 0, container: window})','above-the-fold':'!$.belowthefold(a, {threshold : 0, container: window})'})})(jQuery);
