function checkForm(form_id){
	var form = $(form_id);
	var inputs = form.getElementsByTagName('input');
	var selects = form.getElementsByTagName('select');
	
	for (var i=0; i < inputs.length; i++) {
		if (inputs[i].className == "text req" || inputs[i].className == "required") { // A required field
			if (inputs[i].value == "") {
				alert("'" + inputs[i].title + "' is a required field.");
				inputs[i].className = 'required';
				inputs[i].focus();
				return false;
			}else if(inputs[i].value != ""){
				if (inputs[i].className == "required") {
					inputs[i].className = "text req";
				};
				
				if (inputs[i].id == "email") {
					if (validateEmail(inputs[i].value) == false) {
						alert("A Valid E-Mail Address is Required.")
						inputs[i].focus();
						inputs[i].className = "required";
						return false;
					};
				};
			};
		};
	};
	
	for (var j=0; j < selects.length; j++) {
		if (selects[j].className == "select req" || selects[j].className == "required") {
			
			if (selects[j].value == "NULL") {
				alert("'" + selects[j].title + "' is a required selection.");
				selects[j].className = 'required';
				selects[j].focus();
				return false;
			}else if( selects[j].value != "NULL" && selects[j].className == "required" ){
				selects[j].className = "select req";
			};
			
		};
	};
	
	return true;
}

function validateEmail(incoming) {
	var emailstring = incoming;
	var ampIndex = emailstring.indexOf("@");
	var afterAmp = emailstring.substring((ampIndex + 1), emailstring.length);
		// find a dot in the portion of the string after the ampersand only
	var dotIndex = afterAmp.indexOf(".");
		// determine dot position in entire string (not just after amp portion)
	dotIndex = dotIndex + ampIndex + 1;
		// afterAmp will be portion of string from ampersand to dot
	afterAmp = emailstring.substring((ampIndex + 1), dotIndex);
		// afterDot will be portion of string from dot to end of string
	var afterDot = emailstring.substring((dotIndex + 1), emailstring.length);
	var beforeAmp = emailstring.substring(0,(ampIndex));
	var email_regex = /^\w(?:\w|-|\.(?!\.|@))*@\w(?:\w|-|\.(?!\.))*\.\w{2,3}/ 
		// index of -1 means "not found"
	if ((emailstring.indexOf("@") != "-1") &&
		(emailstring.length > 5) &&
		(afterAmp.length > 0) &&
		(beforeAmp.length > 1) &&
		(afterDot.length > 1) &&
		(email_regex.test(emailstring)) ) {
		  return true;
	} else {
			return false;
	}
}