(function(){var C=document.getElementsByTagName("head")[0],D="http://static.zemanta.com/",E={"zem-script":null,"more-related":D+"readside/morerelated.js"},H=null,F=null,G=function(){return !(window.Zemanta||window.parent.Zemanta||document.designMode==="on"||(document.getElementsByTagName("body")[0]&&document.getElementsByTagName("body")[0].contentEditable==="true"))},B=function(){return(document.getElementById&&document.getElementsByTagName&&arguments.callee&&[].push)};if(!G()||!B()){return }window.ZemantaReadside=window.ZemantaReadside||{isValid:G,loaded:{},scripts:{queue:[],done:[]},jQuery:null,debug:false,log:function(){if(this.debug){if(typeof console!=="undefined"&&console.log){console.log.apply(console,arguments)}else{alert(arguments[0])}}},getTypes:function(I){return(I.className+" "+I.parentNode.className).split(" ")},findScripts:function(O){var I=document.getElementsByTagName("script"),L=null,N=I.length-1,K=0,J=0,M=[],P=[];for(;N>=0;N-=1){L=I[N];if(!L){continue}if(L.src.indexOf(D)===0){M=this.getTypes(L);J=M.length;for(;K<J;K+=1){if(M[K]===O){P.push(L);break}}}}return P},findRID:function(I){var J=F(I).parents(".zemanta-pixie"),K=null;if(J.size()>0){K=J.find(".zemanta-pixie-img").attr("src");K=K&&K.split("x-id=")[1]}else{F(I).prevAll().each(function(){var M=F(this),L=null;if(M.hasClass("zemanta-pixie-img")){L=M.attr("src");K=L&&L.split("x-id=")[1]}else{if(M.hasClass("zemanta-pixie-a")){L=M.find(".zemanta-pixie-img").attr("src");K=L&&L.split("x-id=")[1]}}})}return K},loadScript:function(L,I){H.log("l "+L);var J=document.createElement("script"),K=false;J.type="text/javascript";J.charset="utf-8";if(I){J.onload=J.onreadystatechange=function(){var M=this.readyState;if(!K&&(!M||M==="loaded"||M==="complete")){K=true;I.apply(J);C.removeChild(J)}};J.onerror=function(){K=true;I.apply(J);C.removeChild(J)}}J.src=L;C.appendChild(J);return J},execScript:function(J,I){var K=0;return function(){H.log("x "+J+" on "+I);if(typeof H.loaded[J]==="function"){H.loaded[J](I)}else{K+=1;if(K<50){setTimeout(arguments.callee,200)}}}},template:function(J){var K=function(){var M=/\{(\w+)\}/g,L,N=[];while((L=M.exec(J))!==null){N.push({regx:new RegExp("{"+L[1]+"}","g"),name:L[1]})}return N}(),I=K.length;return function(M){var N=J,L=0;if(M){for(;L<I;L+=1){N=N.replace(K[L].regx,M[K[L].name]||"")}}return N}}};H=window.ZemantaReadside;function A(){var L=H.findScripts("zem-script"),Q=null,N=0,M=L.length,K=0,J=0,O=[],P="",I="",R=true;for(N=0;N<M;N+=1){if(F(L[N]).hasClass("zem-processed")){continue}for(K=0,J=H.scripts.length;K<J;K+=1){if(H.scripts.queue[K]===L[N]){R=false;break}}if(R){H.scripts.queue.push(L[N])}}while((Q=H.scripts.queue.shift())){H.scripts.done.push(Q);F(Q).addClass("zem-processed");O=H.getTypes(Q);for(K=0,J=O.length;K<J;K+=1){P=O[K];I=E[P];if(I){if(!H.loaded[P]){H.loaded[P]="loading";H.log("l "+E[P]);H.loadScript(E[P],H.execScript(P,Q))}else{H.log("lx");H.execScript(P,Q)()}}}}}(function(I){if(H.jQuery){F=H.jQuery;return I()}var J=window.jQuery;if(J&&J.fn.jquery&&parseInt(J.fn.jquery.replace(/\./gi,""),10)>=126){H.jQuery=F=J;I()}else{H.log("lj");H.loadScript(D+"core/jquery.js",function(){H.jQuery=F=window.jQuery.noConflict(true);H.log("l$");I()})}})(A)})();
