function createXmlHttp() {
	// Adapted from http://www.w3schools.com/ajax/ajax_serve
	var xmlHttp = null;
	
	try {
		// Firefox, Opera, and Safari
		xmlHttp = new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer 5.0+

		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX");
			}
		}
	}

	return xmlHttp;
}

function doXmlHttp(url, callback, args) {
	var xmlHttp = createXmlHttp();

	if (xmlHttp != null) {
	
		if (callback != null) {
			xmlHttp.onreadystatechange = function() {					
				if (xmlHttp.readyState == 4) {			
					callback(xmlHttp, args);
				}
			}
		}
		
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	} else {
		alert("Your web browser does not support XML HTTP. Please update your browser.");
	}
}

function ajaxUpdateElement(id, url) {
	doXmlHttp(url, ajaxUpdateElementCallback, id);
}

function ajaxUpdateElementCallback(xmlHttp, args) {
	var id = args;
	var doc = document.getElementById(id);
	doc.innerHTML = xmlHttp.responseText;
}
