function Validate(){
   var strContactName = document.ad_frm.ContactName.value;
   var strContactPhone = document.ad_frm.ContactPhone.value;
   var strfrom = document.ad_frm.from.value;
   strPhone = document.ad_frm.ContactPhone.value;
   var strBusinessName = document.ad_frm.BusinessName.value;
   var strBusinessAddress = document.ad_frm.BusinessAddress.value;
   var strBusinessPhone = document.ad_frm.BusinessPhone.value;
   var strWebLink = document.ad_frm.WebLink.value;
   var strAlertMessage = "Please enter the following:";
   var strFocus = false;
   var strReturn = true;
      if (!document.ad_frm.AgreeToTerms.checked){
      		document.ad_frm.AgreeToTerms.focus();
      		window.alert("An ad cannot be submitted without agreeing to Terms of Use.");
      		return false;}
 	if ((strContactName == '')){
			document.ad_frm.ContactName.focus();
           		strAlertMessage = strAlertMessage+"\n -"+"Contact Name";
			strFocus = true;
			strReturn = false;}			
	if ((strContactPhone == '')){
			if (!strFocus){document.ad_frm.ContactPhone.focus();}
			strAlertMessage = strAlertMessage+"\n -"+"Contact Phone";
			strFocus = true;
			strReturn = false;
	}else if (!PhoneValidation(strPhone)){
			document.ad_frm.ContactPhone.focus();
			return false;				
			}			
	if ((strfrom == '')){
			if (!strFocus){document.ad_frm.from.focus();}
			strAlertMessage = strAlertMessage+"\n -"+"Contact Email Address";
			strFocus = true;
			strReturn = false;
		}else if (!emailValidation(strfrom)){
			document.ad_frm.from.focus();
			return false;					
			}
if (!document.ad_frm.NotifyMe[0].checked & !document.ad_frm.NotifyMe[1].checked){
			if (!strFocus){document.ad_frm.NotifyMe[0].focus();}
			strAlertMessage = strAlertMessage+"\n -"+"A notification option";
			strFocus = true;
			strReturn = false;}
	if ((strBusinessName == '')){
			if (!strFocus){document.ad_frm.BusinessName.focus();}
			strAlertMessage = strAlertMessage+"\n -"+"Business Name";
			strFocus = true;
			strReturn = false;}			
	if ((strBusinessAddress == '')){
			if (!strFocus){document.ad_frm.BusinessAddress.focus();}
			strAlertMessage = strAlertMessage+"\n -"+"Business Address";
			strFocus = true;
			strReturn = false;}			
	if ((strBusinessPhone == '')){
			if (!strFocus){document.ad_frm.BusinessPhone.focus();}
			strAlertMessage = strAlertMessage+"\n -"+"Business Phone";
			strFocus = true;
			strReturn = false;}		
	if ((strWebLink == '' || strWebLink == 'www.')){
			if (!strFocus){document.ad_frm.WebLink.focus();}
			strAlertMessage = strAlertMessage+"\n -"+"A web link";
			strFocus = true;
			strReturn = 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.ad_frm.DCharacterCount.value=0;
		document.ad_frm.DCharacterCount.focus();
	}
	else{
	   document.ad_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
if ( !(numDashes == 1)) {
		alert('Invalid Email address. ');
		return false;
	}
return true;
}
