function getXHR() {
  var newReq = null;
  if(window.XMLHttpRequest) {
    try {
       newReq = new XMLHttpRequest();
       if(newReq.overrideMimeType){
         newReq.overrideMimeType('text/xml');
       }
    }catch(e) {
       newReq = false;
    }
  } else if(window.ActiveXObject) {
    try {
       newReq = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
       try {
          newReq = new ActiveXObject("Microsoft.XMLHTTP");
       } catch(e) {
       newReq = false;
       }
    }
  }
  return newReq;
}


var b = null

function xmlhttpHandler(url) {

  xmlhttp = getXHR();
  
  if (xmlhttp) {

    b = url.split("?");
    xmlhttp.open("POST",b[0],true);

    xmlhttp.onreadystatechange = function() {
      // if xmlhttp shows "loaded"
      if (xmlhttp.readyState==4) {
        // if "OK"
        if (xmlhttp.status==200) {
           xmlhttpResponse(xmlhttp.responseXML);    
        }
        //else {
        //  alert("Problem retrieving XML data : response "+xmlhttp.status)
        //}
      } 
    }
  
    if (b.length > 1 ) {
      //Send the proper header information along with the request
      xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlhttp.setRequestHeader("Content-length", b[1].length);
      //xmlhttp.setRequestHeader("Connection", "close");
      xmlhttp.send(b[1]);
    } else {
      xmlhttp.send(null);
    }
  } 
  else {
    alert("Browser doesn't support XMLHTTP protocol");
  }
}

function xmlhttpHandler2(url,el) {

  xmlhttp2 = getXHR();
 
  if (xmlhttp2) {

    b = url.split("?");
    xmlhttp2.open("POST",b[0],true);

    xmlhttp2.onreadystatechange = function() {
      // if xmlhttp shows "loaded"
      if (xmlhttp2.readyState==4) {
        // if "OK"
        if (xmlhttp2.status==200) {
           xmlhttpResponse(xmlhttp2.responseXML,el);    
        }
        //else {
        //  alert("Problem retrieving XML data : response "+xmlhttp2.status)
        //}
      } 
    }
  
    if (b.length > 1 ) {
      //Send the proper header information along with the request
      xmlhttp2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlhttp2.setRequestHeader("Content-length", b[1].length);
      //xmlhttp2.setRequestHeader("Connection", "close");
      xmlhttp2.send(b[1]);
    } else {
      xmlhttp2.send(null);
    }
  } 
  else {
    alert("Browser doesn't support XMLHTTP protocol");
  }
}


