var errors = 0;

function checkForm() {
	errors = 0;
	$$(".required").each(function(el) {
			if (el.value == "") {
				errors++;
				$(el).setStyle({background: "#FFFFCC" });
			} else {
				$(el).setStyle({background: "#FFFFFF" });
			}
	});
	if (errors > 0) {
		alert("Please enter information in the required fields.");
		return false;
	}
	return true;
}

function checkFormTwo() {
	if (!checkForm())
		return false;
	if ($("email").value != $("cemail").value) {
		alert("Your emails don't match.");
		return false;
	}
	
	if (!isValidEmail($("email").value)) {
		alert("Your email address is not valid.");
		return false;
	}
	
	checks = 0;
	$$("input[type=checkbox]").each(function(el) {
		if (el.checked)
			checks++;
	});
	
	if (checks == 0) {
		alert("Please select at least one thing to register for.");
		return false;
	}
}

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
