// JavaScript Document
function create_xhr_object ()
{
	var xhr;
	
	if (window.XMLHttpRequest) 
	{
		xhr = new XMLHttpRequest(); //Firefox ou IE >= 7.0
	}
	else if (window.ActiveXObject) 
	{
		try // essaie de charger l'objet pour IE
		{ 
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) // essaie de charger l'objet pour une autre version IE
		{
			try 
			{
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e) 
			{
				xhr = 0;
			}
		} 
	}
	
	return xhr;
}

/*function XMLhr ()
{
	var complete = false;
	var xhr = create_xhr_object ();
	
	if (!xhr)
		return false;
	
	// Requête
	this.request = function(url, vars, fn, method)
	{
		if (!xhr)
			return false;
		
		complete = false;
		
		if (method == null)
			method = 'POST';
		else
			method = method.toUpperCase();
		
		// converts the array in query string
		if (vars instanceof Array)
		{
			var qs = '';
			
			for (i in vars)
				qs += i+'='+encodeURIComponent(vars[i])+'&';
			
			vars = qs.substring(0, (qs.length-1));
		}
		
		try
		{
			// sends data using GET
			if (method == 'GET')
			{
				xhr.open('GET', url+'?'+vars, true);
				vars = '';
			}
			// sends data using POST
			else
			{
				xhr.open('POST', url, true);
				xhr.setRequestHeader("Method", "POST "+url+" HTTP/1.1");
				xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			}
			
			// calls fn function when the HTTP request is complete
			xhr.onreadystatechange = function()
			{
				if (xhr.readyState == 4 && !complete)
				{
					complete = true;
					if (fn)
					{
						fn(xhr);
					}
				}
			}
			
			xhr.send(vars);
		}
		catch (h)
		{
			return false;
		}
		
		return true;
	}
	
	return this;
}*/
