<!-- CFM Javascripts -->
<!-- Hide script to validate various fields
//
//Presence Edits 
function EditPresentCall(FieldName) 
 { 
var str = FieldTrim(FieldName.value); 
if (str.length > 0)
return (true);  
else { 		return (false);
} 
} 


function EditPresent(FieldName) 
 { 
var str = FieldTrim(FieldName.value); 
if (str.length > 0)
//{alert(str);
//return (true);  }
return (true);  
else { 
alert(FieldName.name + " must be entered. ");
		FieldName.focus();
		return (false);
} 
} 

function FieldTrim(strText) { 
// this will get rid of leading spaces 
while (strText.substring(0,1) == " ") 
strText = strText.substring(1, strText.length); 

// this will get rid of trailing spaces 
while (strText.substring(strText.length-1,strText.length) == " ") 
strText = strText.substring(0, strText.length-1); 

return strText; 
}


//
// Numeric edit-checks for numerics if the field is entered 
function EditNumValue(FieldName) {
if (isNaN(FieldName.value) == true || FieldName.value == "" || FieldName.value.length == 0)	 
	{	 	
	alert(FieldName.name + " is not numeric. ");
	FieldName.focus();
	FieldName.select();
	return (false);
} else {
	
	//alert(FieldName.name + " is numeric. " + "length is " + FieldName.value.length);
		return (true);
	
}
}





//
// Numeric edit-checks for numerics if the field is entered and correct 
// length.  Zero length means just check for presence of numerics. 
function EditNumericValue(FieldName, FieldLength) {
if (isNaN(FieldName.value) == true && FieldName.value != "")	 
	{	 	
	alert(FieldName.name + " is not numeric. ");
	FieldName.focus();
	FieldName.select();
	return (false);
} else {
	if (FieldName.value.length == FieldLength || FieldLength == 0) 
{
	//alert(FieldName.name + " is numeric. ");
		return (true);
	} else {
		alert(FieldName.name + " is not " + FieldLength + " digits. ");
		FieldName.focus();
		FieldName.select();
		return (false);
	}
}
}

//Numeric presence edit-checks for numerics and correct length.  
//Zero length means just check for presence of numerics.
function EditNumericPresent(FieldName, FieldLength) {
if (isNaN(FieldName.value) == true)	 
	{	 	
	alert(FieldName.name + " is not numeric. ");
	FieldName.focus();
	FieldName.select();
	return (false);
} else {
	if (FieldName.value.length == FieldLength || FieldLength == 0) 
{
	//alert(FieldName.name + " is numeric. ");
		return (true);
	} else {
		alert(FieldName.name + " is not " + FieldLength + " digits. ");
		FieldName.focus();
		FieldName.select();
		return (false);
	}
}
}


//Numeric presence edit-checks for numerics and correct length.  
//Zero length means just check for presence of numerics.  Used when no popup is needed
function EditNewNumericPresent(FieldName, FieldLength) {
if (isNaN(FieldName.value) == true)	 
	{	 	
	//alert(FieldName.name + " is not numeric. ");
	//FieldName.focus();
	//FieldName.select();
	return (false);
} else {
	if (FieldName.value.length == FieldLength || FieldLength == 0) 
{
	//alert(FieldName.name + " is numeric. ");
		return (true);
	} else {
	//	alert(FieldName.name + " is not " + FieldLength + " digits. ");
	//	FieldName.focus();
	//	FieldName.select();
		return (false);
	}
}
}




//
//Validate saluation of mr. & mrs. against both names filled in
//
function EditName() {
 if (document.CFMForm.elements["SALUTATION"].options[0].selected == true) 
{

if (EditPresentCall(document.CFMForm.HIS_FIRST_NAME)  == true &&
	EditPresentCall(document.CFMForm.HIS_LAST_NAME) == true  &&		
	EditPresentCall(document.CFMForm.HER_FIRST_NAME) == true &&		
	EditPresentCall(document.CFMForm.HER_LAST_NAME) == true )
	{
	//	alert("Salutation has correct names.");
		return (true);
	} else {
		alert("Salutation requires " + 		document.CFMForm.HIS_FIRST_NAME.name + " and " + 		document.CFMForm.HIS_LAST_NAME.name + " and " + 		document.CFMForm.HER_FIRST_NAME.name + " and " + 		document.CFMForm.HER_LAST_NAME.name + ".");
		document.CFMForm.HIS_FIRST_NAME.focus();
		document.CFMForm.HIS_FIRST_NAME.select();
		return (false);
	}
} else {
		//alert("Salutation has correct names.");
		return (true);
		
	}
} 



