// I'm not a JavaScript expert, but this is the basic code that makes
// AJAX work. I wish I could attribute this code to someone, but I can't
// re-find my source.  Also, there is probably a lot of cruft.

// There is no need to edit this file.

var page = "physical_DOM.php";
function ajax(url,target)
 {
    // native XMLHttpRequest object
   document.getElementById(target).innerHTML = '';
   if (window.XMLHttpRequest) {
       req = new XMLHttpRequest();
       req.onreadystatechange = function() {ajaxDone(target);};
       req.open("GET", url, true);
       req.send(null);
   // IE/Windows ActiveX version
   } else if (window.ActiveXObject) {
       req = new ActiveXObject("Microsoft.XMLHTTP");
       if (req) {
           req.onreadystatechange = function() {ajaxDone(target);};
           req.open("GET", url, true);
           req.send();
       }
   }
	 // this determines the amount of time in milliseconds that the page
	 // should wait before refreshing. Try adjusting this number to optimize
	 // your results
	 setTimeout("ajax(page,'target')", 500);
}

function ajaxDone(target) {
   if (req.readyState == 4) {
       if (req.status == 200 || req.status == 304) {
           results = req.responseText;
           // this is the important line that updates the background color
					 // results contains the string that is echoed in the PHP script
					 document.body.style.background=results;
       } else {
           document.getElementById(target).innerHTML="ajax error:\n" +
               req.statusText;
       }
   }
}