//	Performs the validation of the Living History form (used for suggesting a topic)
//	Must be included after the communfunctions.js file.
//
//	Returns:
//	false:	If any validation fails.
//	true:	If validation passes.
//
//	20041021. SS. TPR 257. Changed email validation message.
//	20041021. SS. TPR 280. Validate email invalid characters.

function validateLivingHistoryTopicForm()
{
	var form = document.LivingHistoryTopicForm;
	var formtopic = form.topic;
	var formemail = form.email;
	var bReturn = true;
	var bEmpty = false;
	var sErrorMessage = "";
	var bIsNav = true;
	
	bIsNav = isNav4();
	if (bIsNav) {
 		return true;
	}
	
	// Determine if value is entered
	bEmpty = isEmptyNoSpace(formtopic);

	if(bEmpty)
	{
		bReturn = false;
		alert("I'm sorry, you cannot complete this form unless all the mandatory information "
				+ "(marked with a red asterix) is complete. Please enter your topic name.");
		chgFocus(formtopic);
	} // End if
	
	// Determine if 
	if(bReturn)
	{
		if(!isValidLength(formtopic, 1))
		{
			bReturn = false;
			alert("I'm sorry, you have not supplied enough letters or numerals for this form. "
				+ "Please enter at least one character for the topic");
			chgFocus(formtopic);
		} // End if
	} // End if
	
	// Determine if text area field contains 
	if(bReturn)
	{
		sErrorMessage = validateName(formtopic);
		
		bReturn = (sErrorMessage == "");
		
		if(!bReturn)
		{
			alert(sErrorMessage);
			chgFocus(formtopic);
		} // End if
	} // End if
	
		// Determine field length
	if(bReturn)
	{
		bReturn = isValidLength(formtopic, 80);
		
		if(!bReturn){
			bReturn = true;
		}
		else
		{
			alert("I'm sorry, you have supplied too many letters or numerals for the topic."
					+ " This field can only contain a maximum of 80 characters. Please try again.");
			chgFocus(formtopic);
			bReturn = false;
		}	
	}	
	
	//validate email field
		bEmpty = isEmptyNoSpace(formemail);

	if(bEmpty && bReturn)
	{
		bReturn = false;
		alert("I'm sorry, you cannot complete this form unless all the mandatory information "
				+ "(marked with a red asterix) is complete. Please enter your email address.");
		chgFocus(formemail);
	} // End if
	
	if(bReturn) 
	{
		sErrorMessage = validateEmail(formemail);

		if(sErrorMessage != "")
		{
			alert (sErrorMessage);
			bReturn = false;
			chgFocus(formemail);
		 }	
	}
	
	return bReturn;
	
	
} // End validateLivingHistoryTopicForm
