/* * summary: lyz.delayloading 1.0 */ jquery.fn.extend({delayloading:function(a){function g(d){var b,c;if(a.container===undefined||a.container===window){b=$(window).scrolltop();c=$(window).height()+$(window).scrolltop()}else{b=$(a.container).offset().top;c=$(a.container).offset().top+$(a.container).height()}return d.offset().top+d.height()+a.beforehand>=b&&c>=d.offset().top-a.beforehand}function h(d){var b,c;if(a.container===undefined||a.container===window){b=$(window).scrollleft();c=$(window).width()+$(window).scrollleft()}else{b=$(a.container).offset().left; c=$(a.container).offset().left+$(a.container).width()}return d.offset().left+d.width()+a.beforehand>=b&&c>=d.offset().left-a.beforehand}function f(){e.filter("img["+a.imgsrcattr+"]").each(function(d,b){if($(b).attr(a.imgsrcattr)!==undefined&&$(b).attr(a.imgsrcattr)!==null&&$(b).attr(a.imgsrcattr)!==""&&g($(b))&&h($(b))){var c=new image;c.onload=function(){$(b).attr("src",c.src);a.duration!==0&&$(b).hide().fadein(a.duration);$(b).removeattr(a.imgsrcattr);a.success($(b))};c.onerror=function(){$(b).attr("src", a.errorimg);$(b).removeattr(a.imgsrcattr);a.error($(b))};c.src=$(b).attr(a.imgsrcattr)}})}a=jquery.extend({defaultimg:"",errorimg:"",imgsrcattr:"originalsrc",beforehand:0,event:"scroll",duration:"normal",container:window,success:function(){},error:function(){}},a||{});if(a.errorimg===undefined||a.errorimg===null||a.errorimg==="")a.errorimg=a.defaultimg;var e=$(this);if(e.attr("src")===undefined||e.attr("src")===null||e.attr("src")==="")e.attr("src",a.defaultimg);f();$(a.container).bind(a.event,function(){f()})}});