// JavaScript Document

function Request4Validator(theForm)
{

var alertsay = ""; // define for long lines
// alertsay is not necessary for your code,
// but I need to break my lines in multiple lines
// so the code won't extend off the edge of the page

// check to see if the field is blank
if (theForm.salutation.value == "none")
{
	alert("Salutation is required. Please select a valid salutation.");
	theForm.salutation.focus();
	return (false);
}
if (theForm.fname.value.length < 2)
{
	alert("Your first name is required. Please enter a valid first name.");
	theForm.fname.focus();
	return (false);
}
if (theForm.lname.value.length < 2)
{
	alert("Your last name is required. Please enter a valid last name.");
	theForm.lname.focus();
	return (false);
}

// only allow numbers to be entered
if (theForm.phone.value.length < 9)
{
	alert("Your phone number is required.\n Please enter correct telephone numbers (i.e: 123-423-1314).");
	theForm.phone.focus();
	return (false);
}

// check if email field is blank
if (theForm.email.value == "")
{
alert("Please enter a value for the \"Email\" field.");
theForm.email.focus();
return (false);
}

if (theForm.email.value.length < 8)
{
alert("Please enter a valid email. No email address with < 7 characters.");
theForm.email.focus();
return (false);
}

// test if valid email address, must have @ and .
var checkEmail = "@.";
var checkStr = theForm.email.value;
var EmailValid = false;
var EmailAt = false;
var EmailPeriod = false;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkEmail.length;  j++)
{
if (ch == checkEmail.charAt(j) && ch == "@")
EmailAt = true;
if (ch == checkEmail.charAt(j) && ch == ".")
EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
if (EmailAt && EmailPeriod)
{
		EmailValid = true
		break;
	}
}
if (!EmailValid)
{
alert("Please enter a correct email address. It must contain an \"@\" and a \".\".");
theForm.email.focus();
return (false);
}

if (theForm.school.value.length < 5)
{
	alert("School or Institution is required. Please enter a valid name.");
	theForm.school.focus();
	return (false);
}
if (theForm.district.value == "none")
{
	alert("The School District is required. Please select a valid School District.");
	theForm.district.focus();
	return (false);
}
if (theForm.yearteach.value.length < 1)
{
	alert("Number of year (s) teaching is required. Please enter a valid number.\nIf you have been teaching for less than one year please enter 1 for number.");
	theForm.yearteach.focus();
	return (false);
}
if (theForm.gradelevel.value.length < 3)
{
	alert("Grade Level or Subject is required. Please enter a valid Grade Level/Subject.\ni.e.: Elementary School or 6th Grade.");
	theForm.gradelevel.focus();
	return (false);
}


/*
var tuition = false;
for (i = 0; i < theForm.tuitionassist.length-1; i++)
	{
		if (theForm.tuitionassist[i].checked)
			{
				tuition = true;
			}
	}

if  (!tuition == -1)
	{
		alert("Tuition assistance is required Yes or No. Please select one.");
		//theForm.district.focus();
		return (false);
	}

*/
if (theForm.district.value == "none" || theForm.district.value == "")
{
	alert("The School District is required. Please enter a valid School District.");
	theForm.district.focus();
	return (false);
}

/*
if (theForm.typementoring.checked == false) 
	{
		alert ("You did not choose any of the checkboxes for the type of mentoring assistance you will need.");
		theForm.typementoring.focus();
		return false;
	}
*/

if (theForm.date1.value.length < 9 || theForm.date1.value == "add date here")
{
	alert("Date 1 for mentoring services is required. Please enter a valid date.\ni.e.: August 1, 2001 will be 08/01/2001.");
	theForm.date1.focus();
	return (false);
}
if (theForm.time1.value.length < 9)
{
	alert("Time 1 for mentoring services is required. Please enter a valid date.\ni.e.: (7:30 AM to 4:30 PM).");
	theForm.time1.focus();
	return (false);
}
if (theForm.date2.value.length < 9 || theForm.date2.value == "add date here")
{
	alert("Date 2 for mentoring services is required. Please enter a valid date.\ni.e.: August 1, 2001 will be 08/01/2001.");
	theForm.date2.focus();
	return (false);
}
if (theForm.time2.value.length < 9)
{
	alert("Time 2 for mentoring services is required. Please enter a valid date.\ni.e.: (7:30 AM to 4:30 PM).");
	theForm.date1.focus();
	return (false);
}
if (theForm.date3.value.length < 9 || theForm.date3.value == "add date here")
{
	alert("Date 3 for mentoring services is required. Please enter a valid date.\ni.e.: August 1, 2001 will be 08/01/2001.");
	theForm.date3.focus();
	return (false);
}
if (theForm.time3.value.length < 9)
{
	alert("Time 3 for mentoring services is required. Please enter a valid date.\ni.e.: (7:30 AM to 4:30 PM)");
	theForm.time3.focus();
	return (false);
}

if (theForm.reqmentoring.value.length < 10)
{
	alert("A summary for your request is required. \nPlease In three sentences or less, summarize the nature of your request for a SERVS Educator:");
	theForm.reqmentoring.focus();
	return (false);
}

/*
if (theForm.mentor.value == "none" || theForm.mentor.value == "")
{
	alert("Please select a SERVS Educator for your application from the drop down list. \n Or Choose Select a SERVS Educator For Me so we can select one for you base on the information you have provided to us.");
	theForm.mentor.focus();
	return (false);
}
*/

return (true);
// replace the above with return(true); if you have a valid form to submit to
}
