// JavaScript Document
function validEmail(Email) {
	invalidChars = " /:;";
	
	//cannot be empty, cannot have default value
	if (Email == "" || Email == "you@somewhere.com") {
		return false;
	}
	//cannot contain any invalid characters
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i);
		if (Email.indexOf(badChar,0) > -1) {
			return false;
		}
	}
	atPos = Email.indexOf("@",1);
	//must contain one "@" symbol
	if (atPos == -1) {
		return false;
	}
	//and only one "@" symbol
	if (Email.indexOf("@",atPos+1) != -1) {
		return false;
	}
	periodPos = Email.indexOf(".",atPos);
	//and at least one "." after the "@"
	if (periodPos == -1) {
		return false;
	}
	//must be at least 2 characters after the "."
	if (periodPos+3 > Email.length) {
		return false;
	}
	//email is OK
	return true;
}
function submitIt(form01) {
	//name field cannot be empty
	if (form01.FullName.value == "") {
		alert("Please enter your name");
		form01.FullName.focus();
		form01.FullName.select();
		return false;
	}
	//address field cannot be empty
	if (form01.StreetAddress.value == "") {
		alert("Please enter your address");
		form01.StreetAddress.focus();
		form01.StreetAddress.select();
		return false;
	}
	//city field cannot be empty
	if (form01.City.value == "") {
		alert("Please enter your city");
		form01.City.focus();
		form01.City.select();
		return false;
	}
	//state field cannot be empty
	if (form01.State.value == "") {
		alert("Please enter your state or province");
		form01.State.focus();
		form01.State.select();
		return false;
	}
	//zip postal field cannot be empty
	if (form01.ZipCode.value == "") {
		alert("Please enter your zip or posal code");
		form01.ZipCode.focus();
		form01.ZipCode.select();
		return false;
	}
	//country field cannot be empty
	if (form01.Country.value == "") {
		alert("Please enter your country");
		form01.Country.focus();
		form01.Country.select();
		return false;
	}
	//email must be OK
	if (!validEmail(form01.Email.value)) {
		alert("Please enter your e-mail address");
		form01.Email.focus();
		form01.Email.select();
		return false;
	}
	//phone field cannot be empty
	if (form01.HomePhone.value == "") {
		alert("Please enter your home phone number");
		form01.HomePhone.focus();
		form01.HomePhone.select();
		return false;
	}
	//start date field cannot be empty
	if (form01.DateTripStarts.value == "") {
		alert("Please enter the date your trip starts");
		form01.DateTripStarts.focus();
		form01.DateTripStarts.select();
		return false;
	}
	//arrival time field cannot be empty
	if (form01.ApproximateArrivalTime.value == "") {
		alert("Please enter your approximate arrival time");
		form01.ApproximateArrivalTime.focus();
		form01.ApproximateArrivalTime.select();
		return false;
	}
	//end date field cannot be empty
	if (form01.DateTripEnds.value == "") {
		alert("Please enter the date your trip ends");
		form01.DateTripEnds.focus();
		form01.DateTripEnds.select();
		return false;
	}
	//must have either men or women or both
	if  ((form01.NumberofMales.value == "") && (form01.NumberofFemales.value == ""))  {
		alert("Someone must be going on this trip!  Please enter the number of males and/or females");
		form01.NumberofMales.focus();
		form01.NumberofMales.select();
		return false;
	}
	// if males, enter ages
	if ((form01.NumberofMales.value != "") && (form01.MalesAges.value == "")) {
		alert("Please enter the age(s) of the male(s) attending");
		form01.MalesAges.focus();
		form01.MalesAges.select();
		return false;
	}
	// if females, enter ages
	if ((form01.NumberofFemales.value != "") && (form01.FemalesAges.value == "")) {
		alert("Please enter the age(s) of the female(s) attending");
		form01.FemalesAges.focus();
		form01.FemalesAges.select();
		return false;
	}
	// how found
	HowDidYouFindOurWebsiteFlag = -1;
	for (i=0; i<form01.HowDidYouFindOurWebsite.length; i++) {
		if (form01.HowDidYouFindOurWebsite[i].checked) {
			HowDidYouFindOurWebsiteFlag = i;
		}
	}
	if (HowDidYouFindOurWebsiteFlag == -1) {
		alert("Please tell us how you found our website");
		return false;
	}
	//if chose Other
	if  ((form01.HowDidYouFindOurWebsite[3].checked) && (form01.FindOther.value == "")) {
		alert("Please explain Other");
		form01.FindOther.focus();
		form01.FindOther.select();
		return false;
	}
	
	
	
	
	
	
	
	//OK so return true
	return true;
}