// This document holds all of the JavaScript necessary for validating our registration forms. 

function validEmail (email1) {
	invalidChars = " /:,;"
	if (email1 == "") {
		return false
	}

	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
	if (email1.indexOf(badChar,0) != -1) {
		return false
			}
		}

	atPos = email1.indexOf("@",1)
	
	if (atPos == -1) {
		return false
	}
	
	if(email1.indexOf("@",atPos+1) != -1) {
		return false
	}
	
	periodPos = email1.indexOf(".",atPos)
	if (periodPos == -1) {
		return false
	}

	if (periodPos+3 > email1.length) {
		return false
	}

	return true
}

function submitIt(form) {
if (form.visitor_first_name.value=="") {
	alert("Please enter your first name.")
	form.visitor_first_name.focus()
	form.visitor_first_name.select()
	return false
}
if (form.visitor_last_name.value=="") {
	alert("Please enter your last name.")
	form.visitor_last_name.focus()
	form.visitor_last_name.select()
	return false
}
if (form.company.value=="") {
	alert("Please enter your company name.")
	form.company.focus()
	form.company.select()
	return false
}
if (form.phone.value=="") {
	alert("Please enter your phone number.")
	form.phone.focus()
	form.phone.select()
	return false
}
if (!validEmail(form.email.value)) {
	alert("Please enter a valid email address.")
	form.email.focus()
	form.email.select()
	return false
}
if (!form.AgreeToTerms.checked) {
	alert("Please agree to receive mailings before submitting this form.")
	return false
}
return true
}