//
//Validate new leader saluation of mr. & mrs. against both names filled in
//
function EditNewName() {
 if (document.CFMForm.elements["NEW_SALUTATION"].options[1].selected == true) 
{

if (EditPresentCall(document.CFMForm.NEW_HIS_FIRST_NAME)  == true &&
	EditPresentCall(document.CFMForm.NEW_HIS_LAST_NAME) == true  &&		
	EditPresentCall(document.CFMForm.NEW_HER_FIRST_NAME) == true &&		
	EditPresentCall(document.CFMForm.NEW_HER_LAST_NAME) == true )
	{
	//	alert("Salutation has correct names.");
		return (true);
	} else {
		alert("Salutation requires " + 		document.CFMForm.NEW_HIS_FIRST_NAME.name + " and " + 		document.CFMForm.NEW_HIS_LAST_NAME.name + " and " + 		document.CFMForm.NEW_HER_FIRST_NAME.name + " and " + 		document.CFMForm.NEW_HER_LAST_NAME.name + ".");
		document.CFMForm.NEW_HIS_FIRST_NAME.focus();
		document.CFMForm.NEW_HIS_FIRST_NAME.select();
		return (false);
	}
} else {
		//alert("Salutation has correct names.");
		return (true);
		
	}
} 


//
//Validate renewal question 1 against new salutation
//

function EditQuest1() {
if (document.CFMForm.LEADER_NXT_YR[1].checked == true)	 
{

if (document.CFMForm.elements["NEW_SALUTATION"].options[0].selected == false )
	{
	  	//alert("Question about new leader has a salutation.");
		return (true);
	} else {
		alert("New leader for next year question requires new leader info.");
		document.CFMForm.NEW_HIS_FIRST_NAME.focus();
		document.CFMForm.NEW_HIS_FIRST_NAME.select();
		return (false);
	}
} else {
		if (document.CFMForm.elements["NEW_SALUTATION"].options[0].selected == true )
		{	 
			//alert("Question indicates no new leader.");
			return (true);
		
	} else {
		alert("Same leader for next year question does not require new leader info.");
		document.CFMForm.NEW_HIS_FIRST_NAME.focus();
		document.CFMForm.NEW_HIS_FIRST_NAME.select();
		return (false);
	}
} 
}



//
//Validate new leader saluation against other fields
//
function EditNewAddrPhone() {
 if (document.CFMForm.elements["NEW_SALUTATION"].options[0].selected == false) 
{

if (EditPresentCall(document.CFMForm.NEW_ADDRESS_1) == true  &&
	    EditPresentCall(document.CFMForm.NEW_CITY) == true  &&
	    EditPresentCall(document.CFMForm.NEW_ZIPCODE) == true && EditPresentCall(document.CFMForm.NEW_COUNTRY) == true  &&
	    EditNewNumericPresent(CFMForm.NEW_AREA_CODE, 3) == true && EditNewNumericPresent(CFMForm.NEW_PHONE_PREFIX, 3)  == true  &&
	    EditNewNumericPresent(CFMForm.NEW_PHONE_DIGIT, 4) == true && EditPresentCall(document.CFMForm.NEW_email) == true && document.CFMForm.elements["NEW_STATE"].options[0].selected  == false)
	{
	//	alert("Salutation has correct addr/phone.");
		return (true);
	} else {
		alert("Salutation requires " + 		document.CFMForm.NEW_ADDRESS_1.name + " and " + 		document.CFMForm.NEW_CITY.name + " and " + 		document.CFMForm.NEW_STATE.name + " and " + 		document.CFMForm.NEW_ZIPCODE.name +  " and " +		document.CFMForm.NEW_AREA_CODE.name + " and " + 		document.CFMForm.NEW_PHONE_PREFIX.name + " and " + 	document.CFMForm.NEW_PHONE_DIGIT.name +  " and " + 		document.CFMForm.NEW_email.name + ".");
		document.CFMForm.NEW_ADDRESS_1.focus();
		document.CFMForm.NEW_ADDRESS_1.select();
		return (false);
	}
} else {
		
if (EditPresentCall(document.CFMForm.NEW_ADDRESS_1) == true  ||
	    EditPresentCall(document.CFMForm.NEW_CITY) == true  ||
	    EditPresentCall(document.CFMForm.NEW_ZIPCODE) == true || EditPresentCall(document.CFMForm.NEW_COUNTRY) == true  ||
	    EditPresentCall(CFMForm.NEW_AREA_CODE) == true || EditPresentCall(CFMForm.NEW_PHONE_PREFIX)  == true  ||
	    EditPresentCall(CFMForm.NEW_PHONE_DIGIT) == true || EditPresentCall(document.CFMForm.NEW_email) == true || document.CFMForm.elements["NEW_STATE"].options[0].selected  == false)
	{

		alert("New leader information requires a salutation.");
		document.CFMForm.NEW_HIS_FIRST_NAME.focus();
		document.CFMForm.NEW_HIS_FIRST_NAME.select();
		return (false);	
	
	} else {
		//alert("Same leader for next year question does not require new leader info.");
		return (true);
	}
}
}

