<!-- Begin

function Field_Validator(theForm)
{
	if (theForm.firstname.value == "")
	{
		alert("Please enter your first name.");
		theForm.firstname.focus();
		return (false);
	}
		
	
	if (theForm.lastname.value == "")
	{
		alert("Please enter your last name.");
		theForm.lastname.focus();
		return (false);
	}
	
	if (theForm.street.value == "")
	{
		alert("Please enter your address.");
		theForm.street.focus();
		return (false);
	}

	if (theForm.city.value == "")
	{
		alert("Please enter your city.");
		theForm.city.focus();
		return (false);
	}

	if (theForm.zip.value == "")
	{
		alert("Please enter your zip code.");
		theForm.zip.focus();
		return (false);
	}

	if (!(VerifyZipCode(theForm.zip)))
	    return (false);
	        

	if (theForm.email.value == "")
	{
		alert("Please enter your email address.");
		theForm.email.focus();
		return (false);
	}

	if (!(VerifyEmailAddress(theForm.email)))
	    return (false);
	
	return (true);
}


		

function VerifyEmailAddress(EmailForm)
{
  var Reason  = "Email Address entered incorrectly. \n\nReason:"
  var checkStr = EmailForm.value;
  var ix = (checkStr.length - 4)
  var RC = true;
  var MissingDomainName = MissingUserName = 0
  var CharsInValid = AtSignValid = DoublePeriod = PeriodValid = SpaceValid = ExtValid = RL = 0;
  var at_position = x = 99;
	for (i = 0;  i < checkStr.length;  i++)
	{
		if (checkStr.charAt(i) == '@')
		{
			at_position = i;
			AtSignValid++;
			if (at_position == 0)
				MissingUserName++;
		}
		else if (checkStr.charAt(i) == '.')
		{
			if (x == (i-1)){
				DoublePeriod++;
			}
			else
			{
				x = i;
				PeriodValid++;
				if (at_position == (i-1)){
					MissingDomainName++;
					}
			}
		}
		else
		{
			if (!( (checkStr.charAt(i) >= "A" && checkStr.charAt(i) <= "Z") 
				|| (checkStr.charAt(i) >= "a" && checkStr.charAt(i) <= "z") 
				|| (checkStr.charAt(i) == "@") 
				|| (checkStr.charAt(i) == ".") 
				|| (checkStr.charAt(i) == "_") 
				|| (checkStr.charAt(i) == "-") 
				|| (checkStr.charAt(i) >= "0" && checkStr.charAt(i) <= "9")
				)){
				if (checkStr.charAt(i) == ' ')
					SpaceValid ++;
				else
					CharsInValid++;
				}
		}
	}
	if (checkStr.indexOf(".COM", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".EDU", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".NET", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".ORG", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".GOV", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".MIL", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".US", ix) > -1)
		ExtValid++;
		
	else if (checkStr.indexOf(".CC", ix) > -1)
		ExtValid++;
		
	else if (checkStr.indexOf(".cc", ix) > -1)
		ExtValid++;
		
	else if (checkStr.indexOf(".biz", ix) > -1)
		ExtValid++;
	
	else if (checkStr.indexOf(".BIZ", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".ws", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".WS", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".com", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".edu", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".net", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".org", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".gov", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".mil", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".us", ix) > -1)
		ExtValid++;
	RL = Reason.length;
	if (AtSignValid != 1)
		Reason += "\nOnly one '@' allowed, " + AtSignValid + " found.";
	if (MissingUserName > 0)
		Reason += "\nThe user name is missing.";
	if (MissingDomainName > 0)
		Reason += "\nThe domain name is missing.";
	if (PeriodValid == 0)
		Reason += "\nAddress must contain at least one period.";
	if (SpaceValid > 0)
		Reason += "\nNo Spaces allowed. Address contains " + SpaceValid + " space";
	if (SpaceValid > 1)
		Reason += "s.";
	if (CharsInValid > 0)
		Reason += "\nAddress contains " + CharsInValid + " invalid character";
	if (CharsInValid > 1)
		Reason += "s.";
	if (DoublePeriod > 0)
		Reason += "\nAddress contains multiple periods in a row.";
	if (ExtValid == 0)
		Reason += "\nInvalid Domain Suffix entered.\n(Valid: .com, .edu, .net, .org, .gov, .mil, .us)";
	if (checkStr.length > 120)
		Reason += "\nPlease limit the Email Address to 120 characters.";

	if (RL != Reason.length)
	{
		alert(Reason);
		EmailForm.focus();
		RC = false;
		}
	else
		RC = true;
	return(RC);
}


function VerifyZipCode(ZipCodeField)
{
	var checkOK = "0123456789";
	var checkStr = ZipCodeField.value;
	var allValid = true;
	
	//removes any dashes in the zipcode//
	var removechar	= "-";
	dash			= checkStr.indexOf(removechar);
	tmp				= checkStr.substring(0,dash);
	tmp				+= checkStr.substring(dash+1,checkStr.length);
	checkStr		= tmp;
	//alert(checkStr.length);
	
	
	if (checkStr.length < 5)
	{
		alert("Please enter at least 5 digits into zip code.");
		ZipCodeField.focus();
		return (false);
	}

	if (checkStr.length > 9)
	{
		alert("Please enter at most 9 digits into zip code.");
		ZipCodeField.focus();
		return (false);
	}
	
	if ((checkStr.length < 9) && (checkStr.length > 5))
	{
		alert("Please enter at most 9 OR at least 5 digits into zip code.");
		ZipCodeField.focus();
		return (false);
	}
	

	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
			if (j == checkOK.length)
			{
				allValid = false;
				break;
			}
	}
	if (!allValid)
	{
		alert("Please enter only 5 or 9 digits into zip code.");
		ZipCodeField.focus();
		return (false);
	}

	return (true);
}
/*'!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!
' Purpose:  Validate Tell a Friend form
' Inputs:   toForm - form to validate
' Returns:  nothing
'!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!*/
function validateTellFriendForm(toForm) {
	
	// Check first to see if toField is an object
	if(!toForm) {
		return (false);	
	}
	
	// Sender First Name	
	if(toForm.senderfirstname.value == '') {
		alert('You must enter a value in the Your First Name field.');
		toForm.senderfirstname.focus();
		return (false);
	}
	
	// Sender Email	
	if(toForm.senderemail.value == '') {
		alert('You must enter a value in the Your Email field.');
		toForm.senderemail.focus();
		return (false);
	}

	if (!(VerifyEmailAddress(toForm.senderemail)))
	    return (false);

	// Recipient Name	
	if(toForm.recipientname.value == '') {
		alert("You must enter a value in the Your Friend's Name field.");
		toForm.recipientname.focus();
		return (false);
	}

	// Recipient Email	
	if(toForm.recipientemail.value == '') {
		alert("You must enter a value in the Your Friend's Email field.");
		toForm.recipientemail.focus();
		return (false);
	}

	if (!(VerifyEmailAddress(toForm.recipientemail)))
	    return (false);	
}
// End -->
