
   function baseXMLHttpRequest() {
 		var req = false; 
        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            req = new XMLHttpRequest();
            if (req.overrideMimeType) {
                req.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
            try {
                req = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
              try {
                 req = new ActiveXObject("Microsoft.XMLHTTP");
               }catch(e) {
                   alert("You need to enable active scripting and activeX controls");
              }
            }
        }
        if (!req) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        return req;
   }

   function openGetRequest(req,url,asynchronous) {
 	try {
	   req.open("GET", url, asynchronous);
		   req.setRequestHeader("MessageType","CALL")    
		   req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
		   if (window.ActiveXObject) { // IE
		   	  req.send();
		   }else{
		      req.send(null);   // Mozilla, Safari, Opera etc...
		   }
	    } catch (e) {
	        alert(e);
	    }
   }
   function openPostRequest(req,url,parameter,asynchronous) {
 	try {
	   req.open("POST", url, asynchronous);
		   req.setRequestHeader("MessageType","CALL")    
		   req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
		   req.send(parameter);
	    } catch (e) {
	        alert(e);
	    }
   }   

	/*
	  * Returns a function that waits for the specified XMLHttpRequest
	  * to complete, then passes it XML response to the given handler function.
	  * req - The XMLHttpRequest whose state is changing
	  * responseXmlHandler - Function to pass the XML response to
	  */
	 function getReadyStateLoadingHandler(req, controlId, loadingControlId,imagepath, responseXmlHandler) {
	   // Return an anonymous function that listens to the XMLHttpRequest instance
	  
	   return function () {
	       //  0 (uninitialized)
	       //  1 (loading)
	       //   2 (loaded)
	       //   3 (interactive)
	       //  4 (complete) 
 	  
   	 
   	   	
 	   if (req.readyState == 0) { 
 	   
          document.getElementById(loadingControlId).innerHTML='<img src=\"'+imagepath+'/loadingInt.gif\"/>&nbsp;&nbsp;Loading...'; 
       }       
       if (req.readyState == 1) { 
          document.getElementById(loadingControlId).innerHTML='<img src=\"'+imagepath+'/loadingInt.gif\"/>&nbsp;&nbsp;Loading...'; 
       }
       if (req.readyState == 2) { 
          document.getElementById(loadingControlId).innerHTML='<img src=\"'+imagepath+'/loadingInt.gif\"/>&nbsp;&nbsp;Loading...'; 
       }
       if (req.readyState == 3) { 
           document.getElementById(loadingControlId).innerHTML='<img src=\"'+imagepath+'/loadingInt.gif\"/>&nbsp;&nbsp;Loading...'; 
       }   
       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.
        	 document.getElementById('contact_email_addresses').style.display="none"; 
        	 responseXmlHandler(req.responseXML,controlId);
     	  } else {
       	  // An HTTP problem has occurred
       	  //alert(req);
         alert("HTTP error "+req.status+": "+req.statusText);
	       }
     }
   }
 }	
	