//
//Validate security question
//

function EditSecurity() {
if (document.CFMForm.elements["SECURITY_QUESTION"].options[2].selected == true)	 
{
	//alert("Correct Answer.");
	return (true);
} else {
	alert("Incorrect Answer to Security Question. Try Again.");
	document.CFMForm.SECURITY_QUESTION.focus()
	return (false);

}
}

//
// edit new leader zip
function EditNewZIP(FieldName) 
 { 
var str = FieldTrim(FieldName.value); 
var valid = "0123456789-";
var hyphencount = 0;

if (document.CFMForm.elements["NEW_SALUTATION"].options[0].selected == false && FieldName.value.length !=5 && FieldName.value.length != 10) {
alert("Please enter your 5 digit or 5 digit plus 4 zip code.");
FieldName.focus();
FieldName.select();
return false;
}
for (var i=0; i < FieldName.value.length; i++) {
temp = "" + FieldName.value.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your zip code.  Please try again.");
FieldName.focus();
FieldName.select();
return false;
}
if ((hyphencount > 1) || 
(FieldName.value.length == 10 && "" + FieldName.value.charAt(5) != "-")  || 
(hyphencount > 0 && FieldName.value.length == 5)) {
alert("The hyphen character should be used with a properly formatted 5 digit plus 4 zip code like 12345-6789.   Please try again."); 
FieldName.focus();
FieldName.select();
return false;
   }
}
return true;
}


