/* form validation */
	function validEmail(email) {				// checking for valid email address
		invalidChars = " /:,;"
	
		if (email == "") {						// cannot be empty
			return false
		}
		for (i=0; i<invalidChars.length; i++) {	// any invalid characters?
			badChar = invalidChars.charAt(i)
			if (email.indexOf(badChar,0) > -1) {
				return false
			}
		}
		atPos = email.indexOf("@",1)			// there must be one "@" symbol
		if (atPos == -1) {
			return false
		}
		if (email.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
			return false
		}
		periodPos = email.indexOf(".",atPos)
		if (periodPos == -1) {					// and at least one "." after the "@"
			return false
		}
		if (periodPos+3 > email.length)	{		// at least 2 chars after the "."
			return false
		}
		return true
	}

	function isNum(passedVal) {					// Is this a number?
		if (passedVal == "") {
			return false
		}
		for (i=0; i<passedVal.length; i++) {
			if (passedVal.charAt(i) < "0") {
				return false
			}
			if (passedVal.charAt(i) > "9") {
				return false
			}
		}
		return true
	}

	function validZip(inZip) {					// Is this a valid Zip code?
		if (inZip == "") {
			return true
		}
		if (isNum(inZip)) {						// Check if Zip is numeric
			return true
		}
		return false
	}
	
	function isFilled(myField) {
		// check to see if all required fields are filled
		if (myField == "") {return false} else {return true}
	}
	
	function submitIt(form1) {

		// check to see if req'd fields are filled
		if (!isFilled(form1.first_name.value)) {
			alert("Please enter your first name.")
			form1.first_name.focus()
			return false
			}
		if (!isFilled(form1.last_name.value)) {
			alert("Please enter your last name.")
			form1.last_name.focus()
			return false
			}
		if (!isFilled(form1.title.value)) {
			alert("Please enter your title.")
			form1.title.focus()
			return false
			}
		if (!isFilled(form1.school_name.value)) {
			alert("Please enter your school name.")
			form1.school_name.focus()
			return false
			}
		if (!isFilled(form1.addr_1.value)) {
			alert("Please enter your street address.")
			form1.addr_1.focus()
			return false
			}
		if (!isFilled(form1.city.value)) {
			alert("Please enter your city.")
			form1.city.focus()
			return false
			}
		if (!isFilled(form1.state.value)) {
			alert("Please enter your state.")
			form1.state.focus()
			return false
			}
		// Alert box, in case the zip is empty
		if (form1.zip.value == "") {			
			alert("You must enter a Zip code")
			form1.zip.focus()
			return false
		}
		// Alert box, in case the zip is invalid
		if (!validZip(form1.zip.value)) {		
			alert("That is an invalid Zip code")
			form1.zip.focus()
			form1.zip.select()
			return false
		}
		if (!isFilled(form1.phone.value)) {
			alert("Please enter your phone number.")
			form1.phone.focus()
			return false
			}
		// check to see if the email is valid
		if (!validEmail(form1.submit_by.value)) {
			alert("Invalid email address.")
			form1.submit_by.focus()			// Goes back to the email address box
			form1.submit_by.select()			// Highlights incorrect info
			return false
		}
		// If we made it to here, everything's valid, so return true
		return true
	}