(function( $ ){
    /*
     * jQuery.appear
     * http://code.google.com/p/jquery-appear/
     *
     * Copyright (c) 2009 Michael Hixson
     * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
    */
    (function(a){a.fn.appear=function(d,b){var c=a.extend({data:undefined,one:true},b);return this.each(function(){var g=a(this);g.appeared=false;if(!d){g.trigger("appear",c.data);return}var f=a(window);var e=function(){if(!g.is(":visible")){g.appeared=false;return}var k=f.scrollLeft();var j=f.scrollTop();var l=g.offset();var i=l.left;var m=l.top;if(m+g.height()>=j&&m<=j+f.height()&&i+g.width()>=k&&i<=k+f.width()){if(!g.appeared){g.trigger("appear",c.data)}}else{g.appeared=false}};var h=function(){g.appeared=true;if(c.one){f.unbind("scroll",e);var j=a.inArray(e,a.fn.appear.checks);if(j>=0){a.fn.appear.checks.splice(j,1)}}d.apply(this,arguments)};if(c.one){g.one("appear",c.data,h)}else{g.bind("appear",c.data,h)}f.scroll(e);a.fn.appear.checks.push(e);(e)()})};a.extend(a.fn.appear,{checks:[],timeout:null,checkAll:function(){var b=a.fn.appear.checks.length;if(b>0){while(b--){(a.fn.appear.checks[b])()}}},run:function(){if(a.fn.appear.timeout){clearTimeout(a.fn.appear.timeout)}a.fn.appear.timeout=setTimeout(a.fn.appear.checkAll,20)}});a.each(["append","prepend","after","before","attr","removeAttr","addClass","removeClass","toggleClass","remove","css","show","hide"],function(c,d){var b=a.fn[d];if(b){a.fn[d]=function(){var e=b.apply(this,arguments);a.fn.appear.run();return e}}})})(jQuery);

        
    /* Modern Image Lazyloader plugin
     *
     * Copyright (c) 2011 Scott Leonard
     * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
     *
     * Use: $('#carousel').lazyloader('li div.photo img'); 
     * Note: img_selector argument is optional, but allows the plugin to traverse more efficiently when used properly
     */
     
    $.fn.lazyloader = function(img_selector) {
        var imgs = (img_selector) ? img_selector : 'img';
        this.appear(function(){
            var lazyloaded;
            $(this).find( imgs +'[data-src]' ).each(function(){
                lazyloaded = $(this);
                lazyloaded.attr('src', lazyloaded.attr('data-src') );
            });
        });
    };
})( jQuery );