//
// Edits to compare salutation to first and last names - his or hers
//
function EditHis() {
 if (document.CFMForm.elements["SALUTATION"].options[1].selected  == true 
|| document.CFMForm.elements["SALUTATION"].options[4].selected  == true) 
	{ 
  if (EditPresentCall(document.CFMForm.HIS_FIRST_NAME)  == true &&
	EditPresentCall(document.CFMForm.HIS_LAST_NAME) == true  &&		
	EditPresentCall(document.CFMForm.HER_FIRST_NAME) == false &&		
	EditPresentCall(document.CFMForm.HER_LAST_NAME) == false)
	{
	//	alert("Salutation has correct names.");
		return (true);
	} else {
	  		alert("Salutation requires " + 			document.CFMForm.HIS_FIRST_NAME.name + " and " + 			document.CFMForm.HIS_LAST_NAME.name + " only.");
			document.CFMForm.HIS_FIRST_NAME.focus();
			document.CFMForm.HIS_FIRST_NAME.select();
			return (false);

	}
 } else {
	if (document.CFMForm.elements["SALUTATION"].options[2].selected  == true 
|| document.CFMForm.elements["SALUTATION"].options[3].selected  == true
|| document.CFMForm.elements["SALUTATION"].options[5].selected  == true) 
	 { 
	if (EditPresentCall(document.CFMForm.HIS_FIRST_NAME)  == false &&
	EditPresentCall(document.CFMForm.HIS_LAST_NAME) == false &&		
	EditPresentCall(document.CFMForm.HER_FIRST_NAME) == true &&		
	EditPresentCall(document.CFMForm.HER_LAST_NAME) == true )
		{
	//	alert("Salutation has correct names.");
		return (true);

	} else {
			alert("Salutation requires " + 			document.CFMForm.HER_FIRST_NAME.name + " and " + 			document.CFMForm.HER_LAST_NAME.name + " only.");
			document.CFMForm.HER_FIRST_NAME.focus();
			document.CFMForm.HER_FIRST_NAME.select();
			return (false);

	}
 } else {
	if (document.CFMForm.elements["SALUTATION"].options[0].selected == true) { 
	if (EditPresentCall(document.CFMForm.HIS_FIRST_NAME) == false ||	EditPresentCall(document.CFMForm.HIS_LAST_NAME) == false ||		
	EditPresentCall(document.CFMForm.HER_FIRST_NAME) == false ||
	EditPresentCall(document.CFMForm.HER_LAST_NAME) == false )
	{
		alert("Salutation requires " + 			document.CFMForm.HIS_FIRST_NAME.name + " and " + 			document.CFMForm.HIS_LAST_NAME.name + " and " + 			document.CFMForm.HER_FIRST_NAME.name + " and " + 			document.CFMForm.HER_LAST_NAME.name + ".");
		document.CFMForm.HIS_FIRST_NAME.focus();
		document.CFMForm.HIS_FIRST_NAME.select();
		return (false);
	} else {
	//	alert("Salutation has correct names.");
		return (true);
	}
 } else {
	alert("Salutation does not correspond to your entry in " + 		document.CFMForm.HER_FIRST_NAME.name + " and " + 		document.CFMForm.HER_LAST_NAME.name + ".");
	document.CFMForm.HER_FIRST_NAME.focus();
	document.CFMForm.HER_FIRST_NAME.select();

	return (false);
}
}
}
}



//
// Edits to compare new Leader salutation to first and last names - his or hers
//
function EditNewHis() {
 if (document.CFMForm.elements["NEW_SALUTATION"].options[2].selected  == true 
|| document.CFMForm.elements["NEW_SALUTATION"].options[5].selected  == true) 
	{ 
  if (EditPresentCall(document.CFMForm.NEW_HIS_FIRST_NAME)  == true &&
	EditPresentCall(document.CFMForm.NEW_HIS_LAST_NAME) == true  &&		
	EditPresentCall(document.CFMForm.NEW_HER_FIRST_NAME) == false &&		
	EditPresentCall(document.CFMForm.NEW_HER_LAST_NAME) == false)
	{
	//	alert("Salutation has correct names.");
		return (true);
	} else {
	  		alert("Salutation requires " + 			document.CFMForm.NEW_HIS_FIRST_NAME.name + " and " + 			document.CFMForm.NEW_HIS_LAST_NAME.name + " only.");
			document.CFMForm.NEW_HIS_FIRST_NAME.focus();
			document.CFMForm.NEW_HIS_FIRST_NAME.select();
			return (false);

	}
 } else {
	if (document.CFMForm.elements["NEW_SALUTATION"].options[3].selected  == true 
|| document.CFMForm.elements["NEW_SALUTATION"].options[4].selected  == true
|| document.CFMForm.elements["NEW_SALUTATION"].options[6].selected  == true) 
	 { 
	if (EditPresentCall(document.CFMForm.NEW_HIS_FIRST_NAME)  == false &&
	EditPresentCall(document.CFMForm.NEW_HIS_LAST_NAME) == false &&		
	EditPresentCall(document.CFMForm.NEW_HER_FIRST_NAME) == true &&		
	EditPresentCall(document.CFMForm.NEW_HER_LAST_NAME) == true )
		{
	//	alert("Salutation has correct names.");
		return (true);

	} else {
			alert("Salutation requires " + 			document.CFMForm.NEW_HER_FIRST_NAME.name + " and " + 			document.CFMForm.NEW_HER_LAST_NAME.name + " only.");
			document.CFMForm.NEW_HER_FIRST_NAME.focus();
			document.CFMForm.NEW_HER_FIRST_NAME.select();
			return (false);

	}
 } else {
	if (document.CFMForm.elements["NEW_SALUTATION"].options[1].selected == true) { 
	if (EditPresentCall(document.CFMForm.NEW_HIS_FIRST_NAME) == false ||	EditPresentCall(document.CFMForm.NEW_HIS_LAST_NAME) == false ||		
	EditPresentCall(document.CFMForm.NEW_HER_FIRST_NAME) == false ||
	EditPresentCall(document.CFMForm.NEW_HER_LAST_NAME) == false )
	{
		alert("Salutation requires " + 			document.CFMForm.NEW_HIS_FIRST_NAME.name + " and " + 			document.CFMForm.NEW_HIS_LAST_NAME.name + " and " + 			document.CFMForm.NEW_HER_FIRST_NAME.name + " and " + 			document.CFMForm.NEW_HER_LAST_NAME.name + ".");
		document.CFMForm.NEW_HIS_FIRST_NAME.focus();
		document.CFMForm.NEW_HIS_FIRST_NAME.select();
		return (false);
	} else {
	//	alert("Salutation has correct names.");
		return (true);
	}
 } else {
	if (document.CFMForm.elements["NEW_SALUTATION"].options[0].selected == true) { 
	if (EditPresentCall(document.CFMForm.NEW_HIS_FIRST_NAME) == true ||	EditPresentCall(document.CFMForm.NEW_HIS_LAST_NAME) == true ||		
	EditPresentCall(document.CFMForm.NEW_HER_FIRST_NAME) == true ||
	EditPresentCall(document.CFMForm.NEW_HER_LAST_NAME) == true )
	{
		alert("No Salutation selected for " + 			document.CFMForm.NEW_HIS_FIRST_NAME.name + " and " + 			document.CFMForm.NEW_HIS_LAST_NAME.name + " and " + 			document.CFMForm.NEW_HER_FIRST_NAME.name + " and " + 			document.CFMForm.NEW_HER_LAST_NAME.name + ".");
		document.CFMForm.NEW_HIS_FIRST_NAME.focus();
		document.CFMForm.NEW_HIS_FIRST_NAME.select();
		return (false);
	} else {
	//	alert("Salutation has correct names.");
		return (true);
	}
 } else {
	alert("Salutation does not correspond to your entry in " + 		document.CFMForm.NEW_HER_FIRST_NAME.name + " and " + 		document.CFMForm.NEW_HER_LAST_NAME.name + ".");
	document.CFMForm.NEW_HER_FIRST_NAME.focus();
	document.CFMForm.NEW_HER_FIRST_NAME.select();

	return (false);
}
}
}
}
}



