function emailvalidation(entered, alertbox)
{
with (entered)
	{
	apos=value.indexOf("@"); 
	dotpos=value.lastIndexOf(".");
	lastpos=value.length-1;
	if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
	{ focus();
	if (alertbox) {alert(alertbox);} return false;}
	else {return true;}
	}
} 

function CheckFormPetition () {

	var errorMsg = "";
	var errorMsgLong = "";

	if (document.frmSignPetition.name.value == ""){
		errorMsg += "\n\tName \t- Enter Name";
		document.frmSignPetition.name.focus();
	}
	if (document.frmSignPetition.Address1.value == ""){
		errorMsg += "\n\tAddress \t- Enter Address";
		document.frmSignPetition.Address1.focus();
	}
	if (document.frmSignPetition.City.value == ""){
		errorMsg += "\n\tCity \t- Enter City";
		document.frmSignPetition.City.focus();
	}

	if (document.frmSignPetition.County.value == ""){
		errorMsg += "\n\tCounty \t- Enter County";
		document.frmSignPetition.County.focus();
	}

	if (document.frmSignPetition.Zip.value == ""){
		errorMsg += "\n\tZip Code \t- Enter Zip Code";
		document.frmSignPetition.Zip.focus();
	}
	if (document.frmSignPetition.PhoneNumber.value == ""){
		errorMsg += "\n\tPhone Number \t- Enter Phone Number";
		document.frmSignPetition.PhoneNumber.focus();
	}

	if (document.frmSignPetition.email.value == ""){
		errorMsg += "\n\tEmail \t- Enter Email";
		document.frmSignPetition.email.focus();
	} else if(!emailvaildation(document.frmSignPetition.email, 'The E-mail is not valid')) {
		return false;
	}

	if ((errorMsg != "") || (errorMsgLong != "")){
		msg = "___________________________________________________________________\n\n";
		msg += "The record could not been added because there are problem(s) with the form.\n";
		msg += "Please correct the problem(s) and re-submit the form.\n";
		msg += "___________________________________________________________________\n\n";
		msg += "The following field(s) need to be corrected: -\n";

		errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong);
		return false;
	}

	return true;
}

function CheckFormNewsletter () {

	var errorMsg = "";
	var errorMsgLong = "";


	if (document.frmNewsletter.email.value == ""){
		errorMsg += "\n\tEmail \t- Enter Email";
		document.frmNewsletter.email.focus();
	}

	if (document.frmNewsletter.fname.value == ""){
		errorMsg += "\n\tFirst Name \t- Enter First Name";
		document.frmNewsletter.fname.focus();
	}

	if (document.frmNewsletter.lname.value == ""){
		errorMsg += "\n\tLast Name \t- Enter Last Name";
		document.frmNewsletter.lname.focus();
	}

	if ((errorMsg != "") || (errorMsgLong != "")){
		msg = "___________________________________________________________________\n\n";
		msg += "The record could not been added because there are problem(s) with the form.\n";
		msg += "Please correct the problem(s) and re-submit the form.\n";
		msg += "___________________________________________________________________\n\n";
		msg += "The following field(s) need to be corrected: -\n";

		errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong);
		return false;
	}

	return true;
}


