$(document).ready(function() {
	$("#entry-email, #entry-name").focus(function() { $(this).val(''); });
	$("#lotto-entry-form").submit(function() {
		if ($.trim($("#lotto-entry-form input:text").val()).length>2) {
			if ($("#entry-name").val().search("Your full name")<0) {
				if ($("#entry-email").val().search("Your email")<0) {
					var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
					if (emailReg.test($("#entry-email").val())) {
						return true;
					}
					else {
						$("#errormsg").html('Invalid email address.');
						$("#entry-email").focus();
						return false;
					}
				}
				else {
					$("#errormsg").html('Invalid email address.');
					$("#entry-email").focus();
					return false;
				}
			}
			else {
				$("#errormsg").html('You must enter in your full name.');
				$("#entry-name").focus();
				return false;
			}
		}
		else {
			$("#errormsg").html('You must fill both your name and email.');
			$("#entry-name").focus();
			return false;
		}
	});
});
