function AJAX() {
	
	this.xhr_object    = null;
	this.response      = null;
	this.ready         = true;
	this.asynchronous  = true;
	this.autovalidate  = false;

	if (typeof XMLHttpRequest == "undefined")
	  XMLHttpRequest = function() {
		try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch(e) {};
		try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch(e) {};
		try { return new ActiveXObject("Msxml2.XMLHTTP"); }     catch(e) {};
		try { return new ActiveXObject("Microsoft.XMLHTTP"); }  catch(e) {};
	 
		throw alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	  };
	this.xhr_object = new XMLHttpRequest(); 

	this.indicatorFunction = null;

	this.setIndicatorFunction = function(func) {
		if(typeof(func) == "function") this.indicatorFunction = func;
	}

	this.callbackFunction = null;

	this.setCallbackFunction = function(func) {
		if(typeof(func) == "function") {
            this.callbackFunction = func;
            this.autovalidate     = true;
        }
	}

	this.setSynchronous = function() {
		this.asynchronous = false;
	}

	this.setAsynchronous = function() {
		this.asynchronous = true;
	}

	this.getFileGet = function(url, data) {
		return this.doRequest(url, "GET", data);
	}

	this.getFile = this.getFileGet;
	
	this.getFilePost = function(url, data) {
		return this.doRequest(url, "POST", data);
	}

	this.getFileHeader = function(url, header) {
		return this.doRequest(url, "HEAD", header);
	}

	this.doRequest = function(url, method, data) {

		if(!this.ready || !this.xhr_object) return false;

		function _getResponseHeader(headers, header_name) {
			var tmp = headers.split("\n");
			for(var i=0, n=tmp.length, t=[]; i<n-1; ++i) {
				t = tmp[i].split(": ");
				if(t[0].toLowerCase() == header_name.toLowerCase()) return t[1];
			}
			return "Header inconnu...";
		}

		if(this.indicatorFunction) this.indicatorFunction(true);
		this.ready = false;

		var obj = this;
		function onreadystatechangeFunction() {
			if(obj.xhr_object.readyState != 4) return;
			
			if(obj.indicatorFunction) obj.indicatorFunction(false);

			var all_headers = obj.xhr_object.getAllResponseHeaders();
			if(method == "HEAD") {
				obj.response = data ? _getResponseHeader(all_headers, data) : all_headers;
			}
			else {
				var content_type = _getResponseHeader(all_headers, "Content-Type");
				if (content_type != "Header inconnu..." && (new RegExp("^text/xml.*$", "gi")).test(content_type))
					obj.response = obj.xhr_object.responseXML;
				else {
					if(obj.xhr_object.status != 200 && obj.xhr_object.status != 304) alert("Une erreur " + obj.xhr_object.status + " est survenue, le serveur a detecté un problème dans les données transmises. Modifiez vos données ou bien contactez nous via la page contact si vous pensez que ces données sont correctes."); 
					obj.response = obj.xhr_object.responseText;
				}
				if (obj.callbackFunction) {
                    obj.callbackFunction(obj.xhr_object.responseText);
                    if (obj.autovalidate) obj.validateRequest();
                }
			}
		}

		if(method == "GET" && typeof(data) != "undefined" && data != "") url += "?"+data;
		this.xhr_object.open(method, _AJAX_addDummyData(url), this.asynchronous);

		if(this.asynchronous)
			this.xhr_object.onreadystatechange = onreadystatechangeFunction;
		
		if(data) this.xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		else     data = null;
		this.xhr_object.send(data);

		if(!this.asynchronous)
			onreadystatechangeFunction();

		return true;
	}

	this.hasResponse = function() {
		return this.response != null;
	}

	this.getResponse = function() {
		return this.response;
	}

    this.setAutoValidate = function(flag) {
        this.autovalidate = flag;
    }

	this.validateRequest = function() {
		this.ready    = true;
		this.response = null;
	}

	this.cancelRequest = function() {
		this.xhr_object.abort();
		if(this.indicatorFunction) this.indicatorFunction(false);
		this.validateRequest();
	}
}

function _AJAX_addDummyData(str) {
	var t = new Date();
    if (str.indexOf("?") == -1) str += "?ajax_dummy=";
    else                        str += "&ajax_dummy=";
	return str+t.getTime();
}
