function ajax_load_div_content(url, id, parameters, type, mime)
{
	if (id!="")
	{
		//document.getElementById(id).innerHTML = '<FONT color=red>Chargement...</FONT>';
		document.getElementById(id).innerHTML = '<IMG SRC="/img/loading.gif">';
	}

	if (!mime) 
	{
		mime = 'text';
	}
	if (!type) 
	{
		type = 'POST';
	}

	var xhrRec = xhrRequest(mime);
	if (type == 'POST')
	{
		xhrRec.open('POST', url, true);
		xhrRec.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhrRec.setRequestHeader("Content-length", parameters.length);
		xhrRec.setRequestHeader("Connection", "close");
		xhrRec.send(parameters);
	}
	else
	{
		xhrRec.open('GET', url, true);
	}

	xhrRec.onreadystatechange = function() 
	{
		if (xhrRec.readyState == 4) 
		{
			if (xhrRec.status == 200) 
			{
				if (id!="")
				{
					if (document.getElementById(id))
					{
						document.getElementById(id).innerHTML = xhrRec.responseText;
						var x = document.getElementById(id).getElementsByTagName("script"); 
						for(var i=0;i<x.length;i++)
						{
							eval(x[i].text);
						}
					}
				}
				xhrRec = null;
			} 
			else 
			{
				if (id!="")
				{
					alert('Probleme lors de l\'execution de cette fonction !');
				}
				xhrRec = null;
			}
		}
		else if (xhrRec.readyState == 1 || xhrRec.readyState == 2 || xhrRec.readyState == 3)
		{
			if (id!="")
			{
				if (document.getElementById(id))
				{
					document.getElementById(id).innerHTML = '<IMG SRC="/img/loading.gif">';
				}
			}
		}
	}

	if (type == 'GET')
	{
		xhrRec.send(null);
	}
}


function xhrRequest(type) 
{
	var xhrSend;
	if (!type) 
	{
		type = 'text';
	}
	if (window.ActiveXObject) 
	{
		try {
			xhrSend = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xhrSend = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	} 
	else if (window.XMLHttpRequest)
	{
		xhrSend = new XMLHttpRequest();
		if (xhrSend.overrideMimeType) 
		{
			xhrSend.overrideMimeType('text/' + type);
		}
	}
	return (xhrSend);
}
