// the facilities to get a new request object are essentially those from 'Javascript the Definitive Guide' pg 480-481

var HTTPRequestFunctions = [ function() { return new XMLHttpRequest(); },
							 function() { return new ActiveXObject("Msxml2.XMLHTTP"); },
					 		 function() { return new ActiveXObject("Microsoft.XMLHTTP"); }
				    	    ];

var HTTPRequestFunction = null;

function getHTTPRequest() {
	if(HTTPRequestFunction != null) {
		return HTTPRequestFunction();
	}
	
	for(var i=0; i < HTTPRequestFunctions.length; i++) {
		try {
			var request = HTTPRequestFunctions[i]();
			if(request != null) {
				HTTPRequestFunction = HTTPRequestFunctions[i];
				return request;
			}
		} catch(e) {
			continue;
		}
	}
	//  If we are here, we do not have XMLHTTPRequest capability
	return null;
}
			
	