//
//Validate saluation against religion and occupation
//
function EditRelOccup() {
 if (document.CFMForm.elements["SALUTATION"].options[0].selected == true) 
{ 
 if (EditPresentCall(document.CFMForm.HIS_RELIGION)  == true &&
	EditPresentCall(document.CFMForm.HIS_OCCUP) == true  &&		
	EditPresentCall(document.CFMForm.HER_RELIGION) == true &&		
	EditPresentCall(document.CFMForm.HER_OCCUP) == true)
	
	{
	//	alert("Salutation has correct religion.");
		return (true);
	} else {
		alert("Salutation requires " + 			document.CFMForm.HIS_RELIGION.name + " and " + 			document.CFMForm.HIS_OCCUP.name + " and " + 			document.CFMForm.HER_RELIGION.name + " and " + 			document.CFMForm.HER_OCCUP.name + ".");
			document.CFMForm.HIS_RELIGION.focus();
			document.CFMForm.HIS_RELIGION.select();
			return (false);
		
	}
} else {
	//	alert("Salutation has correct religion.");
		return (true);
	}
} 
//
// Edits to compare salutation to religion and occupation
//
function EditRelOccup2() {
 if (document.CFMForm.elements["SALUTATION"].options[1].selected  == true 
|| document.CFMForm.elements["SALUTATION"].options[4].selected  == true) 
	{ 
	if (EditPresentCall(document.CFMForm.HIS_RELIGION)  == true &&
	EditPresentCall(document.CFMForm.HIS_OCCUP) == true  &&		
	EditPresentCall(document.CFMForm.HER_RELIGION) == false &&		
	EditPresentCall(document.CFMForm.HER_OCCUP) == false)
	{
	//	alert("Salutation has correct religion.");
		return (true);

	} else {
	  		alert("Salutation requires " + 			document.CFMForm.HIS_RELIGION.name + " and " + 			document.CFMForm.HIS_OCCUP.name + ".");
			document.CFMForm.HIS_RELIGION.focus();
			document.CFMForm.HIS_RELIGION.select();
			return (false);
	}
 } else {
	if (document.CFMForm.elements["SALUTATION"].options[2].selected  == true 
|| document.CFMForm.elements["SALUTATION"].options[3].selected  == true
|| document.CFMForm.elements["SALUTATION"].options[5].selected  == true) 
	 { 
	if (EditPresentCall(document.CFMForm.HIS_RELIGION)  == false &&
	EditPresentCall(document.CFMForm.HIS_OCCUP) == false  &&		
	EditPresentCall(document.CFMForm.HER_RELIGION) == true &&		
	EditPresentCall(document.CFMForm.HER_OCCUP) == true)
		{
	//	alert("Salutation has correct religion.");
		return (true);
	} else {
	 		alert("Salutation requires " + 			document.CFMForm.HER_RELIGION.name + " and " + 			document.CFMForm.HER_OCCUP.name + ".");
			document.CFMForm.HER_RELIGION.focus();
			document.CFMForm.HER_RELIGION.select();
			return (false);
	}
 } else {
	if (document.CFMForm.elements["SALUTATION"].options[0].selected == true) { 
	if (EditPresentCall(document.CFMForm.HIS_RELIGION)  == false ||
	EditPresentCall(document.CFMForm.HIS_OCCUP) == false ||		
	EditPresentCall(document.CFMForm.HER_RELIGION) == false ||		
	EditPresentCall(document.CFMForm.HER_OCCUP) == false)
	{
		alert("Salutation requires " + 			document.CFMForm.HIS_RELIGION.name + " and " + 			document.CFMForm.HIS_OCCUP.name + " and " + 			document.CFMForm.HER_RELIGION.name + " and " + 			document.CFMForm.HER_OCCUP.name + ".");
		document.CFMForm.HIS_RELIGION.focus();
		document.CFMForm.HIS_RELIGION.select();
		return (false);
	} else {
	//	alert("Salutation has correct religion.");
		return (true);
	}
 } else {
	alert("Salutation does not correspond to your entry in " + 		document.CFMForm.HER_FIRST_NAME.name + " and " + 		document.CFMForm.HER_LAST_NAME.name + ".");
	document.CFMForm.HER_FIRST_NAME.focus();
	document.CFMForm.HER_FIRST_NAME.select();

	return (false);
}
}
}
}
//
//Validate saluation against married status
//
function EditMarry() {
 if (document.CFMForm.elements["SALUTATION"].options[0].selected == true) 
{ 
	if (document.CFMForm.elements["MARITAL_STATUS"].options[1].selected == true) 
	{
		alert("Salutation requires entry of married and marriage date.");
		document.CFMForm.elements["MARITAL_STATUS"].focus();
		
		return (false);

	} else {
	//	alert("Salutation matches marital status " );
		return (true);
	}
} else {
	if (document.CFMForm.elements["MARITAL_STATUS"].options[1].selected == false) 
	{
		alert("Salutation conflicts with marriage status.");
		document.CFMForm.elements["MARITAL_STATUS"].focus();
	
		return (false);

	} else {
	//	alert("Salutation matches marital status " );
		return (true);
	}

		
	}
} 

