function AJAX(a_sURL/*, a_sDiv*/)
{
	if (a_sURL != undefined)
	{
		this.m_sURL = a_sURL;
	}
	/*
	if (a_sDiv != undefined)
	{
		this.m_sDiv = a_sDiv;
	}
	*/
	if (this.m_Request != undefined)
	{
		this.m_Request.abort();
		delete this.m_Request;
	}
	this.m_Request = this.createReqestObject();
	var m_This = this;
	this.m_Request.onreadystatechange = function() {m_This.handleResponse()};
	this.m_Request.open("GET", this.m_sURL, true);
	this.m_Request.send(null);
}

AJAX.prototype.m_sURL = undefined;
AJAX.prototype.m_sDiv = undefined;
AJAX.prototype.m_Request = undefined;

AJAX.prototype.createReqestObject = function()
{
	var req;
	try {
		// Mozilla, Firefox, Opera et le reste du monde.
		req = new XMLHttpRequest();
	}
	catch (error) {
		try {
			// IE
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (error) {
			try {
				// IE
				req = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (error) {
				req = false;
			}
		}
	}
	return req;
}

AJAX.prototype.handleResponse = function()
{
	if (this.m_Request.readyState == 4)
	{
		// On regarde pour 0 à cause d'un bug dans Firefox.
		if (this.m_Request.status == "200" || this.m_Request.status == "0")
		{
			//var content = getById(this.m_sDiv);
			//content.innerHTML = this.m_Request.responseText;
			eval(this.m_Request.responseText);
			if (this.onDraw != undefined)
			{
				this.onDraw();
			}
		}
		else
		{
			if (this.onError != undefined)
			{
				this.onError({status:this.m_Request.status, statusText:this.m_Request.statusText});
			}
		}
		delete this.m_Request;
	}
	else
	{
		//getById(this.m_sDiv).innerHTML = "<img src='/images/working.gif' alt='En traitement...'>";
	}
}

function div_show(a_sDiv, data)
{
	var content = getById(a_sDiv);
	content.innerHTML = data;
}

function getById(a_id)
{
	if (document.getElementById)
	{
		return document.getElementById(a_id);
	}
	else if (document.all)
	{
		return document.all[a_id];
	}
	else if (document.layers)
	{
		return document.layers[a_id];
	}
	return null;
}

function aj_direct(s)
{
	var URL = escape(s);
	var ajax = new AJAX(URL);
}