function checkUsernameExists(usernameTextBox){
	username = usernameTextBox.value;
	if (username != "" && username != undefined){
		
		$.ajax({ 
			url: "scr_checkUsername.php?username="+username, 
			success: function(msg){
				if (msg == "1"){
					// exists
					$("#errors").get(0).innerHTML = "Username " + username + " already exists";
					$("#errors").get(0).style.visibility = "visible";
					usernameTextBox.style.backgroundColor="#ffc5bf";
					_exU = true;
				}else{
					$("#errors").get(0).innerHTML = "";
					$("#errors").get(0).style.visibility = "hidden";
					usernameTextBox.style.backgroundColor="#ffffff";
					_exU = false;
				}
			}
		});
	}
}

function checkEmailExists(emailTextBox){
	email = emailTextBox.value;
	$.ajax({ 
		url: "scr_checkEmail.php?email="+email, 
		success: function(msg){
			if (msg == "1"){
				// exists
				$("#errors").get(0).innerHTML = "An account with this email already exists";
				$("#errors").get(0).style.visibility = "visible";
				emailTextBox.style.backgroundColor="#ffc5bf";
				_exE = true;
			}else{
				$("#errors").get(0).innerHTML = "";
				$("#errors").get(0).style.visibility = "hidden";
				emailTextBox.style.backgroundColor="#ffffff";
				_exE = false;
			}
		}
	}); 
}

/*
function checkUsernameExists(usernameTextBox){
	username = usernameTextBox.value;
	if (username != "" && username != undefined){
		dojo.xhrPost({
			url: "scr_checkUsername.php?username="+username,
			handleAs: "text",
			load: function(response){
				if (response == "1"){
					// exists
					dojo.byId("errors").innerHTML = "Username " + username + " already exists";
					dojo.byId("errors").style.visibility = "visible";
					usernameTextBox.style.backgroundColor="#ffc5bf";
					_exU = true;
				}else{
					dojo.byId("errors").innerHTML = "";
					dojo.byId("errors").style.visibility = "hidden";
					usernameTextBox.style.backgroundColor="#ffffff";
					_exU = false;
				}
			},
			error: function(error){
				//alert(error);
			}
		}); 
	}
}

function checkEmailExists(emailTextBox){
	email = emailTextBox.value;
	if (email != "" && email != undefined){
		dojo.xhrPost({
			url: "scr_checkEmail.php?email="+email,
			handleAs: "text",
			load: function(response){
				if (response == "1"){
					// exists
					dojo.byId("errors").innerHTML = "An account with this email already exists";
					dojo.byId("errors").style.visibility = "visible";
					emailTextBox.style.backgroundColor="#ffc5bf";
					_exE = true;
				}else{
					dojo.byId("errors").innerHTML = "";
					dojo.byId("errors").style.visibility = "hidden";
					emailTextBox.style.backgroundColor="#ffffff";
					_exE = false;
				}
			},
			error: function(error){
				//alert(error);
			}
		}); 
	}	 
}

*/
