/*
	Auteur(s)       : ALI HUSSEIN
	Date de création: Avril 2006
	Mise(s) à jour
	-    AAAA/MM/JJ :
*/
//Send to server a request. Response a XML file
var userFormDestination; 
function connectServer()
{
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, sResp)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {

        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200 && !bComplete)
        {
          bComplete = true;
          sResp(xmlhttp, userFormDestination);
        }};
      xmlhttp.send(sVars);
    } catch(z) { return false; }
    return true;
  };
  return this;
}


function serverResponseXML(oXML) {
    alert("je retourne");
    var responseXML = oXML.responseText;
		
	alert(responseXML);

}

function requestServer(page,method,param,userForm){
        userFormDestination=userForm;
		var myConnection = new connectServer();

		if (!myConnection) alert("XMLHTTP not available. Try a newer/better browser.");

		
	   myConnection.connect(page, method, param, serverResponse); //Function ServerResponse in file ServerReply
	   	   		
}