//
//Validate saluation against married dates
//
function EditMarryDate() {
 if (document.CFMForm.elements["MARITAL_STATUS"].options[0].selected == true) 
{ 
	if (document.CFMForm.elements["MARRIED_YEAR"].options[0].selected == true ||
		document.CFMForm.elements["MARRIED_MONTH"].options[0].selected == true ||
		document.CFMForm.elements["MARRIED_DAY"].options[0].selected == true)
	{
		alert("Marriage date required.");
		document.CFMForm.elements["MARRIED_YEAR"].focus();
		
		return (false);

	} else {
	//	alert("Date matches marital status " );
		return (true);
	}
} else {
	if (document.CFMForm.elements["MARRIED_YEAR"].options[0].selected == false ||
		document.CFMForm.elements["MARRIED_MONTH"].options[0].selected == false ||
		document.CFMForm.elements["MARRIED_DAY"].options[0].selected == false) 
	{
		alert("Marriage status conflicts with married date.");
		document.CFMForm.elements["MARRIED_YEAR"].focus();
	
		return (false);

	} else {
	//	alert("Date matches marital status " );
		return (true);
	}

		
	}
} 


//
//Validate parish affiliation with parish name, city
//
function EditParish() {
 if (document.CFMForm.PARISH_AFFILIATED[0].checked == true) 
{ 
	if (EditPresentCall(document.CFMForm.PARISH) == false  ||	
	    EditPresentCall(document.CFMForm.PARISH_CITY) == false ||
	    document.CFMForm.elements["PARISH_STATE"].options[0].selected  == true)

	{
		alert("Parish affiliation requires entry of parish and parish city/state.");
		document.CFMForm.PARISH.focus();
		
		return (false);

	} else {
	//	alert("Parish affiliation matches parish and parish city/state " );
		return (true);
	}
} else {
	if (EditPresentCall(document.CFMForm.PARISH) == true  ||	
	    EditPresentCall(document.CFMForm.PARISH_CITY) == true  ||
	    document.CFMForm.elements["PARISH_STATE"].options[0].selected  == false)

	{
		alert("Entry of parish and parish city/state requires parish affiliation.");
		document.CFMForm.PARISH_AFFILIATED[0].focus();
	
		return (false);

	} else {
	//	alert("Parish affiliation matches parish and parish city/state " );
		return (true);
	}

		
	}
} 






