/*  Script code that reads updated information and changes the page.
    Based on Rasmus Lerdorf's "30 second AJAX" example */

function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if (browser == "Microsoft Internet Explorer") {
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else {
		ro = new XMLHttpRequest();
	}
	return ro;
}

function sendRequest(page, element) {
	var http = createRequestObject();

	// We are appending the GET request with the time to avoid an IE6 cache bug
	var d = new Date();
	var time = d.getTime();
			
	http.open('GET', page + '?time=' + time);
			
			
	//http.targetElement = element; - there is no 'targetElement' property
			
			
	/* We have to use a closure for this, because it is a property
	   and not a method, so 'this' doesn't actually point to http
	   inside it.  Thanks, Microsoft. */
		
	http.onreadystatechange = function () {
		if (http.readyState == 4
		    && http.status == 200) {
					
			// this made IE6 asplode, as XMLHttpRequest objects don't have "targetElement"
			//document.getElementById(http.targetElement).innerHTML = http.responseText;
					
					
			document.getElementById(element).innerHTML = http.responseText;
					
					
			/* Remove this closure to avoid memory leaks. */
			// can't set "onreadystate" to null w/o IE exploding... use empty function
			http.onreadystatechange = function (){ /*null for IE6*/ };
		}
	}
	d = time = null;
	http.send(null);
}

