
var xmlhttp = new createRequest();

function createRequest() {	
	var xmlhttp;
	
	try {
		xmlhttp = new XMLHttpRequest();
	}
	catch (e) {
		xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
	}
	if (!xmlhttp) 
		alert("Error creating Request object");
	else
		return xmlhttp;
}

function pullAllData() {
	if(xmlhttp) {
		try {
			xmlhttp.open("GET","allprojectsjx.php"	,true);
			xmlhttp.onreadystatechange = stateChange;
			xmlhttp.send(null);
		}
		catch(e) {
			alert("Can't connect to server:\n"+e.toString());
		}
	} else {
		alert('no xmlhttp');
	}
}

function stateChange() {
	if(xmlhttp.readyState == 4) {
		if(xmlhttp.status == 200) {
			try {
				showData();
			}
			catch(e) {
				alert('Error Message: '+e);			
			}
		}
	}
}

function showData() {
	var response = xmlhttp.responseText;
	if(!response || (response == 'error'))
		throw("Error connecting to the database!");
	
	createOverlay(response);
}
	
