﻿// var response = null;

function loadXMLDoc(url) 
{
// alert("in 1");
// code for Mozilla, etc.
if (window.XMLHttpRequest)

  { // alert("in 2");
  xmlhttp=initXMLHTTPRequest();
  xmlhttp.onreadystatechange=onResponse;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }

// code for IE

else if (window.ActiveXObject)
  { // alert("in 3");
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    if (xmlhttp)
    {
    xmlhttp.onreadystatechange=onResponse;
    xmlhttp.open("GET",url,true);
    xmlhttp.send();
    }
  }
}

function initXMLHTTPRequest(){

   var xRequest=null;
   if (window.XMLHttpRequest){
      xRequest=new XMLHttpRequest();
   } else if (window.ActiveXObject){
      xRequest=new ActiveXObject("Microsoft.XMLHTTP");
   }
   // xRequest.overrideMimeType('text/xml');
   if (xRequest.overrideMimeType) {
      xRequest.overrideMimeType('text/xml');
   }
   return xRequest;

}

function checkReadyState(obj)
{
 if(obj.readyState == 4)
  {
    if(obj.status == 200)
    {
      return true;
    }
    else
    {
      alert("Problem retrieving XML data\n\nObject Status: " + obj.status + "  " + obj.StatusText);
    }
  }
}


function onResponse() 
{

  if(checkReadyState(xmlhttp))
  {
   var response = xmlhttp.responseXML.documentElement;
  // return response;
  // alert("pre process");
    processXML(response);
	} // end if

} // end function




