/*
======================================================================
JavaScript XMLHttpRequest object builder
Author: Alessandro Lacava http://www.alessandrolacava.com
Created: Jul 25th, 2006.
Description: Build and return the object used to perform AJAX calls.
======================================================================
*/

// The following function creates an XMLHttpRequest object
function createHttpRequest()
{
	if (typeof XMLHttpRequest != "undefined") //NOT IE
	{
		return new XMLHttpRequest();
	}
	else if (window.ActiveXObject) // IE
	{
		var sVersions = [ "MSXML2.XMLHttp.5.0",
		"MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0",
		"MSXML2.XMLHttp","Microsoft.XMLHttp"
		];

		// Try to get an instance of the newer version.
		// If it is not available go down till the oldest one
		for (var i = 0; i < sVersions.length; i++)
		{
			try
			{
				var ret = new ActiveXObject(sVersions[i]);
				return ret;
			}
			catch (oException)
			{
				// Do nothing. Just go on trying with the older versions
			}
		}
	}
	// If it gets here then no version is available
	alert("XMLHttpRequest object could not be created.");
	return false;
}
