// jQuery.autoIMG.js v0.3 - Tang Bin - http://planeArt.cn/ - MIT Licensed
(function(B){var _="images/loading.png",C="images/error.png",A="maxWidth"in document.documentElement.style,$=!-[1,]&&!("prototype"in Image)&&A;new Image().src=_;B.fn.autoIMG=function(){var B=this,$=B.width();return B.find("img").each(function(H,E){if(A)return E.style.maxWidth=$+"px";var D=E.getAttribute("data-src")||E.src,B=E.nextSibling,G=E.parentNode,F=new Image();E.style.display="none";E.removeAttribute("src");E.parentNode.removeChild(E);F.src=_;B?B.insertBefore(F):G.appendChild(F);imgReady(D,function(A,_){if(A>$){_=$/A*_,A=$;F.parentNode.removeChild(F);E.style.display="";E.style.width=A+"px";E.style.height=_+"px";E.setAttribute("src",D);B?B.insertBefore(E):G.appendChild(E)}},function(){F.src=C;F.title="Image load error!"})})};$&&(function(A,$,_){_=$.createElement("style");$.getElementsByTagName("head")[0].appendChild(_);_.styleSheet&&(_.styleSheet.cssText+=A)||_.appendChild($.createTextNode(A))})("img {-ms-interpolation-mode:bicubic}",document);(function(){var B=[],A=null,_=function(){var _=0;for(;_<B.length;_++)B[_].end?B.splice(_--,1):B[_]();!B.length&&$()},$=function(){clearInterval(A);A=null};this.imgReady=function(G,L,$){var C,P,D,J,N,I,F,O=1024,M=document,K=M.body||M.getElementsByTagName("head")[0],E=new Image();E.src=G;if(!L)return E;if(E.complete)return L(E.width,E.height);F=M.createElement("div");F.style.cssText="visibility:hidden;position:absolute;left:0;top:0;width:1px;height:1px;overflow:hidden";F.appendChild(E);K.appendChild(F);D=E.offsetWidth;J=E.offsetHeight;E.onload=function(){P();L(E.width,E.height)};E.onerror=function(){P();$&&$()};C=function(){N=E.offsetWidth;I=E.offsetHeight;if(N!==D||I!==J||N*I>O){P();L(N,I)}};C.url=G;P=function(){C.end=true;E.onload=E.onerror=null;F.innerHTML="";F.parentNode.removeChild(F)};!C.end&&C();for(var H=0;H<B.length;H++)if(B[H].url===G)return;if(!C.end){B.push(C);if(!A)A=setInterval(_,150)}}})()})(jQuery)
