var response;
var request = false;      // The object to handle the request for data
var reqType = "GET";      // Make the request type a GET as opposed to a POST
var url = "http://www.boonevilleairport.com/wrespond.php";
var url = "/wrespond.php";
var asynch = true;        // Make this an asynchronous request
var interval = 1000 * 60; // Update the page at 60 second intervals

function getData() {    

   // Do the first request, then    
   httpRequest();

   // send the request at intervals
   setInterval(httpRequest, interval);
}

function httpRequest() {

   if (document.images) {
//       document.images.weathercam.src='http://www.magtelwireless.com/bnvlairweather/weather.jpg?'+new Date().getTime(); 
       document.images.weathercam.src='http://69.29.96.8/bnvlairweather/weather.jpg?'+new Date().getTime(); 
    }


   if (document.images) {
//       document.images.weathercam2.src='http://www.magtelwireless.com/bnvlairweather/weather2.jpg?'+new Date().getTime(); 
       document.images.weathercam2.src='http://69.29.96.8/bnvlairweather/weather2.jpg?'+new Date().getTime(); 
    }
   if (document.images) {
//       document.images.weathercam3.src='http://www.magtelwireless.com/bnvlairweather/weather3.jpg?'+new Date().getTime(); 
       document.images.weathercam3.src='http://69.29.96.8/bnvlairweather/weather3.jpg?'+new Date().getTime(); 
    }



   try {
     request = new XMLHttpRequest();
     reqtyp = "XMLHttpRequest";
   } catch (trymicrosoft) {
     try {
       request = new ActiveXObject("Msxml2.XMLHTTP");
       reqtyp = "Msxml2.XMLHTTP";
     } catch (othermicrosoft) {
       try {
         request = new ActiveXObject("Microsoft.XMLHTTP");
         reqtyp = "Microsoft.XMLHTTP";
       } catch (failed) {
         request = false;
         reqtyp = "request object not set";
       }  
     }
   }

   if(request) {
      initReq(reqType,url,asynch); // Initialize the request 
   } else {
      alert("Your browser does not permit the use of all "+ 
      "of this application's features!");
   }

}

function initReq(reqType,url,bool) { 
   var urlToSend = url + "?key=ms" + new Date().getTime(); 
   request.open(reqType, urlToSend, bool); 
   request.onreadystatechange = handleResponse; 
   request.send(null);
}

function handleResponse() { 
   if(request.readyState == 4) { 
       if(request.status == 200) { 
          var doc = request.responseXML; 
          displayDocInfo(doc); 
       } else { 
/*
          alert("A problem occurred with communicating between the " 
          + "XMLHttpRequest object and the server program."); 
          alert("request.status = " + request.status); 
          alert("request type = " + reqtyp);
*/
     } 
   }
}

function displayDocInfo(doc) { 
   var root = doc.documentElement; 
   var nds; 
   var thisTag; 

   if(root.hasChildNodes()) { 
       nds=root.childNodes; 
       for (var i = 0; i < nds.length; i++){ 

          thisTag = document.getElementById(nds[i].nodeName); 

          if (thisTag) { 
             if(nds[i].hasChildNodes){ 
                thisTag.innerHTML = nds[i].firstChild.nodeValue; 
             } else { 
                thisTag.innerHTML = " "; 
             } 
          } 
       } 
   } 
   return;
}


