// JavaScript Document

function createXHR()
{
	try 
	{  
		xhr = new ActiveXObject('Msxml2.XMLHTTP');   
	}
	catch (e) 
	{
		try 
		{
			xhr = new ActiveXObject('Microsoft.XMLHTTP');    
		}
		catch (e2) 
		{
			try 
			{  
				xhr = new XMLHttpRequest();     
			}
			catch (e3) 
			{  
				xhr = false;   
			}
		}
	}
	
	return xhr;
}

function insertAjax(URL, type, data)
{
	var xhr = createXHR();
		
	xhr.onreadystatechange  = function()
	{ 
		if(xhr.readyState  == 4)
		{
			// Nothing
		}
	}; 
		   
	xhr.open(type, URL, true);
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-15");                  
	xhr.send(data);
}


function recupAjax(URL, type, data, functionAction)
{
	var xhr = createXHR();
		
	xhr.onreadystatechange  = function()
	{ 
	 	chargementAjax('visible');
		
		if(xhr.readyState == 4 && xhr.status == 200)
		{ 
			chargementAjax('hidden');

			functionAction(xhr.responseText);
		}
	}; 
		
	xhr.open(type, URL, true);
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-15");                  
	xhr.send(data);
}

function chargementAjax(etat)
{
	document.getElementById('ajaxchargement').style.visibility = etat;
}

