function validate(theFormName,theFieldNames,theFieldDescs) 

	{ var FNames = theFieldNames.split('|')
	var FDescs = theFieldDescs.split('|');
	var argLength = FNames.length;
	var headLine = 'There is a problem with the following field(s):\n';
	var messageAlert = headLine;
	var pattern = /SubscriberEmailAddress/i;
	
    for(arg=0;arg<FNames.length;arg++) {
		theArgName=FNames[arg];
		theArgValue=document[theFormName][theArgName].value;
		if (theArgValue=='')
			{ messageAlert = messageAlert + FDescs[arg] + ' is blank.\n'; }
		//The validation of the valid email address  
		//Added by Wen April 10,2007
		else if ( theArgValue!='' && (pattern.test(FNames)))
			{
				var reEmail = new RegExp('^[a-zA-Z][\w\.-]*[a-zA-Z0-9]*@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$');
				if (!theArgValue.match(reEmail))
					messageAlert =  messageAlert + FDescs[arg] + ' is not validate.\n';
				
			}
		//end of addded by Wen
		else if ((theArgValue!='') && ((theArgName.indexOf('date')>=0)||(theArgName.indexOf('Date')>=0)))
			{ 
			theArgValue=trimString(theArgValue);
			tempArr=theArgValue.split('/');
				
				//  Begin Added by will edwards 8/15/02 to resolve leading zeroes in date validation
				for(i=0;i<3;i++) {
					re = /0/gi
					if (parseInt(tempArr[i]) < 1) { tempArr[i] = tempArr[i].replace(re,""); }
					else { tempArr[i] == parseInt(tempArr[i]); }
				}
				//  End Added by will edwards 8/15/02 to resolve leading zeroes in date validation
				
				if ((tempArr.length!=3)
					|| (tempArr[0].length>2)
					|| (tempArr[1].length>2)
					|| (tempArr[2].length!=4)
					|| (tempArr[0]!=parseInt(tempArr[0]))
					|| (tempArr[1]!=parseInt(tempArr[1]))
					|| (tempArr[2]!=parseInt(tempArr[2])))
					
					{ messageAlert = messageAlert + FDescs[arg] + ' must be formatted: MM/DD/YYYY.\n';}
			}
    }
	if(messageAlert==headLine) { return true;} else { alert(messageAlert); return false; } }
	
<!--// Added by tsu@sandag.org 02.10.05 to compare two form fields //-->
function doCompare(theFormName,fieldNameOne,fieldNameTwo) {
    if (document[theFormName][fieldNameOne].value != document[theFormName][fieldNameTwo].value)
    {
        alert('Oops\! Those entries don\'t match!');
        return false;
    } else {
        return true;
    }
}


function trimString (str) {
  while (str.charAt(0) == ' ')
    str = str.substring(1);
  while (str.charAt(str.length - 1) == ' ')
    str = str.substring(0, str.length - 1);
  return str;
}

function validateSignup(theFormName,theFieldNames,theFieldDescs) 
	{ 
	var configform = theFormName;
	var attending = 0;
	if(document.configform.rdoAttending[0].checked == false){
		//alert("Select whether you are attending the retreat.");
		if (document.configform.rdoAttending[1].checked == false){
			alert("Select whether you are attending the retreat.")
			attending = -1;
			return false;
		}
	}else{
		attending = 1;
	}
	if (attending != 0) {
		if(document.configform.noCheckIn.checked == false){
		myOption = -1;
		for (i=document.configform.checkin.length-1; i > -1; i--) {
			if (document.configform.checkin[i].checked) {
				for (i=document.configform.checkout.length-1; i > -1; i--) {
					if (document.configform.checkout[i].checked) {
						myOption = i; i = -1;
					}
			 	 }
			}
		}
			if (myOption == -1) {
				alert("Select checkin/checkout date or no accomodations required.");
				document.configform.rdoAttending[0].focus();
				return false;
			}
		}else{
			if(document.configform.dateattending1.checked == false){
				if(document.configform.dateattending2.checked == false){
					if(document.configform.dateattending3.checked == false){
						alert("Select date attending.");
						return false;
					}
				}
			}
		}
	}
	var FNames = theFieldNames.split('|')
	var FDescs = theFieldDescs.split('|');
	var argLength = FNames.length;
	var headLine = 'There is a problem with the following field(s):\n';
	var messageAlert = headLine;
    for(arg=0;arg<FNames.length;arg++) {
		theArgName=FNames[arg];
		theArgValue=document[theFormName][theArgName].value;
		if (theArgValue=='')
			{ messageAlert = messageAlert + FDescs[arg] + ' is blank.\n'; }
		else if ((theArgValue!='') && ((theArgName.indexOf('date')>=0)||(theArgName.indexOf('Date')>=0)))
			{ 
			theArgValue=trimString(theArgValue);
			tempArr=theArgValue.split('/');
				
				//  Begin Added by will edwards 8/15/02 to resolve leading zeroes in date validation
				for(i=0;i<3;i++) {
					re = /0/gi
					if (parseInt(tempArr[i]) < 1) { tempArr[i] = tempArr[i].replace(re,""); }
					else { tempArr[i] == parseInt(tempArr[i]); }
				}
				//  End Added by will edwards 8/15/02 to resolve leading zeroes in date validation
				
				if ((tempArr.length!=3)
					|| (tempArr[0].length>2)
					|| (tempArr[1].length>2)
					|| (tempArr[2].length!=4)
					|| (tempArr[0]!=parseInt(tempArr[0]))
					|| (tempArr[1]!=parseInt(tempArr[1]))
					|| (tempArr[2]!=parseInt(tempArr[2])))
					
					{ messageAlert = messageAlert + FDescs[arg] + ' must be formatted: MM/DD/YYYY.\n';}
			}
				str = document.configform.txtEmail.value
				if (str.length > 0){
					if (((str.indexOf(".") > 2) && (str.indexOf("@") > 0)) == false){
						alert ("Email address format is invalid.");
						document.configform.txtEmail.focus();
						return false;						
					}
				}
    }
	if(messageAlert==headLine) { return true;} else { alert(messageAlert); return false; } }
	

