// variable to hold reference to XMLHTTP object
var oHTTP;

function loadTarget(sURL,loc) {
 // create instance of a new XMLHTTP object
 oHTTP = new XMLHttpRequest();//new ActiveXObject("Microsoft.XMLHTTP");
 if (oHTTP != null) {
  // specify callback for loading completion
  oHTTP.onreadystatechange = function () {gotTarget(loc);}
  // open HTTP connection and send async request
  oHTTP.open('GET', sURL, true);
  oHTTP.send();
 }
 else {
  document.getElementById('spnError').innerText 
   = 'ERROR: Cannot create XMLHTTP object to load next page. Your browser may be incompatible.';
 }
}

function gotTarget(loc) {
 // see if loading is complete
 if (oHTTP.readyState == 4) {
  // check if there was an error
  if (oHTTP.status == 200) {
   // dump next page content into this page
		if(loc=="page"){
	   document.write(oHTTP.responseText);
	   }else{
	   document.getElementById('data_replace').innerHTML=oHTTP.responseText;
	   document.getElementById("divWait").style.visibility='hidden';
	   }
  }
  else {
   document.getElementById('spnError').innerText 
    = 'ERROR: Cannot load next page. Server may be too busy.';
  }
 }
}
