﻿//global variables to keep track of the request and the function to call when done
var ajaxreq = false, ajaxCallback;

//ajaxRequest: sets up a request
function ajaxRequest(filename) {
	try {
		//Firefox / IE7 / Others
		ajaxreq = new XMLHttpRequest();
	} catch (error) {
		try {
			//IE5 / IE6
			axareq = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (error) {
			return false;
		}
	}
	
	ajaxreq.open("GET", filename);
	ajaxreq.onreadystatechange = ajaxResponse;
	ajaxreq.send(null);
}

//ajaxResponse: Waits for response and calls a function
function ajaxResponse () {
	//if (ajaxreq.readyState < 4) {
	//	gears = document.getElementById("centertext");
	//	gears.innerHTML = "<img src='http://localhost/K-Universal6.0/public_html/css/pics/Gears03.gif'>";
	//}
	if (ajaxreq.readyState == 4) {
		if (ajaxreq.status == 200) {
			//if the request succeeded...
			if (ajaxCallback) {
				ajaxCallback();
			}
		} else alert("Request failed: " + ajaxreq.statusText);
		return true;
	}
}