

function createHttpRequestObject() {

   var req;
	
   req = false;
   
   if(window.XMLHttpRequest){
      // Firefox, Safari, Opera...
      //req = new XMLHttpRequest();
	  try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
   } else if(window.ActiveXObject) {
      // Internet Explorer 5+
      //req = new ActiveXObject("Microsoft.XMLHTTP");
	  try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
   } else {
      // There is an error creating the object,
      // just as an old browser is being used.
      // alert('Problem creating the XMLHttpRequest object');
	  alert('Your browser does not support XMLHTTP');
   }

   return req;

}


	
// Make the XMLHttpRequest object
var xmlhttp = createHttpRequestObject();

function sendHttpRequest(url) {

   // Open script for requests
   if (xmlhttp){
   		xmlhttp.open('get', url, true);
   		xmlhttp.onreadystatechange = handleHttpResponse;
   		//req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		//http.send("");
		xmlhttp.send(null);
   } else {
   		// There is an error creating the object,
      // just as an old browser is being used.
      // alert('Problem creating the XMLHttpRequest object');
	  alert('Your browser does not support XMLHTTP');
   }
  

}

function processReqChange() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            // ...processing statements go here...
        } else {
            alert("There was a problem retrieving the XML data:\n" +
                req.statusText);
        }
    }
}

function handleHttpResponse() {

   if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
	  // ...processing statements go here...
	  
      // Text returned FROM the script
      var response = xmlhttp.responseText;

      if(response) {
         // UPDATE ajaxTest content
         document.getElementById("ajaxTest").innerHTML = response;
      }

   } else {
   		alert("There was a problem retrieving the data:\n" +
                xmlhttp.statusText);
   }

}

/*
	example 1	
	<input name="q" id="q" type="text" id="q" style="width:300px" onkeyup="sendRequest(this.value);" />
	<div id="searchResults" style="width:295px; padding:5px; border:1px solid #000000"></div>

	example 2
	<div id="ajaxTest">Click to change the text</div>
	<input type="button" id="test" value="test" onclick="sendHttpRequest('test');"/>

*/
//-->
