/*!
 * LazyWrite - deferred document.write implementation
 * Version: 1.01 build 20110916
 * Website: http://github.com/xfsn/LazyWrite
 *
 * Copyright (c) 2011 Shen Junru
 * Released under the MIT License.
 */
(function(P,d,k,K,p){var G=1,a=k?"onreadystatechange":"onload",q=/^\s*<!--/,r="lazy-holder-",R="text/lazyjs",m="",O="",g=/<([a-z]+)(?:\s+[^>\/\s]+(?:=['"].*['"])?)*\s*>\s*$/i,U=function(W){O=((W=W.match(g))||[])[1]||O;return W},x=function(W){return !O||new RegExp("</"+O+">","i").test(W)},b=P.onerror,h=d.write,t=d.writeln,c=h.apply?function(){h.apply(d,arguments)}:h,e=d.createDocumentFragment(),Q=d.createElement("div"),E=p,l=p,z=p,y=p,I=[],f=[],o=p,v=false,C=true,n=[].join,A=function(W){o.ex.push(W)},u=function(X,W){return X.appendChild(W)},H=function(W){return W.parentNode?W.parentNode.removeChild(W):W},V=function(X,W){return X.parentNode.replaceChild(W,X)&&W},L=function(){return d.createElement("span")},B=function w(X){var W=d.createElement("script");W.type=X.type;if(X.src){W.src=X.src}else{W.text=X.text}return W},M=function(X,W){clearTimeout(W._tid);W.done=true;W[a]=W.onerror=null;H(X);if(l===W){l=p;F()}},J=function(X,W){if(W.src){W[a]=function(){var Z=k&&W.readyState;if(!W.done&&(!Z||/complete|loaded/.test(Z))){if(Z==="loaded"&&!W.loaded){W.loaded=true;setTimeout(arguments.callee)}else{M(X,W)}}};W.onerror=function(Z){W._error=Z;A(Z);M(X,W)};l=W;setTimeout(function(){u(X,W)});W._tid=setTimeout(function(){A("unknow");M(X,W)},60500)}else{try{K(W.text.replace(q,""))}catch(Y){A(Y)}H(X)}},j=function(W){if(W){if(!l){E=W.holder}J(W.holder,W.script=B(W.script));return !W.script.src}},s=function(W){while((W=j(f.shift()))){}return W!==false&&!l},S=function(aa,ab,Y){if(k){Q.innerHTML="<img />"+ab;H(Q.firstChild)}else{Q.innerHTML=ab}var X=[],W=Q.getElementsByTagName("script"),ac,Z;while(W[0]){X.push({script:W[0],holder:V(W[0],element=L())})}while(Q.firstChild){e.appendChild(Q.firstChild)}if(z===aa){f=(Z=f.n.slice(f.l-f.length).concat(X)).concat(ac=f.o);f.n=Z;f.o=ac;y.parentNode.insertBefore(e,y)}else{f=X.concat(ac=f);f.n=X;f.o=ac;y=e.appendChild(y||L());Y?aa.parentNode.insertBefore(e,aa.nextSibling):V(aa,e)}f.l=f.length;z=aa;if(C&&X.length){C=s()}return C},D=function(W){return W&&W.html&&S(d.getElementById(W.id),W.html)},T=function(){while(D(o=I.shift())){}if(C&&!I.length){y&&H(y);e=Q=E=l=z=y=p;d.write=h;d.writeln=t}},F=function(){C=true;if(s()){try{o.cb&&o.cb(o.ex)}catch(W){A(W)}T()}},i=function(X,W,Y){if(typeof Y!=="function"){Y=p}if(typeof W==="function"){Y=W,W=p}W||c('<span id="'+(W=r+G++)+'"></span>');I.push({id:W,html:X,cb:Y,ex:[]})},N=function(){var X=n.call(arguments,"");if(X){if(U(X)){return m+=X}else{if(x(X)){X=m+X,O=m="";if(v){try{S(E,X,true)}catch(W){A(W)}}else{i(X)}}else{m+=X}}}};(P.LazyWrite={write:c,render:i,prepare:function(){d.writeln=d.write=N},process:function(){if(v){return}v=true;T()},findScripts:function(ab){ab=ab||R;var ac=d.getElementsByTagName("script"),aa,Y,X,Z=0,W=[];if(ac){for(X=ac.length;Z<X;Z++){W[Z]=ac[Z]}for(Z=0;Z<X;Z++){if(ab===W[Z].type){V(W[Z],aa=L());if(Y=W[Z].getAttribute("require")){u(Q,d.createElement("script")).src=Y}u(Q,W[Z]);i(Q.innerHTML,aa.id=r+G++);Q.innerHTML=""}}}}}).prepare();P.onerror=function(X,W){if(l&&(W===l.src)&&!l._error){A(X)}b&&b.apply(P,arguments)}})(window,document,/*@cc_on!@*/!1,function(){eval.apply(window,arguments)});

