var uid="";var progress="";var nBooks="";var recent="";var coverSize="";var removeNoCover="";var curPath="";function innerContent(A,B){document.getElementById(A).innerHTML=B}function XMLtoString(A){if(A.xml){return A.xml}else{return(new XMLSerializer()).serializeToString(A)}}function stringToXML(B){if(window.ActiveXObject){var A=new ActiveXObject("Microsoft.XMLDOM");A.async=false;A.loadXML(A);return A}else{if(window.XMLHttpRequest){var C=new DOMParser();return C.parseFromString(B,"text/xml")}else{alert("stringToXML: impossibile trasformare la stringa in un documento XML");return null}}}function getDomAdapter(){var A="";if("undefined"!=typeof ActiveXObject){A="MS"}else{if("undefined"!=typeof document&&document.implementation&&document.implementation.createDocument&&"undefined"!=typeof DOMParser){A="default"}}switch(A){case"MS":return new (function(){this.createDocument=function(){var D=["Msxml2.DOMDocument.6.0","Msxml2.DOMDocument.3.0","MSXML2.DOMDocument","MSXML.DOMDocument","Microsoft.XMLDOM"];for(var B in D){try{return new ActiveXObject(D[B])}catch(C){}}throw new Error("Unable to create DOMDocument")};this.serialize=function(B){return B.xml};this.parseXml=function(B){var C=this.createDocument();if(!C.loadXML(B)){throw new Error("Parse error")}return C}})();case"default":return new (function(){this.createDocument=function(){return document.implementation.createDocument("","",null)};this.serialize=function(B){return new XMLSerializer().serializeToString(B)};this.parseXml=function(B){var C=new DOMParser().parseFromString(B,"text/xml");if("parsererror"==C.documentElement.nodeName){throw new Error("Parse error")}return C}})();default:throw new Error("Unable to select the DOM adapter")}}function getElementsByClassName(A,C){var D=document.getElementsByTagName(A);var E=new Array();for(var B=0;B<D.length;B++){if(D[B].className==C){E[E.length]=D[B]}}return E}function convert2Xhtml(B){var A;A=B;A=A.replace(/<.*>?>/g,function(C,E,D){return C.replace(/\s(\w+=)([#\w,;]+)/g,function(F,H,G){return" "+H.toLowerCase()+'"'+G+'"'})});A=A.replace(/<(\/?\w+)([^>]*>)/g,function(C,E,D){return"<"+E.toLowerCase()+D});A=A.replace(/<(meta|base|basefont|param|link|img|br|hr|area|input)([^>]*)>/g,function(C,E,D){return C.indexOf(" />")==-1?"<"+E+D+" />":C});A=A.replace(/<(img)([^>]*)\/>/g,function(C,E,D){return C.indexOf("alt=")==-1?"<"+E+D+' alt="" />':C});return A}function getXMLhttp(){if(window.XMLHttpRequest){return new XMLHttpRequest()}else{if(window.ActiveXObject){if(_ms_XMLHttpRequest_ActiveX){return new ActiveXObject(_ms_XMLHttpRequest_ActiveX)}else{var A=["Msxml2.XMLHTTP.7.0","Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];for(var B=0;B<A.length;B++){try{return new ActiveXObject(A[B])}catch(C){}}}if(_ms_XMLHttpRequest_ActiveX==""){return null}}}}function AJAXRequest(G,B,E,F,D,C){var A=this;A.AJAX=getXMLhttp();if(typeof F=="undefined"){F=executeReturn}if(F!=null){A.process=F;A.AJAX.onreadystatechange=function(){if(A.AJAX.readyState==4&&A.AJAX.status==200){if(A.AJAX.responseText){}}A.process(A.AJAX)}}if(!G){G="POST"}G=G.toUpperCase();if(typeof D=="undefined"||D==null){D=true}A.AJAX.open(G,B,D);if(G=="POST"){A.AJAX.setRequestHeader("Connection","close");A.AJAX.setRequestHeader("Content-Type","application/x-www-form-urlencoded");A.AJAX.setRequestHeader("Method","POST "+B+"HTTP/1.1")}if(C||typeof C=="undefined"){if(!E|G=="GET"){E=""}A.AJAX.send(E)}return A.AJAX}function evalRet(httpReq){if(httpReq.readyState==4&&httpReq.status==200){httpReqResult=httpReq.responseText;httpReqResult=httpReqResult.substring(0,httpReqResult.indexOf("document"));eval(httpReqResult);b_txt=b_txt.replace(/&/g,"&amp;");b_txt=convert2Xhtml(b_txt);b_txt="<div>"+b_txt+"</div>";var xml=getDomAdapter().parseXml(b_txt);uls=xml.getElementsByTagName("ul");var content="";for(var i=0;i<uls.length;i++){lis=uls[i].getElementsByTagName("li");coverUrl="http://image.anobii.com/anobi/image_medium/no_image_small.gif";if(lis.length==3){startIndex=1;coverUrl=(lis[0].getElementsByTagName("img").length>0)?lis[0].getElementsByTagName("img")[0].getAttribute("src"):"http://image.anobii.com/anobi/image_medium/no_image_small.gif"}else{startIndex=0}if((lis.length!=3&&!this.removeNoCover)||(lis.length==3&&lis[startIndex].getElementsByTagName("a")[0].firstChild)){anobiiUrl=lis[startIndex].getElementsByTagName("a")[0].getAttribute("href");title=lis[startIndex].getElementsByTagName("a")[0].firstChild.nodeValue;author="an unknown author";if(lis[startIndex+1].firstChild!=null){author=lis[startIndex+1].firstChild.nodeValue}content+='<a href="'+anobiiUrl+'">';content+='<img src="'+coverUrl+'" alt="'+title+", by "+author+'" title="'+title+", by "+author+'" />';content+="</a>"}}innerContent("anobiiBooks",content)}}function anobiiReload(A){anobiiInit(this.curPath,this.uid,this.progress,this.nBooks,this.recent,this.coverSize,this.removeNoCover)}function anobiiInit(G,C,A,D,F,E,B){this.uid=C;this.progress=A;this.nBooks=D;this.recent=F;this.coverSize=E;this.removeNoCover=B;this.curPath=G;if(C==""){innerContent("anobiiBooks","You must configure the plugin");return }urlAnobii=this.curPath+"proxy.php?uid="+this.uid+"&progress="+this.progress+"&nBooks="+this.nBooks+"&recent="+this.recent+"&coverSize="+this.coverSize+"&iHateIE="+Math.random();AJAXRequest("GET",urlAnobii,null,evalRet,true,1)};
