// Créer le package ZoulouX
if (typeof zouloux == "undefined")
{
	var zouloux = new Object();
}

// Le constructeur de la classe
zouloux.XHR = function (url)
{
	// Cibler cet objet
	var _this = this;
	
	// Initialiser l'objet XHR
	this.xhr = null; 
	
	// Le créer selon le navigateur
	if (window.XMLHttpRequest)
	{
		// Firefox et autres
		this.xhr = new XMLHttpRequest();
		
		// Evite un bug du navigateur Safari
		if (this.xhr.overrideMimeType) 
		{
			this.xhr.overrideMimeType("text/xml");
		}
	}
	else if (window.ActiveXObject)
	{
		// Internet Explorer 
		try 
		{
			this.xhr = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			this.xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else 
	{ 
		// XMLHttpRequest non supporté par le navigateur 
		alert("Impossible d'utiliser les fonctionnalités AJAX."); 
		xhr = false; 
	}
	
	// Une fois que les informations ont été reçues
	this.xhr.onreadystatechange = function()
	{
		if(_this.xhr.readyState == 4)
		{
			if (_this.xhr.status == 200)
			{
				// Récéption ok, appeler la fonction attachée à l'objet
				_this.onLoad(_this.xhr.responseXML, _this.xhr.responseText);
			}
			else
			{
				// Répondre à la fonction d'erreur
				if (typeof _this.onError == "undefined")
				{
					// Si on en trouve pas la fonction on envois un message
					alert("Erreur de reception des données AJAX");
				}
				else
				{
					// Sinon on appèle la fonction
					_this.onError();
				}
			}
		}
	}
	
	// L'anticache
	//this._date = new Date();
	//this._anti = "?_t="+this._date.getTime();
	
	// Appeler l'url
	this.xhr.open("GET", url, true);
	this.xhr.send(null);
}