function XHRConnection(pdebug) {
var conn = false;var debug = (pdebug == true || pdebug == false) ? pdebug : false;
var datas = new String();var areaId = new String();
var xmlObj;
var xmlLoad;
try {conn = new XMLHttpRequest();}
catch (error) {
if (debug) { alert(error); }
try {conn = new ActiveXObject("Microsoft.XMLHTTP");} catch (error) {if (debug) {alert(error);}
try {conn = new ActiveXObject("Msxml2.XMLHTTP");} catch (error) {if (debug) { alert(error);}
conn = false;}}}
this.setDebugOff = function() {debug = false;};
this.setDebugOn = function() {debug = true;};
this.resetData = function() {datas = new String(); datas = '';};
this.appendData = function(pfield, pvalue) {datas += (datas.length == 0) ? pfield+ "=" + escape(pvalue) : "&" + pfield + "=" + escape(pvalue);};
this.setRefreshArea = function(id) {areaId = id;};
this.createXMLObject = function() {
try {xmlDoc = document.implementation.createDocument("", "", null);
xmlLoad = 'onload';} catch (error) { try {xmlDoc = new ActiveXObject("Microsoft.XMLDOM");xmlLoad = 'onreadystatechange ';} catch (error) {if (debug) { alert('CXML');}
return false;}}
return xmlDoc;}
this.setXMLObject = function(obj) {
if (obj == undefined) {
if (debug) {alert('P');}
return false;} try {
xmlObj = obj;}catch (error) {if (debug) {alert('A');}}}
this.loadXML = function(xml, callBack) {
if (!conn) return false;
if (xmlObj && xml) {
if (typeof callBack == "function") {
if (xmlLoad == 'onload') {xmlObj.onload = callBack;}
else {xmlObj.onreadystatechange = function() {
if (xmlObj.readyState == 4) callBack()}}}
try  {
if (!xmlObj.load(xml)) alert('impossible de lancer le chargement de '+xml);
}
catch (error)
{alert("Chargement impossible avec ce navigateur, nous vous conseillons firefox");window.location.replace("http://www.fur4x-hebergement.net/galize/");}
return;}}
this.sendAndLoad = function(Url, httpMode, callBack) {
httpMode = httpMode.toUpperCase();
conn.onreadystatechange = function() {
if (conn.readyState == 4 && conn.status == 200) {
if (typeof callBack == "function") {
callBack(conn);
return;}
else if (areaId.length > 0){
try {document.getElementById(areaId).innerHTML = conn.responseText;}
catch(error) {if (debug) { alert(areaId);}}
return;}}};
switch(httpMode) {
case "GET":
try {Url = (datas.length > 0) ? Url + "?" + datas : Url;
conn.open("GET", Url,true);
conn.send(null);}
catch(error) {if (debug) { alert(Url);}
return false;}
break;
case "POST":
try {conn.open("POST", Url,true); 
conn.setRequestHeader("Method", "POST " + Url + " HTTP/1.01");
conn.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
conn.send(datas);}
catch(error) {
if (debug) {alert(Url);}
return false;}
break;
default :
return false;
break;}
return true;};
return this;}
