/*
 * Returns an new XMLHttpRequest object, or false if the browser
 * doesn't support it
 */
function newXMLHttpRequest() {
	var xmlhttp = null;
	if (window.XMLHttpRequest) {
  		xmlhttp = new XMLHttpRequest();
  			if ( typeof xmlhttp.overrideMimeType != 'undefined') {
    			xmlhttp.overrideMimeType('text/xml');
  			}
	} else if (window.ActiveXObject) {
  		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
  		alert('Error getting information, perhaps your browser does not support xmlhttprequests?');
  	}
  		
  	return xmlhttp;
}

function getReadyStateHandler(req, responseXmlHandler) {

   // Return an anonymous function that listens to the XMLHttpRequest instance
   return function () {

     // If the request's status is "complete"
     if (req.readyState == 4) {
       
       // Check that we received a successful response from the server
       if (req.status == 200) {
		 
         // Pass the XML payload of the response to the handler function.
         responseXmlHandler(req.responseXML);

       } else {

         // An HTTP problem has occurred
         alert("HTTP error "+req.status+": "+req.statusText);
       }
     }
   }
 }
