// Get the HTTP Object
function getHTTPObject(){

if (window.ActiveXObject) {
	return new ActiveXObject("Microsoft.XMLHTTP");
}else if (window.XMLHttpRequest) {
	return new XMLHttpRequest();
}else {
	alert("Your browser does not support AJAX.");
	return null;
}
}

// Change the value of the outputText field

function setOutput(){

if(httpObject.readyState == 4){

var contacts = eval("(" + httpObject.responseText + ")");

for(var contact in contacts){
	document.getElementById(contact).value = contacts[contact];
}

}
}


// Implement business logic

function fillContacts(){

httpObject = getHTTPObject();

if (httpObject != null) {
	httpObject.open("GET", "/ajax_fill_contacts.php", true);
	httpObject.send(null);
	httpObject.onreadystatechange = setOutput;
	alert(httpObject.responseText);
}
}

var httpObject = null;
