// Function to pause for the specified number of milliseconds
function pause(millis) {
	var date = new Date();
	var curDate = null;

	do {
		curDate = new Date();
	} while(curDate-date < millis);
}

// Function to send a GET request via AJAX
function getAjax(url, async) {
	xmlHttp = createAjaxObject();
	
	if (async) {
		xmlHttp.onreadystatechange=function() {
			if(xmlHttp.readyState==4) {
				eval(xmlHttp.responseText);
			}
		}
	}

    xmlHttp.open('GET', url, async); // Set third argument to true for asyncronous calls!
    xmlHttp.send(null);
}

// Function to send a POST request via AJAX
function postAjax(url, parameters, async) {
	xmlHttp = createAjaxObject();
	
	if (async) {
		xmlHttp.onreadystatechange=function() {
			if(xmlHttp.readyState==4) {
				eval(xmlHttp.responseText);
			}
		}
	}
	
    xmlHttp.open('POST', url, async); // Set third argument to true for asyncronous calls!
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", parameters.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(parameters);
}

// Function to create our actual AJAX object based on what browser the user is currently using
function createAjaxObject() {
	var xmlHttp;
	try { // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		return xmlHttp;
	} catch (e) { // Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			return xmlHttp;
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				return xmlHttp;
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
}