function verifyEntries()
{

	var first_name = false;
	var last_name = false;
	var email = false;

	if (document.frmComments.txtFirstName.value != "")
		{
			first_name = true;
			hideElement("firstNameError");
		}
	else {
			showElement("firstNameError", "Sorry, the First Name field is blank. try again");
			errorFocus = "first_name";
			document.frmComments.txtFirstName.focus();
		}
		
	if (document.frmComments.txtLastName.value != "")
		{
			last_name = true;
			hideElement("lastNameError");
		}
	else {
			showElement("lastNameError", "Sorry, the Last Name field is blank. try again");		
			errorFocus = "last_name"
			document.frmComments.txtLastName.focus();
		}
				
	if (validEmail())
		{
			email = true;
		}
		
	if (first_name == true && last_name == true && email == true)
		{	
			return true;
		}
	
	return false;
}

function showElement(elementId, errorMessage)
{
	
	// This function is used to display error messages when an invalid entry has been entered.
	
	// Argument Explanation
	// elementId refers to the error message element ie. <span id=""> that should be displayed.
	// the elementId's visibility is set to "visible" and the position is set to relative.
	// the errorMessage being passed is the text that should be displayed when an invalid entry has been made
	
	// In some case, the errorMessage should not be used to change the text of a particular element ie. taxYears
	// in these cases the errorMessage being passed is "leave".
	// When an errorMessage is not equal to "leave" the error message should be changed
	
	if (errorMessage != "leave")
	{
		document.getElementById(elementId).innerHTML = errorMessage;
	}
	
	
	// set passed elementId visibility to visible & position to absolute
	
	document.getElementById(elementId).style.visibility = "visible";
	document.getElementById(elementId).style.position = "relative";

}

function hideElement(elementId)
{
	// set passed element visibility to hidden & position to absolute
	
	document.getElementById(elementId).style.visibility = "hidden";
	document.getElementById(elementId).style.position = "absolute";

}

function validEmail()
{
	// This function is used to check if a valid E-mail address has been entered. 
	
	// set default E-mail error Message
	errorMessage = "Sorry, the E-mail Address you entered is invalid. try again";
	
	var email = document.frmComments.txtEmail.value;
	
	// A valid e-mail address cannot have a "." as it's first character. E-mail addresses must also contain an "@" 
	
   	if (email.indexOf(".") < 2 || email.indexOf("@") <  1)
	{
		// set the error message, e-mail is invalid
		showElement("emailError", errorMessage);
		
		// set focus to E-mail address textbox
		document.frmComments.txtEmail.focus();
		return false;
	}
	
	else
	{	
		// hide e-mail error, the e-mail address is correct
		hideElement('emailError');
		return true;
	}
	
	return false;

}
