function checkName () {
	var user = $('user').value;
	if (!user.match(/^[a-zA-Z0-9][a-zA-Z0-9_]+$/)) {
		alert('Usernames must start with a letter or number and may underscores but no spaces');
		return;
	}
	if (user.length > 32) {
		alert('Usernames cannot be more than 32 characters long');
		return;
	}
	var request = new Request.JSON({
		url: '/ajax_user_avail.php',
		onComplete: function(username){
			if (username.available) {
				alert('That username is available!');
			}
			else if (username.invalid) {
				alert('That username is invalid');
			}
			else {
				alert('Sorry, that username is taken!');
				$('user').value = '';
			}
		}
	}).get({'u': user});
}
function checkForm() {
	var user = $('user').value;
	if (user == '') {
		alert('You must provide a username');
		return false;
	}
	if (!user.match(/^[a-zA-Z0-9][a-zA-Z0-9_]+$/)) {
		alert('Usernames must start with a letter or number and may underscores but no spaces');
		return false;
	}
	if (user.length > 32) {
		alert('Usernames cannot be more than 32 characters long');
		return false;
	}
	if ($('email').value.length == 0) {
		alert('You must provide your email address');
		return false;
	}
	if ($('email').value != $('emailconfirm').value) {
		alert('Your email does not match your confirmation email');
		$('emailconfirm').value = '';
		$('emailconfirm').focus();
		return false;
	}
	if ($('firstname').value == '' || $('lastname').value == '') {
		alert('Your first and last name are required');
		return false;
	}
	if ($('pass').value.length == 0) {
		alert('You must provide a password');
		return false;
	}
	if ($('pass').value != $('passconfirm').value) {
		alert('Your password does not match your confirmation password');
		$('pass').value = '';
		$('passconfirm').value = '';
		$('pass').focus();
		return false;
	}
	if (!$('genderM').checked && !$('genderF').checked) {
		alert('You must provide your gender');
		return false;
	}
	if (!$('dob_dd').value.match(/^[0-9]+$/) || !$('dob_yyyy').value.match(/^[12]\d+$/)) {
		alert('You must provide your date of birth');
		return false;
	}
	if (!$('tos').checked) {
		alert('You must agree to the Terms & Conditions');
		return false;
	}
	return true;
}