$(function() {
	$('#submit').bind('click', function() {
		try {
			$('#name_of_player, #name_of_coach, #college, #team, #telephone_number, #location, #email, #email_confirmation, #message').each(function() {
				if (this.value == '') {				
					var elementLabelText = $('label[for=' + this.id + ']').text().replace(/[ ]*:[ ]*/g, '');
					throw('Please fill out the "' + elementLabelText + '" field.');
					return false;
				}
			});
			
			if ($.trim($('#email').get(0).value) != $.trim($('#email_confirmation').get(0).value)) {
				throw ('Error: email address mismatch.'); 			
			}
			
			if ($.trim($('#email').get(0).value).search(/^[A-Z0-9.+]+@[A-Z0-9.+]+$/gi)==-1) {
				throw ('Please enter a valid email address.');			
			}

		}
		catch (e) {
			alert(e);
			return false;
		}
		return true;
	});
});
