function GetHttpCnx()
{
	//firefox 
	if (window.XMLHttpRequest) 
	{ 
		var HttpCnx = new XMLHttpRequest(); 
	} 
	//ie 
	else if (window.ActiveXObject)
	{
		try
		{ 
			var HttpCnx = new ActiveXObject("Msxml2.XMLHTTP"); 
		}
		catch (e)
		{
			var HttpCnx = new ActiveXObject("Microsoft.XMLHTTP"); 
		}
	}
	//non supporté 
	else
	{ 
		var HttpCnx = false;
	}
	
	return HttpCnx;
}

function HTTPConnect()
{
	var HttpCnx = false;
	var Datas = new String();
	
	HttpCnx = GetHttpCnx();

	//Vide la pile de données
	this.ResetData = function()
	{
		Datas = new String();
		Datas = '';
	};
	
	//Ajoute des données a envoyer
	this.AddData = function(pfield, pvalue)
	{
		Datas += (Datas.length == 0) ? pfield+ "=" + escape(pvalue) : "&" + pfield + "=" + escape(pvalue);
	};

	//Envoi la requete HTTP
	this.SendData = function(CnxUrl, HttpMode, CallBackFonction,param)
	{
		HttpMode = HttpMode.toUpperCase();
		
		HttpCnx.onreadystatechange = function()
		{
			if (HttpCnx.readyState == 4 && HttpCnx.status == 200)
			{
				// Si une fonction de callBack a été définie
				if (typeof CallBackFonction == "function")
				{
					CallBackFonction(HttpCnx,param);
					return;
				}
				else
				{
					return;
				}
			}
		};
		
		if(HttpMode == "GET")
		{
			try
			{
				if(Datas.length > 0)
				{
					CnxUrl = CnxUrl + "?" + Datas;
				}
				
				HttpCnx.open("GET", CnxUrl);
				HttpCnx.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1;");
				HttpCnx.send(null);
			}
			catch(error)
			{
				return false;
			}
		}
		else if(HttpMode == "POST")
		{
			try
			{
				HttpCnx.open("POST", CnxUrl); 
				HttpCnx.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1;");
				HttpCnx.send(Datas);
			}
			catch(error)
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	};
	return this;
}