


/*  
    FUNCTION
    makeHttpRequest

    DESCRIPTION
    Create an appropriate HTTP Request and runs the specified function on the result. 
      
    PARAMETERS
    url - url of web file to access for result
    callback_function - local JavaScript function to apply to result of 'url' above
    return_xml - boolean flag determining if result is XML or not
*/
function makeHttpRequest(url, callback_function, return_xml)
{
   var http_request = false;

   var i; 

 var activex_ids = [ 
   'MSXML2.XMLHTTP.3.0', 
   'MSXML2.XMLHTTP', 
   'Microsoft.XMLHTTP' 
 ]; 

   if (window.XMLHttpRequest) { 
       // Mozilla, Safari,...
       http_request = new XMLHttpRequest();
       if (http_request.overrideMimeType) {
           http_request.overrideMimeType('text/xml');
       }
   } else if (window.ActiveXObject) { 
       for (i = 0; i < activex_ids.length; i++) { 
     try { 
       http_request = new ActiveXObject(activex_ids[i]); 
     } catch (e) {} 
   } 
   }

   if (!http_request) {
       //Don't need to tell user, just don't do AJAX - left in comment for dev clarity.
       //alert('Browser doesn\'t support AJAX.');
       return false;
   }
   
   // Now we run our designated function with the data returned
   http_request.onreadystatechange = function() {
       if (http_request.readyState == 4) {
           if (http_request.status == 200) {
               if (return_xml) {
                   eval(callback_function + '(http_request.responseXML)');
               } else {
                   eval(callback_function + '(http_request.responseText)');
               }
           } else {
               // Don't tell the user - left in comment for dev clarity.
               //alert('There was a problem with the request.(Code: ' + http_request.status + ')');
           }
       }
   }
   
   http_request.open('GET', url, true);
   http_request.send(null);
   
}