// =================================================================================
//  school_mailer.js
//   Created 11/19/2008 by Greg Spry
//    Holds javascript specific to form submission
//
// =================================================================================
//  Constants
// =================================================================================

// =================================================================================
// Functions
// =================================================================================
window.addEvent('domready', function() {
	
});

// =================================================================================
function submitSchoolMailerForm(theForm){
	with(theForm){
		if (Name.value == ''){
			alert('Please enter your first and last name.');
			Name.focus();
			return false;
		}
		if (School.value == ''){
			alert('Please enter the name of your school.');
			School.focus();
			return false;
		}
		if (Address.value == ''){
			alert('Please enter your street address.');
			Address.focus();
			return false;
		}
		if (City.value == ''){
			alert('Please enter your city.');
			City.focus();
			return false;
		}
		if (State.value == ''){
			alert('Please enter your state.');
			State.focus();
			return false;
		}
		if (Zip.value == ''){
			alert('Please enter your zip code.');
			Zip.focus();
			return false;
		}
		if (Email.value == ''){
			alert('Please enter your email address.');
			Email.focus();
			return false;
		}
		if (!isValidEmail(Email.value)){
			alert('Please enter a valid email address.\nExample: local@domain.ext');
			Email.focus();
			return false;
		}
	}
	insitePost('ki9eyo-3b09or6ku0', 'schoolMailerForm', 'Email', 'School Safety - New Mailer Request');
	theForm.submit();
}

// =================================================================================
function isValidEmail(stringValue){
	return stringValue.match(/^(\w|-|_|\.)+@(\w|-|_|\.){3,}\.\w{2,5}$/);
}

// =================================================================================
