
function Validate(){
   var strfrom;
   var strAlertMessage;
   var strFocus;
   var strReturn

   strfrom = document.frm.from.value;
   strAlertMessage = "Please enter the following:";
   strFocus = false;
   strReturn = true

      if (!document.frm.consent.checked){
      		document.frm.consent.focus();
      		window.alert("A comment cannot be submitted without agreeing to publish.");
                strReturn = false;
      		return false;}
				
if ((strfrom == '')){
        document.frm.from.focus();
        strAlertMessage = strAlertMessage+"\n -"+"Contact Email Address";
	strFocus = true;
	strReturn = false;}
   else if (!emailValidation(strfrom)){
			document.frm.from.focus();
			return false;}			

	if (!strReturn){window.alert(strAlertMessage);}	
					
return strReturn;}





var countingFields1;

function onDESCEventCounter(field,MAX){
   var MAXCHAR=MAX;
   var len=0;
	for (i=0;i<countingFields1.length;i++){
		len+=countingFields1[i].value.length;
	}
	if (len>MAXCHAR){
		alert("The maximum number of characters\nthat can be entered is " + MAXCHAR + ".\n\n You have entered " + len + " characters.");
		field.value=field.value.substring(0,field.value.length+MAXCHAR-len);
		document.frm.DCharacterCount.value=0;
		document.frm.DCharacterCount.focus();
	}
	else{
	   document.frm. DCharacterCount.value=(MAXCHAR-len);
	}
}

function PhoneValidation(phone) {
var matchArr = phone.match(/^(\d{3})-?\d{3}-?\d{4}$/);
var numDashes = phone.split('-').length - 1
var areacodenum = phone.substr(0,3);
if (matchArr == null || !(numDashes == 2) || !(areacodenum == '520')) {
		alert('Invalid Phone Number. \nMust be 10 digits in the form NNN-NNN-NNNN.');
		return false;
	}
return true;
}

function emailValidation(email) {
var numDashes = email.split('@').length - 1
var numDashes2= email.split('.').length - 1
if ( !(numDashes == 1) || !(numDashes2 == 1)) {
		alert('Invalid Email address. ');
		return false;
	}
return true;
}

