///////////////////////////////////////////
function validateRequestType(theForm)
///////////////////////////////////////////
{	
	for (i = 0;  i < theForm.request_type.length;  i++)
	{
		if(theForm.request_type[i].checked == true)
		{
			theForm.subject.value = "CE 8.0 Live Class Request:  *" + theForm.LastName.value  + ", " + theForm.FirstName.value + "* " + theForm.request_type[i].value;
			return true;
		}
	}
	alert("Please select the category that best describes the nature of your help request.");
	return false;
}

///////////////////////////////////////////
function formatFormFields(theForm)
///////////////////////////////////////////
{	
	//clean up the unused select fields
	for (i = 0;  i < 4;  i++)
	{
		var formMethod = "Method" + i;
		var formLength = "Length" + i;
		var formSubject = "Subject" + i;
		var formCourseN = "CourseNumber" + i;
		
		if(isEmptyString(document.getElementsByName(formSubject)[0].value) && isEmptyString(document.getElementsByName(formCourseN)[0].value))
		{
			document.getElementsByName(formMethod)[0].selectedIndex=4;
			document.getElementsByName(formLength)[0].selectedIndex=3;
		}
	}
	//clear the duplicate values so they don't show on the form
	theForm.WebCT_ID2.value="";
	theForm.Email2.value="";
}


///////////////////////////////////////////
function facultyAssistantValidator(theForm)
///////////////////////////////////////////
{	
	//validate first name
	if(!validateFirstName(theForm)) return false;
	
	//validate last name
  	if(!validateLastName(theForm)) return false;
  	
	//validate WebCT ID fields (WebCT_ID & WebCT_ID2)
  	if(!isWebCTIDValid(theForm)) return false;

	//validate email address
  	if(!validateFieldInput(theForm.Email, "Email", 7, 30)) return false;
	
	//validate email retype
  	if(!validateFieldInput(theForm.Email2, "Email Retype", 7, 30)) return false;
  	
  	//more email validation
  	if(!isEmailValid(theForm)) return false;
  	
	//validate phone number
  	if(!validatePhoneNumber(theForm)) return false;
	
	//validate request type (radio buttons)
	if(!validateRequestType(theForm)) return false;

	//format select fields
	formatFormFields(theForm);

}