//
//Validate renewal form parish affiliation with parish and address data
//
function EditNewParish() {
 if (document.CFMForm.PARISH_AFFILIATED[0].checked == true)
{ 
	if (EditPresentCall(document.CFMForm.PARISH) == false  || EditPresentCall(document.CFMForm.PARISH_ADDRESS_1) == false  ||
	    EditPresentCall(document.CFMForm.PARISH_CITY) == false  ||
	    EditPresentCall(document.CFMForm.PARISH_ZIPCODE) == false || EditPresentCall(document.CFMForm.PARISH_COUNTRY) == false  ||
	    EditNewNumericPresent(CFMForm.PARISH_AREA_CODE, 3) == false || EditNewNumericPresent(CFMForm.PARISH_PHONE_PREFIX, 3)  == false  ||
	    EditNewNumericPresent(CFMForm.PARISH_PHONE_DIGIT, 4) == false || document.CFMForm.elements["PARISH_STATE"].options[0].selected  == true)

	{
		alert("Parish affiliation requires entry of parish name, address, city, state, country, ZIP and phone.");
		document.CFMForm.PARISH.focus();
		
		return (false);

	} else {
	//	alert("Parish affiliation matches parish and parish info " );

		return (true);
	}
} else {
	if (EditPresentCall(document.CFMForm.PARISH) == true  || EditPresentCall(document.CFMForm.PARISH_ADDRESS_1) == true  ||
	    EditPresentCall(document.CFMForm.PARISH_ADDRESS_2) == true  || EditPresentCall(document.CFMForm.PARISH_CITY) == true  ||
	    EditPresentCall(document.CFMForm.PARISH_ZIPCODE) == true || EditPresentCall(document.CFMForm.PARISH_COUNTRY) == true  ||
	    EditPresentCall(document.CFMForm.PARISH_AREA_CODE) == true || EditPresentCall(document.CFMForm.PARISH_PHONE_PREFIX) == true  ||
	    EditPresentCall(document.CFMForm.PARISH_PHONE_DIGIT) == true || document.CFMForm.elements["PARISH_STATE"].options[0].selected  == false)

	{
		alert("Entry of parish information requires parish affiliation?");
		document.CFMForm.PARISH_AFFILIATED[0].focus();
	
		return (false);

	} else {
	//alert("Parish affiliation matches parish and parish info " );
		return (true);
	}

		
	}
}


//
//Validate book selected is entered if special book is requested
//
function EditBook() {
 if (document.CFMForm.elements["SPECIAL_BOOK"].options[0].selected == true) { 
	if (document.CFMForm.elements["BOOK_TYPE"].options[3].selected  == false ) {
	//	alert("special not chosen");
		return (true);
	} else {
 		alert("You chose to receive a Special Book.  Please specify it.");
		document.CFMForm.SPECIAL_BOOK.focus();
	
		return (false);
	}
 } else {
	if (document.CFMForm.elements["BOOK_TYPE"].options[3].selected  == true ) {
	//	alert("special specified and chosen");
		return (true);
	} else {
 		alert("You cannot specify a Special Book without choosing that option.");
		document.CFMForm.SPECIAL_BOOK.focus();
	
		return (false);
	}
}
}


