//
// Callback function that dumps the response data into a DOM element.
//
function my_callback(div_id, response)
{
	document.getElementById(div_id).innerHTML = response;
}


//
// Send a request to the web server for a snippet of HTML.
//
function send_request(url, div_id, callback)
{
	function bind_callback() {
		if (http_req.readyState == 4) {
			if (http_req.status == 200) {
				if (http_callback) {
					http_callback(div_id, http_req.responseText);
				} else {
					alert('No callback defined!');
				}
			} else {
				alert("There was a problem retrieving the data...");
			}
		}
	}

	var http_req = null;
	var http_callback = callback;

	if (window.XMLHttpRequest) {
		http_req = new XMLHttpRequest();
	} else {
		http_req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	http_req.onreadystatechange = bind_callback;

	http_req.open("GET", url, true);
	http_req.send(null);
}

