/*
* freepaper_spip.js
* franck ruzzin
* le 20/06/2009
*/

m_freepaper_swfUrl="plugins/freepaper/swf/freepaper.0.8.1.swf";	//URL du fichier fichier swf "freepaper.swf"
m_freepaper_phpURL="plugins/freepaper/php/freepaper_spip.php";	//URL du script PHP freepaper_spip.php

freepaper={swfArray:new Array(),xmlArray:new Array(),embedDoc:function(A,F,B){if(!F.width){F.width=600}if(!F.height){F.height=800}if(!B.altContentId){B.altContentId="freepaper1"}B.id=B.altContentId+"_ready";A.playerId=B.id;var D=document.getElementById(B.altContentId);D.style.height=F.height+"px";D.style.width=F.width+"px";var E=this.getXhr();if(!E){throw new Error("Impossible d'ouvrir une communication xhr.")}var C=this;E.onreadystatechange=function(){if(E.readyState==4){if(E.status==200){if(B.trace==true){alert(E.responseText)}var I=E.responseText.lastIndexOf("TRYING WITH -> ");if(I>0){var H=/IMG\/pdf/;A.pdfURL=A.pdfURL.replace(H,"IMG/swf")}C.display(A,F,B)}else{var G="Ouverture de "+m_freepaper_phpURL+"\n";G+="Erreur: "+E.status+" "+E.statusText;alert(G)}}};E.open("POST",m_freepaper_phpURL,true);E.setRequestHeader("Content-Type","application/x-www-form-urlencoded");E.send("docURL="+A.pdfURL+"&callerURL="+document.URL)},display:function(A,C,B){A.swfURL=A.pdfURL+".swf";A.pdfURL=null;if(!this.swfArray[B.altContentId+"_ready"]){this.swfArray[B.altContentId+"_ready"]=A.swfURL;this.xmlArray[B.altContentId+"_ready"]=A.xmlDataPath}B.styleclass="freepaper";swfobject.embedSWF(m_freepaper_swfUrl,B.altContentId,C.width,C.height,"8.0.0",false,A,C,B);setTimeout(this.resetGetFlashPlayer_Proxy(B.altContentId),500)},resetGetFlashPlayer_Proxy:function(B){var A=this;return function(){A.resetGetFlashPlayer(B)}},resetGetFlashPlayer:function(C){var B=document.getElementById(C);if(B){B.style.backgroundImage="url(plugins/freepaper/images/empty.gif)";var A=B.getElementsByTagName("IMG")[0];A.style.display="block";alert("Téléchargez le plugin Flash !")}},getXhr:function(){var B=null;if(window.XMLHttpRequest){B=new XMLHttpRequest()}else{if(window.ActiveXObject){try{B=new ActiveXObject("Msxml2.XMLHTTP")}catch(A){B=new ActiveXObject("Microsoft.XMLHTTP")}}else{alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");B=false}}return B}};var fpdomutil={getObjectLeft:function(C){var B=(typeof (C)=="string")?document.getElementById(C):C;var A=0;A=B.offsetLeft;while(B.offsetParent){B=B.offsetParent;A+=B.offsetLeft}return parseInt(A)},getObjectTop:function(C){var B=(typeof (C)=="string")?document.getElementById(C):C;var A=0;A=B.offsetTop;while(B.offsetParent){B=B.offsetParent;A+=B.offsetTop}return parseInt(A)},getObjectWidth:function(C){var B=(typeof (C)=="string")?document.getElementById(C):C;var A=0;A=B.offsetWidth;return parseInt(A)},getObjectHeight:function(C){var B=(typeof (C)=="string")?document.getElementById(C):C;var A=0;A=B.offsetHeight;return parseInt(A)},getNavigatorHeight:function(){if(window.innerHeight){return window.innerHeight}else{if(document.body){if(document.body.parentElement&&document.body.parentElement.clientHeight){return document.body.parentElement.clientHeight}else{if(document.body.clientHeight){return document.body.clientHeight}}}}return 0},getNavigatorWidth:function(){if(window.innerWidth){return window.innerWidth}else{if(document.body){if(document.body.parentElement&&document.body.parentElement.clientWidth){return document.body.parentElement.clientWidth}else{if(document.body.clientWidth){return document.body.clientWidth}}}}return 0},getDocumentHeight:function(){return document.body.scrollHeight},getDocumentWidth:function(){return document.body.scrollWidth},getScrollTop:function(){if(window.innerWidth){return window.pageYOffset}else{return document.documentElement.scrollTop}},getScrollLeft:function(){if(window.innerWidth){return window.pageXOffset}else{return document.documentElement.scrollLeft}},addNewRule:function(B,A,D,C){if(document.styleSheets){if(document.styleSheets[B].cssRules){document.styleSheets[B].insertRule(A+"{"+D+";}",C)}else{if(document.styleSheets[B].rules){document.styleSheets[B].addRule(A,D,C)}}}},deleteRule:function(A,B){if(document.styleSheets){if(document.styleSheets[A].cssRules){document.styleSheets[A].deleteRule(B)}else{if(document.styleSheets[A].rules){document.styleSheets[A].removeRule(B)}}}},getCssRules:function(A){if(typeof (A)=="undefined"){A=0}if(document.styleSheets){if(document.styleSheets[A].cssRules){return document.styleSheets[A].cssRules}else{if(document.styleSheets[A].rules){return document.styleSheets[A].rules}}}},getScrollBarWidth:function(){var C=document.createElement("p");C.style.width="100%";C.style.height="200px";var D=document.createElement("div");D.style.position="absolute";D.style.top="0px";D.style.left="0px";D.style.visibility="hidden";D.style.width="200px";D.style.height="150px";D.style.overflow="hidden";D.appendChild(C);document.body.appendChild(D);var B=C.offsetWidth;D.style.overflow="scroll";var A=C.offsetWidth;if(B==A){A=D.clientWidth}document.body.removeChild(D);return(B-A)},getStyle:function(C,B,A){if(window.getComputedStyle){retVal=document.defaultView.getComputedStyle(C,null).getPropertyValue(B)}else{if(C.currentStyle){retVal=C.currentStyle[A]}}return retVal},isIE6:navigator.userAgent.toLowerCase().indexOf("msie 6")!=-1,isIE:navigator.userAgent.toLowerCase().indexOf("msie")!=-1,isFF3:navigator.userAgent.toLowerCase().indexOf("firefox/3")!=-1,isSafari:navigator.userAgent.toLowerCase().indexOf("safari")!=-1,isOpera:navigator.userAgent.toLowerCase().indexOf("opera")!=-1};
