/* The Factory pattern. This pattern is used to instantiate a type. This script uses the Factory pattern to instantiate the XMLHttpRequest object. The Factor pattern is implemented in a single method, FactoryXMLHttpRequest, which returns an XMLHttpRequest object instance. For more details see Ajax Patterns and Best Practices by Christian Gross pages 27-29. */

function FactoryXMLHttpRequest(){
    if (window.XMLHttpRequest)
	{
	    return new XMLHttpRequest();
	    
	} 
    else if (window.ActiveXObject) 
	{
	    try {
		return new ActiveXObject("Msxml2.XMLHTTP");
	    } catch (e)
		{
		    try {
			return new ActiveXObject("Microsoft.XMLHTTP");
		    } catch (e) {
		    }
		}
	}
    throw new Error("Could not instantiate XMLHttpRequest");
}
