var emailRegEx = new RegExp("^[\'_a-z0-9-]+(\\.[\'_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*\\.(([a-z]{2,3})|(aero|coop|info|museum|name|jobs|travel))$");

$(document).ready(function() {
	// Reset the error color.
	$("form#frmSebform").find("input").focus(function() {
		$(this).css("background-color","");
	});

	$("form#frmSebform").find("input").change(function() {
		$(this).css("background-color","");
	});

	$("form#frmSebForm").find("#username").focus();

	// Validate the form.
	$("form#frmSebform").submit(function() {
		var errors = [];
		var errColor = "red";

		object = $(this).find("#username");
		if (object.val().length == 0) {
			errors.push("- The Email field is required.");
			object.css("background-color",errColor)
		}
				
		object = $(this).find("#password");
		if (object.val().length == 0) {
			errors.push("- The Password field is required.");
			object.css("background-color",errColor)
		}

		if (errors.length > 0) {
			var errorMsg = "The following error(s) occurred:";
			for (var counter = 0; counter < errors.length; counter++) {
				errorMsg += "\n" + errors[counter]; 
			}
			alert(errorMsg);
			return false;
		}

		return true;
	});
});