/*
* freepaper2_spip.js
* franck ruzzin
* le 04/03/2010
*/

m_freepaper2_swfUrl = freepaper2Root + "swf/freepaper2.0.9.0.swf";	//URL du fichier fichier swf "freepaper.swf"
m_freepaper2_phpURL = freepaper2Root + "php/freepaper2_spip.php";	//URL du script PHP freepaper_spip.php
freepaper2={swfArray:new Array(),xmlArray:new Array(),embedDoc:function(A,E,B){if(!E.width){E.width=600}if(!E.height){E.height=800}if(!B.altContentId){B.altContentId="freepaper1"}B.id=B.altContentId+"_ready";A.playerId=B.id;var C=document.getElementById(B.altContentId);C.style.height=E.height+"px";C.style.width=E.width+"px";if(A.docURL.substr(A.docURL.length-3).toUpperCase()=="SWF"){this.display(A,E,B)}else{var D=this.getXhr();if(!D){throw new Error("Impossible d'ouvrir une communication xhr.")}D.onreadystatechange=function(){if(D.readyState==4){if(D.status==200){if(B.trace==true){alert(D.responseText)}var G=freepaper2.getFileExtension(A.docURL);if(D.responseText.lastIndexOf("EXEC RETURN VALUE : 0")>-1){A.docURL=A.docURL.replace("IMG/"+G,"IMG/swf")+".swf"}else{var H=D.responseText.lastIndexOf("Not in IMG/swf, Looking in IMG/");if(H>0){A.docURL=A.docURL+".swf"}else{A.docURL="error.swf"}}freepaper2.display(A,E,B)}else{var F="Ouverture de "+m_freepaper2_phpURL+"\n";F+="Erreur: "+D.status+" "+D.statusText;alert(F)}}};D.open("POST",m_freepaper2_phpURL,true);D.setRequestHeader("Content-Type","application/x-www-form-urlencoded");D.send("docURL="+A.docURL+"&callerURL="+document.URL)}},getFileExtension:function(C){var A=C.lastIndexOf(".");if(A==-1){return""}var B=C.substr(A+1);return B},display:function(A,C,B){A.swfURL=A.docURL;delete A.docURL;B.styleclass="freepaper";swfobject.embedSWF(m_freepaper2_swfUrl,B.altContentId,C.width,C.height,"9.0.115.0",freepaper2Root+"swf/expressInstall.swf",A,C,B,this.onEndInstall)},onEndInstall:function(A){if(A.ref==undefined){freepaper2.resetGetFlashPlayer(A.id)}else{freepaper2.setFocusAndListener(A.id+"_ready")}},resetGetFlashPlayer:function(C){var B=document.getElementById(C);if(B){B.style.backgroundImage="url("+freepaper2Root+"images/empty.gif)";var A=B.getElementsByTagName("IMG")[0];A.style.display="block";alert("T\351l\351chargez le plugin Flash !")}},setFocusAndListener:function(D){var C=document.getElementById(D);function B(){C.focus()}function A(E){if(E!=null&&E.preventDefault!=null){E.preventDefault()}return false}if(C.addEventListener==null){C.onmousewheel=A}else{C.addEventListener("DOMMouseScroll",A,false)}setTimeout(B,1000)},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};