function handleHttpResponseSignup() { 
	if (http.readyState == 4) { 
		// Split the comma delimited response into an array  
		results = http.responseText.split(","); 
		if (results[0] == "username") {
			if (results[1] != "") {
				document.getElementById('userCHK').innerHTML = "Sorry, that's taken!"; 
				document.getElementById("Username").style.backgroundColor = "#ff0000";
			} else {
				document.getElementById('userCHK').innerHTML = "Username is OK"; 
				document.getElementById("Username").style.backgroundColor = "#ffffff";
			}
		} else if (results[0] == "email") {
			if (results[1] != "") {
				document.getElementById('emailCHK').innerHTML = "Sorry, already used.";
				document.getElementById("email").style.backgroundColor = "#ff0000";
			} else {
				document.getElementById('emailCHK').innerHTML = "Email is OK";
				document.getElementById("email").style.backgroundColor = "#ffffff";
			}
		}	
	} 
}

function checkEmail() {
	var url = "checkFields.php?op="; // The server-side script 
	var getEmail = document.getElementById("email").value;
	var urlToGo = url+"email&baba="+getEmail;
	http.open("GET", urlToGo, true); 
	http.onreadystatechange = handleHttpResponseSignup; 
	http.send(null);

}

function checkUsername() {
	var url = "checkFields.php?op="; // The server-side script 
	var getUsername = document.getElementById("Username").value;
	var urlToGo = url+"username&baba="+getUsername;
	http.open("GET", urlToGo, true); 
	http.onreadystatechange = handleHttpResponseSignup; 
	http.send(null);
}

function getHTTPObject() { 
	var xmlhttp; 
	/*@cc_on 
	@if (@_jscript_version >= 5) 
		try { 
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
		} catch (e) { 
			try { 
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
			} catch (E) { 
				xmlhttp = false; 
			} 
		} 
	@else 
		xmlhttp = false; 
	@end 
	@*/ 
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { 
		try { 
			xmlhttp = new XMLHttpRequest(); 
		} catch (e) { 
			xmlhttp = false; 
		} 
	} 
	return xmlhttp; 
} 

var http = getHTTPObject(); // We create the HTTP Object