//
//Validate book selected is entered if special book is requested
//
function EditNewBook() {
 if (document.CFMForm.elements["SPECIAL_BOOK"].options[0].selected == true) 
{ 
	
 		alert("Please specify book used.");
		document.CFMForm.SPECIAL_BOOK.focus();
	
		return (false);
	
 } else {

	//	alert("special specified and chosen");
		return (true);
	} 

}






//
//
//Validate dues entered if other is selected
//
function EditDues() {
 if (document.CFMForm.OTHER_DUES.value == "") { 
	if (document.CFMForm.elements["DUES_TYPE"].options[5].selected  == false ) {
	//	alert("Regular dues chosen  ");
		return (true);
	} else {
 		alert("You chose to send other amount of dues.  Please specify it.");
		document.CFMForm.OTHER_DUES.focus();
		document.CFMForm.OTHER_DUES.select();
		return (false);
	}
 } else {
	if (document.CFMForm.elements["DUES_TYPE"].options[5].selected  == true ) {
	//	alert("other specified and chosen");
		if (isNaN(CFMForm.OTHER_DUES.value) == true && CFMForm.OTHER_DUES.value != "")	 
	{	 	
	alert(CFMForm.OTHER_DUES.name + " is not numeric. ");
	document.CFMForm.OTHER_DUES.focus();
	document.CFMForm.OTHER_DUES.select();
	return (false);
} else {
	if (document.CFMForm.OTHER_DUES.value > 40) 
{
	//alert(FieldName.name + " is numeric. ");
		return (true);
	} else {
		alert(CFMForm.OTHER_DUES.name + " must be " + " greater than $40. ");
		document.CFMForm.OTHER_DUES.focus();
		document.CFMForm.OTHER_DUES.select();
		return (false);
	}
}

	} else {
 		alert("You cannot specify a special dues amount without choosing that option.");
		document.CFMForm.OTHER_DUES.focus();
		document.CFMForm.OTHER_DUES.select();
		return (false);
	}
}
}

//Script to edit zip code
function EditZIP(FieldName) {
var valid = "0123456789-";
var hyphencount = 0;

if (FieldName.value.length !=5 && FieldName.value.length != 10) {
alert("Please enter your 5 digit or 5 digit plus 4 zip code.");
FieldName.focus();
FieldName.select();
return false;
}
for (var i=0; i < FieldName.value.length; i++) {
temp = "" + FieldName.value.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your zip code.  Please try again.");
FieldName.focus();
FieldName.select();
return false;
}
if ((hyphencount > 1) || 
(FieldName.value.length == 10 && "" + FieldName.value.charAt(5) != "-")  || 
(hyphencount > 0 && FieldName.value.length == 5)) {
alert("The hyphen character should be used with a properly formatted 5 digit plus 4 zip code like 12345-6789.   Please try again."); 
FieldName.focus();
FieldName.select();
return false;
   }
}
return true;
}

//script to edit email name for validity
function EditEmail(FieldName) {
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var str = FieldTrim(FieldName.value)

/* Finally, let's start trying to figure out if the supplied address is
   valid. for field altemail, edit only if something is supplied, field is optional*/

if (FieldName.name == "altemail" && str.length == 0) 
 return true; 


/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=FieldName.value.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	alert("Email address seems incorrect (check for presence of @ and .'s)");
	FieldName.focus();
      FieldName.select();
      return false;
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    alert("Email username doesn't seem to be valid.");
    FieldName.focus();
    FieldName.select();
    return false;

}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Email destination IP address is invalid!");
		  FieldName.focus();
   		  FieldName.select();
              return false;
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("Email domain name doesn't seem to be valid.");
      FieldName.focus();
      FieldName.select();
      return false;

}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   alert("Email address must end in a three-letter domain, or two letter country.");
   FieldName.focus();
   FieldName.select();
   return false;
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   alert("Email address is missing a hostname!");
   FieldName.focus();
   FieldName.select();
   return false;
}

// If we've gotten this far, everything's valid!
return true;
}


// Stop hiding script -->


