// BASED ON FORM GUARD:// 	Form Guard// 	Copyright Xin Yang 2003, 2004// 	Web Site: www.yxScripts.com// 	EMail: m_yangxin@hotmail.com// 	Last Updated: Sep-01-2004// 	This script is free as long as the copyright notice remains intact.// WITH SOME ADDITIONS/CHANGES BY GERARD GLEESON// to consolidate all error messagesvar totalAlert="";// form submit countervar submitCounter=0;// regular expressions used by checking functionsvar reNonBlank=/[\S]/;var reHexColor=/^#[0-9a-fA-F]{6}$/;var reInt=/^\d+$/;var reSignedInt=/^(\+|-)?\d+$/;var reFloat=/^\d+(\.\d+)?$/;var reSignedFloat=/^(\+|-)?\d+(\.\d+)?$/;var reChar=/^[\w\-]+$/;// GG Note: This is not the reEmail expression from the original Form Guard// script, instead I used the expression from "JavaScript & DHTML Cookbook",// by Danny Goodman (pub. O'Reilly, 2003). The original rejected single// character names (e.g. a@domain.com) which are valid.var reEMail=/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;var reIP=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;var rePostalCA=/^(\w\d){3}$/;var reURL=/^http(s)?\:\/\/\w[\w\-]+(\.\w[\w\-]+)+([\/\%\?\&\+\#\.\w\-]+)*$/;function rpChar(f) {  var df=f;  df=df.replace(/\\/g, '\\\\');  df=df.replace(/\//g, '\\\/');  df=df.replace(/\[/g, '\\\[');  df=df.replace(/\]/g, '\\\]');  df=df.replace(/\(/g, '\\\(');  df=df.replace(/\)/g, '\\\)');  df=df.replace(/\{/g, '\\\{');  df=df.replace(/\}/g, '\\\}');  df=df.replace(/\</g, '\\\<');  df=df.replace(/\>/g, '\\\>');  df=df.replace(/\|/g, '\\\|');  df=df.replace(/\*/g, '\\\*');  df=df.replace(/\?/g, '\\\?');  df=df.replace(/\+/g, '\\\+');  df=df.replace(/\^/g, '\\\^');  df=df.replace(/\$/g, '\\\$');  return df;}function rePhone(f) {  var df=rpChar(f);  df=df.replace(/d/gi, '\\d');  df=df.replace(/w/gi, '(\\w|\\d)');  return new RegExp('^'+df+'$');}function reDate(f) {  var df=rpChar(f);  df=df.replace(/dd/gi, '\\d\\d');  df=df.replace(/mm/gi, '\\d\\d');  df=df.replace(/yyyy/gi, '\\d\\d\\d\\d');  return new RegExp('^'+df+'$');}function reCharNM(n,m) {  return new RegExp("\^[\\w\\-]{"+n+","+m+"}\$");}function reNumberN(n,mode) {  return new RegExp("\^"+(mode!=0?"(\\+\|-)?":"")+"\\d{1,"+n+"}\$");}function reNumberN2(n,mode) {  return new RegExp("\^"+(mode!=0?"(\\+\|-)?":"")+"\\d{"+n+"}\$");}function reNumberNM(n,m,mode) {  return new RegExp("\^"+(mode!=0?"(\\+\|-)?":"")+"\\d{1,"+n+"}(\\.\\d{1,"+m+"})?\$");}function reNumberNM2(n,m,mode) {  return new RegExp("\^"+(mode!=0?"(\\+\|-)?":"")+"\\d{"+n+"}\\.\\d{"+m+"}\$");}// wrapper functionsfunction _checkValue(re, value, msg, mode) {  if (!re.test(value)) {    _alertIt(msg, mode);    return (mode && mode==1)?true:false;  }  return true;}function _alertIt(msg, mode) {  if (mode) {    totalAlert+=msg+"\n";  }  else {    totalAlert="";    alert(msg);  }}function _checkIt(re, field, msg, mode) {  if (!re.test(field.value)) {    _alertIt(msg, mode);    if (field.select) {      field.select();    }    if (field.focus) {      field.focus();    }    return (mode && mode==1)?true:false;  }  return true;}function noErrors() {  if (totalAlert=="") {    return true;  }  else {    alert(totalAlert);    totalAlert="";    return false;  }}// the checking functionsfunction goodPasswords(field1, field2, msg1, msg2, mode) {  if (nonBlank(field1, msg1, mode?2:0) && nonBlank(field2, msg1, mode?2:0)) {    if (field1.value == field2.value) {      return true;    }    else {      _alertIt(msg2, mode);    }  }  return (mode && mode==1)?true:false;}function goodPasswordsLen(field1, field2, n, m, msg1, msg2, msg3, mode) {  if (nonBlank(field1, msg1, mode?2:0) && nonBlank(field2, msg1, mode?2:0)) {    if (field1.value == field2.value) {      if (goodCharLen(n, m, field1, msg3, mode?2:0)) {        return true;      }    }    else {      _alertIt(msg2, mode);    }  }  return (mode && mode==1)?true:false;}function goodEMails(field1, field2, msg1, msg2, mode) {  if (goodEMail(field1, msg1, mode?2:0) && goodEMail(field2, msg1, mode?2:0)) {    if (field1.value == field2.value) {      return true;    }    else {      _alertIt(msg2, mode);    }  }  return (mode && mode==1)?true:false;}function goodEMail2(value, msg, mode) {  return _checkValue(reEMail, value, msg, mode);}function goodMultiEMails(field, msg, mode) {  var values = field.value.split(/\s*[,;]\s*/), allGood = reNonBlank.test(field.value);  if (!allGood) {    _alertIt(msg, mode);  }  for (var i = 0; i < values.length && allGood; i++) {    if (reNonBlank.test(values[i])) {      allGood = goodEMail2(values[i], msg, mode?2:0);    }  }  return allGood?true:(mode && mode==1)?true:false;}function goodPhone(pf, field, msg, mode) {  return _checkIt(rePhone(pf), field, msg, mode);}function goodPostalCA(field, msg, mode) {  return _checkIt(rePostalCA, field, msg, mode);}function goodDate(df, field, msg, mode) {  if (_checkIt(reDate(df), field, msg, mode?2:0)) {    var di=field.value;    var y4=df.search(/yyyy/i), y=di.substring(y4, y4+4)-0;    var m2=df.search(/mm/i), m=di.substring(m2, m2+2)-1;    var d2=df.search(/dd/i), d=di.substring(d2, d2+2)-0;    var dd=new Date(y, m, d);    if (y==dd.getFullYear() && m==dd.getMonth() && d==dd.getDate()) {      return true;    }    else {      _alertIt(msg, mode);      field.select();      field.focus();    }  }  return (mode && mode==1)?true:false;}function goodIP(field, msg, mode) {  return _checkIt(reIP, field, msg, mode);}function goodChar(field, msg, mode) {  return _checkIt(reChar, field, msg, mode);}function goodEMail(field, msg, mode) {  return _checkIt(reEMail, field, msg, mode);}function goodInt(field, msg, mode) {  return _checkIt(reInt, field, msg, mode);}function goodSignedInt(field, msg, mode) {  return _checkIt(reSignedInt, field, msg, mode);}function goodFloat(field, msg, mode) {  return _checkIt(reFloat, field, msg, mode);}function goodSignedFloat(field, msg, mode) {  return _checkIt(reSignedFloat, field, msg, mode);}function goodIntLen(n, field, msg, mode) {  return _checkIt(reNumberN(n,0), field, msg, mode);}function goodSignedIntLen(n, field, msg, mode) {  return _checkIt(reNumberN(n,1), field, msg, mode);}function goodIntLen2(n, field, msg, mode) {  return _checkIt(reNumberN2(n,0), field, msg, mode);}function goodSignedIntLen2(n, field, msg, mode) {  return _checkIt(reNumberN2(n,1), field, msg, mode);}function goodCharLen(n, m, field, msg, mode) {  return _checkIt(reCharNM(n,m), field, msg, mode);}function goodFloatLen(n, m, field, msg, mode) {  return _checkIt(reNumberNM(n,m,0), field, msg, mode);}function goodSignedFloatLen(n, m, field, msg, mode) {  return _checkIt(reNumberNM(n,m,1), field, msg, mode);}function goodFloatLen2(n, m, field, msg, mode) {  return _checkIt(reNumberNM2(n,m,0), field, msg, mode);}function goodSignedFloatLen2(n, m, field, msg, mode) {  return _checkIt(reNumberNM2(n,m,1), field, msg, mode);}function _rangeIt(field, r1, r2, msg, mode) {  if (field.value>=r1 && field.value<=r2) {    return true;  }  else {    _alertIt(msg, mode);    field.select();    field.focus();    return (mode && mode==1)?true:false;  }}function rangeInt(field, r1, r2, msg, mode) {  if (goodInt(field, msg, mode?2:0)) {    return _rangeIt(field, r1, r2, msg, mode);  }  return (mode && mode==1)?true:false;}function rangeSignedInt(field, r1, r2, msg, mode) {  if (goodSignedInt(field, msg, mode?2:0)) {    return _rangeIt(field, r1, r2, msg, mode);  }  return (mode && mode==1)?true:false;}function rangeFloat(field, r1, r2, msg, mode) {  if (goodFloat(field, msg, mode?2:0)) {    return _rangeIt(field, r1, r2, msg, mode);  }  return (mode && mode==1)?true:false;}function rangeSignedFloat(field, r1, r2, msg, mode) {  if (goodSignedFloat(field, msg, mode?2:0)) {    return _rangeIt(field, r1, r2, msg, mode);  }  return (mode && mode==1)?true:false;}function rangeIntLen(n, field, r1, r2, msg, mode) {  if (goodIntLen(n, field, msg, mode?2:0)) {    return _rangeIt(field, r1, r2, msg, mode);  }  return (mode && mode==1)?true:false;}function rangeSignedIntLen(n, field, r1, r2, msg, mode) {  if (goodSignedIntLen(n, field, msg, mode?2:0)) {    return _rangeIt(field, r1, r2, msg, mode);  }  return (mode && mode==1)?true:false;}function rangeIntLen2(n, field, r1, r2, msg, mode) {  if (goodIntLen2(n, field, msg, mode?2:0)) {    return _rangeIt(field, r1, r2, msg, mode);  }  return (mode && mode==1)?true:false;}function rangeSignedIntLen2(n, field, r1, r2, msg, mode) {  if (goodSignedIntLen2(n, field, msg, mode?2:0)) {    return _rangeIt(field, r1, r2, msg, mode);  }  return (mode && mode==1)?true:false;}function rangeFloatLen(n, m, field, r1, r2, msg, mode) {  if (goodFloatLen(n, m, field, msg, mode?2:0)) {    return _rangeIt(field, r1, r2, msg, mode);  }  return (mode && mode==1)?true:false;}function rangeSignedFloatLen(n, m, field, r1, r2, msg, mode) {  if (goodSignedFloatLen(n, m, field, msg, mode?2:0)) {    return _rangeIt(field, r1, r2, msg, mode);  }  return (mode && mode==1)?true:false;}function rangeFloatLen2(n, m, field, r1, r2, msg, mode) {  if (goodFloatLen2(n, m, field, msg, mode?2:0)) {    return _rangeIt(field, r1, r2, msg, mode);  }  return (mode && mode==1)?true:false;}function rangeSignedFloatLen2(n, m, field, r1, r2, msg, mode) {  if (goodSignedFloatLen2(n, m, field, msg, mode?2:0)) {    return _rangeIt(field, r1, r2, msg, mode);  }  return (mode && mode==1)?true:false;}function _dd(n) {  return (n<10)?"0"+n:""+n;}function _getOffset(n) {  var d=new Date();  if (n!=0) {    d.setTime(d.getTime()+n*86400000);  }  return d.getFullYear()+""+_dd(d.getMonth()+1)+""+_dd(d.getDate())+"";}function _stringIt(df, d) {  var y4=df.search(/yyyy/i), m2=df.search(/mm/i), d2=df.search(/dd/i);  return d.substring(y4, y4+4)+d.substring(m2, m2+2)+d.substring(d2, d2+2);}function rangeDate(df, field, r1, r2, msg, mode) {  if (goodDate(df, field, msg, mode?2:0)) {    var d=_stringIt(df, field.value);    var r1x="", r2x="";    if (r1.search(/^\d+$/)!=-1) {      r1x=_getOffset(r1-0);    }    else {      r1x=_stringIt(df, r1);    }    if (r2.search(/^\d+$/)!=-1) {      r2x=_getOffset(r2-0);    }    else {      r2x=_stringIt(df, r2);    }    if (d<r1x || d>r2x) {      _alertIt(msg, mode);      field.select();      field.focus();    }    else {      return true;    }  }  return (mode && mode==1)?true:false;}function goodDateRange(df, field1, field2, msg, mode) {  if (goodDate(df, field1, msg, mode?2:0) && goodDate(df, field2, msg, mode?2:0)) {    if (_stringIt(df, field1.value)>_stringIt(df, field2.value)) {      _alertIt(msg, mode);      field1.focus();    }    else {      return true;    }  }  return (mode && mode==1)?true:false;}function goodDateRange2(df, field1, field2, msg, mode) {  if (goodDate(df, field1, msg, mode?2:0) && goodDate(df, field2, msg, mode?2:0)) {    if (_stringIt(df, field1.value)>=_stringIt(df, field2.value)) {      _alertIt(msg, mode);      field1.focus();    }    else {      return true;    }  }  return (mode && mode==1)?true:false;}function goodHexColor(field, msg, mode) {  return _checkIt(reHexColor, field, msg, mode);}function nonBlank(field, msg, mode) {  if (field.type) {    if (/file|select|text|password/.test(field.type)) {      return _checkIt(reNonBlank, field, msg, mode);    }    else if (/radio|checkbox/.test(field.type)) {      if (field.checked) {        return true;      }      else {        _alertIt(msg, mode);        field.focus();        return (mode && mode==1)?true:false;      }    }    else {      _alertIt("Invalid field for nonBlank() checking", mode);      return (mode && mode==1)?true:false;    }  }  else if (field.length && field[0].type && /radio|checkbox/.test(field[0].type)) {    for (var i=0; i<field.length; i++) {      if (field[i].checked) { return true; }    }    _alertIt(msg, mode);    field[0].focus();    return (mode && mode==1)?true:false;  }  else {    _alertIt("Invalid field for nonBlank() checking", mode);    return (mode && mode==1)?true:false;  }}function goodRadioedFields(form, fn, re, msgs, msg, mode) {  for (var i=0; i<form[fn].length; i++) {    if (form[fn][i].checked) {      return _checkIt(re, form[form[fn][i].value], msgs[i], mode);    }  }  _alertIt(msg, mode);  return (mode && mode==1)?true:false;}function goodRadioedFields2(form, fn, re, msgs, msg, mode) {  for (var i=0; i<form[fn].length; i++) {    if (form[fn][i].checked) {      return _checkIt(re[i], form[form[fn][i].value], msgs[i], mode);    }  }  _alertIt(msg, mode);  return (mode && mode==1)?true:false;}function noBadWords(field, strict, words, msg, mode) {  var lw=[], nwb=strict?'':'\\b';  for (var i=0; i<words.length; i++) {    lw[i]=nwb+words[i].toLowerCase()+nwb;  }  var re=new RegExp(lw.join("|"), "i");  if (re.test(field.value)) {    _alertIt(msg, mode);    return (mode && mode==1)?true:false;  }  else {    return true;  }}// credit card checking codes taken from Netscape LivePayment samples codes and modified to fit Form Guardfunction goodCreditCard(field, msg, mode) {  var sum=0, mul=1, l=field.value.length;  var digit, tproduct;  if (_checkIt(reInt, field, msg, mode?2:0)) {    for (var i=0; i<l; i++) {      digit=field.value.substring(l-i-1,l-i);      tproduct=parseInt(digit ,10)*mul;      if (tproduct>=10) {        sum+=(tproduct%10)+1;      }      else {        sum+=tproduct;      }      if (mul==1) {        mul++;      }      else {        mul--;      }    }    if ((sum%10)==0) {      return true;    }    else {      _alertIt(msg, mode);      return (mode && mode==1)?true:false;    }  }}function goodVisa(field, msg, mode) {  if ((field.value.length==16 || field.value.length==13) && field.value.substring(0,1)==4) {    return goodCreditCard(field, msg, mode);  }  else {    _alertIt(msg, mode);    return (mode && mode==1)?true:false;  }}function goodMasterCard(field, msg, mode) {  var firstdig=field.value.substring(0,1), seconddig=field.value.substring(1,2);  if (field.value.length==16 && firstdig==5 && (seconddig>=1 && seconddig<=5)) {    return goodCreditCard(field, msg, mode);  }  else {    _alertIt(msg, mode);    return (mode && mode==1)?true:false;;  }}function goodAmericanExpress(field, msg, mode) {  var firstdig=field.value.substring(0,1), seconddig=field.value.substring(1,2);  if (field.value.length==15 && firstdig==3 && (seconddig==4 || seconddig==7)) {    return goodCreditCard(field, msg, mode);  }  else {    _alertIt(msg, mode);    return (mode && mode==1)?true:false;;  }}function goodDinersClub(field, msg, mode) {  var firstdig=field.value.substring(0,1), seconddig=field.value.substring(1,2);  if (field.value.length==14 && firstdig==3 && (seconddig==0 || seconddig==6 || seconddig==8)) {    return goodCreditCard(field, msg, mode);  }  else {    _alertIt(msg, mode);    return (mode && mode==1)?true:false;;  }}function goodCarteBlanche(field, msg, mode) {  return goodDinersClub(field, msg, mode);}function goodDiscover(field, msg, mode) {  var first4digs=field.value.substring(0,4);  if (field.value.length==16 && first4digs=="6011") {    return goodCreditCard(field, msg, mode);  }  else {    _alertIt(msg, mode);    return (mode && mode==1)?true:false;;  }}function goodEnRoute(field, msg, mode) {  var first4digs=field.value.substring(0,4);  if (field.value.length==15 && (first4digs=="2014" || first4digs=="2149")) {    return goodCreditCard(field, msg, mode);  }  else {    _alertIt(msg, mode);    return (mode && mode==1)?true:false;;  }}function goodJCB(field, msg, mode) {  var first4digs=field.value.substring(0,4);  if (field.value.length==16 && (first4digs=="3088" || first4digs=="3096" || first4digs=="3112" || first4digs=="3158" || first4digs=="3337" || first4digs=="3528")) {    return goodCreditCard(field, msg, mode);  }  else {    _alertIt(msg, mode);    return (mode && mode==1)?true:false;;  }}function notSubmitted(msg) {  if (submitCounter==0) {    submitCounter=1;    return true;  }  else {    alert(msg);    return false;  }}function goodURL(field, msg, mode) {  return _checkIt(reURL, field, msg, mode);}function validRequired(formField,fieldLabel){  var result = true;  if (formField.value == "")  {    alert('Please enter a value for the "' + fieldLabel +'" field.');    formField.focus();    result = false;  }  return result;}function goodStringLen(n, m, field, msg) {  var str = field.value;  if ((str == null) || (str.length < n) || (str.length > m)) {    alert(msg);    return false;  } else {    return true;  }}function mygoodPhone(field, msg) {  // hard-coded to "(ddd) ddd-dddd" format, but allow trailing information such as ext. or comment  var str = field.value;  if ((str == null) || (str.length < 14)) {    alert(msg);    field.focus();    return false;  }  if (field.value.substring(0,1) != "(") {    alert(msg);    field.focus();    return false;  }  if (field.value.substring(4,6) != ") ") {    alert(msg);    field.focus();    return false;  }  if (field.value.substring(9,10) != "-") {    alert(msg);    field.focus();    return false;  }  var d1 = field.value.substring(1,4);  var d2 = field.value.substring(6,9);  var d3 = field.value.substring(10,14);  var nums = d1 + d2 + d3;  nums = nums.toString();  if (!nums.match(reInt)) {    alert(msg);    field.focus();    return false;  }  return true;}function validateChangePasswordForm(theForm){  // Customize these calls for your form  // Start ------->  if (!validRequired(theForm.password,"Old Password"))    return false;  if (!goodPasswordsLen(theForm.password1, theForm.password2, 8, 16, "Please input both New Password fields", "New Passwords do not match, please try again", "Passwords must be between 8 and 16 characters in length."))    return false;  // <--------- End  return true;}function validateUpdateMemberForm(theForm){  // Customize these calls for your form  // Start ------->  if (!validRequired(theForm.name,"Business Name"))    return false;  if (!goodStringLen(3, 54, theForm.name, "Please enter a valid Business Name (minimum 3 characters, maximum 54)"))    return false;  if (theForm.web_site.value) {    if (!goodURL(theForm.web_site, "Invalid Web Site address, format should be http://sitename.type"))      return false;  }  if (!validRequired(theForm.contact_name,"Contact Name"))    return false;  if (theForm.contact_email.value) {    if (!goodEMail(theForm.contact_email, "Invalid Email address, format should be user@sitename.type"))      return false;  }  if (!validRequired(theForm.address_line1,"Address Line 1"))    return false;  if (!validRequired(theForm.city_town,"City/Town"))    return false;  if (!validRequired(theForm.zip,"Zip Code"))    return false;  if (theForm.phone.value) {    if (!mygoodPhone(theForm.phone, "Please enter a Phone number with area code, format: (nnn) nnn-nnnn."))      return false;  }  if (theForm.phone2.value) {    if (!mygoodPhone(theForm.phone2, "Please enter a Second Phone number with area code, format: (nnn) nnn-nnnn, or leave blank."))      return false;  }  if (theForm.fax.value) {    if (!mygoodPhone(theForm.fax, "Please enter a Fax number with area code, format: (nnn) nnn-nnnn, or leave blank."))      return false;  }    // alert('Primary Category ID "' + theForm.primary_category_id.value +'".');  if (theForm.primary_category_id.value == "32") {  	  if (!goodStringLen(0, 100, theForm.description, "Description exceeds maximum length for Associates of 100 characters (including spaces and punctuation)."))    	return false;  	  if (!goodStringLen(0, 50, theForm.keywords, "Keywords exceed maximum length for Associates of 50 characters (including spaces and punctuation)."))    	return false;  } else {  	  if (!goodStringLen(0, 200, theForm.description, "Description exceeds maximum length of 200 characters (including spaces and punctuation)."))    	return false;  	  if (!goodStringLen(0, 100, theForm.keywords, "Keywords exceed maximum length of 100 characters (including spaces and punctuation)."))    	return false;  }  // <--------- End  return true;}function validateUpdateUserForm(theForm){  // Customize these calls for your form  // Start ------->  if (!validRequired(theForm.uname,"Username"))    return false;  if (!goodStringLen(4, 64, theForm.uname, "Please enter a Username (minimum 4 characters, maximum 64)"))    return false;  if (!validRequired(theForm.fullname,"Full Name"))    return false;  if (!goodEMail(theForm.contact_email, "Please enter a valid Email address."))    return false;  if (!validRequired(theForm.address_line1,"Address Line 1"))    return false;  if (!validRequired(theForm.city_town,"City/Town"))    return false;  if (!validRequired(theForm.zip,"Zip"))    return false;  if (!mygoodPhone(theForm.phone, "Please enter a Phone number with area code, format: (nnn) nnn-nnnn."))    return false;  if (theForm.phone2.value) {    if (!mygoodPhone(theForm.phone2, "Please enter a Second Phone number with area code, format: (nnn) nnn-nnnn, or leave blank."))      return false;  }  if (theForm.fax.value) {    if (!mygoodPhone(theForm.fax, "Please enter a Fax number with area code, format: (nnn) nnn-nnnn, or leave blank."))      return false;  }  // <--------- End  return true;}function validateMemberUserForm(theForm){  // Customize these calls for your form  // Start ------->  // Member Fields:  if (!validRequired(theForm.name,"Business Name"))    return false;  if (!goodStringLen(3, 54, theForm.name, "Please enter a valid Business Name (minimum 3 characters, maximum 54)"))    return false; if (theForm.web_site.value) {    if (!goodURL(theForm.web_site, "Invalid Web Site address, format should be http://sitename.type"))      return false;  }  if (!validRequired(theForm.contact_name,"Contact Name"))    return false;  if (theForm.contact_email.value) {    if (!goodEMail(theForm.contact_email, "Invalid Email address, format should be user@sitename.type"))      return false;  }  if (!validRequired(theForm.address_line1,"Address Line 1"))    return false;  if (!validRequired(theForm.city_town,"City/Town"))    return false;  if (!validRequired(theForm.zip,"Zip Code"))    return false;  if (!mygoodPhone(theForm.phone, "Please enter a Phone number with area code, format: (nnn) nnn-nnnn."))    return false;  if (theForm.phone2.value) {    if (!mygoodPhone(theForm.phone2, "Please enter a Second Phone number with area code, format: (nnn) nnn-nnnn, or leave blank."))      return false;  }  if (theForm.fax.value) {    if (!mygoodPhone(theForm.fax, "Please enter a Fax number with area code, format: (nnn) nnn-nnnn, or leave blank."))      return false;  }  if (!nonBlank(theForm.primary_category_id,"Please select a Business Category"))    return false;  if (theForm.primary_category_id.value == "32") {  	  if (!goodStringLen(0, 100, theForm.description, "Description exceeds maximum length for Associates of 100 characters (including spaces and punctuation)."))    	return false;  	  if (!goodStringLen(0, 50, theForm.keywords, "Keywords exceed maximum length for Associates of 50 characters (including spaces and punctuation)."))    	return false;  } else {  	  if (!goodStringLen(0, 200, theForm.description, "Description exceeds maximum length of 200 characters (including spaces and punctuation)."))    	return false;  	  if (!goodStringLen(0, 100, theForm.keywords, "Keywords exceed maximum length of 100 characters (including spaces and punctuation)."))    	return false;  }  // User Fields  if (!validRequired(theForm.user_username,"Username"))    return false;  if (!goodStringLen(4, 64, theForm.user_username, "Please enter a Username (minimum 4 characters, maximum 64)"))    return false;  if (!validRequired(theForm.user_password,"Password"))    return false;  if (!goodStringLen(8, 16, theForm.user_password, "Please enter a Password (minimum 8 characters, maximum 16)"))    return false;  if (!validRequired(theForm.user_fullname,"Full Name"))    return false;  if (!goodEMail(theForm.user_contact_email, "Please enter a valid User Email address."))    return false;  if (!validRequired(theForm.user_address_line1,"User Address Line 1"))    return false;  if (!validRequired(theForm.user_city_town,"User City/Town"))    return false;  if (!validRequired(theForm.user_zip,"User Zip"))    return false;  if (!mygoodPhone(theForm.user_phone, "Please enter the User's Phone number with area code, format: (nnn) nnn-nnnn."))    return false;  if (theForm.user_phone2.value) {    if (!mygoodPhone(theForm.user_phone2, "Please enter a Second Phone number with area code, format: (nnn) nnn-nnnn, or leave blank."))      return false;  }  if (theForm.user_fax.value) {    if (!mygoodPhone(theForm.user_fax, "Please enter a Fax number with area code, format: (nnn) nnn-nnnn, or leave blank."))      return false;  }  // <--------- End  return true;}function validateMinMemberUserForm(theForm){  // Customize these calls for your form  // Start ------->  // Member Fields:  if (!validRequired(theForm.name,"Business Name"))    return false;  if (!goodStringLen(3, 54, theForm.name, "Please enter a valid Business Name (minimum 3 characters, maximum 54)"))    return false; if (theForm.web_site.value) {    if (!goodURL(theForm.web_site, "Invalid Web Site address, format should be http://sitename.type"))      return false;  }  if (theForm.contact_email.value) {    if (!goodEMail(theForm.contact_email, "Invalid Email address, format should be user@sitename.type"))      return false;  }  if (theForm.phone.value) {    if (!mygoodPhone(theForm.phone, "Please enter a Phone number with area code, format: (nnn) nnn-nnnn, or leave blank."))      return false;  }  if (theForm.phone2.value) {    if (!mygoodPhone(theForm.phone2, "Please enter a Second Phone number with area code, format: (nnn) nnn-nnnn, or leave blank."))      return false;  }  if (theForm.fax.value) {    if (!mygoodPhone(theForm.fax, "Please enter a Fax number with area code, format: (nnn) nnn-nnnn, or leave blank."))      return false;  }  if (!nonBlank(theForm.primary_category_id,"Please select a Business Category"))    return false;  if (theForm.primary_category_id.value == "32") {  	  if (!goodStringLen(0, 100, theForm.description, "Description exceeds maximum length for Associates of 100 characters (including spaces and punctuation)."))    	return false;  	  if (!goodStringLen(0, 50, theForm.keywords, "Keywords exceed maximum length for Associates of 50 characters (including spaces and punctuation)."))    	return false;  } else {  	  if (!goodStringLen(0, 200, theForm.description, "Description exceeds maximum length of 200 characters (including spaces and punctuation)."))    	return false;  	  if (!goodStringLen(0, 100, theForm.keywords, "Keywords exceed maximum length of 100 characters (including spaces and punctuation)."))    	return false;  }  // User Fields  if (!validRequired(theForm.user_username,"Username"))    return false;  if (!goodStringLen(4, 64, theForm.user_username, "Please enter a Username (minimum 4 characters, maximum 64)"))    return false;  if (!validRequired(theForm.user_password,"Password"))    return false;  if (!goodStringLen(8, 16, theForm.user_password, "Please enter a Password (minimum 8 characters, maximum 16)"))    return false;  if (theForm.user_contact_email.value) {    if (!goodEMail(theForm.user_contact_email, "Invalid Email address, format should be user@sitename.type"))      return false;  }  if (theForm.user_phone.value) {    if (!mygoodPhone(theForm.user_phone, "Please enter the User's  Second Phone number with area code, format: (nnn) nnn-nnnn, or leave blank."))      return false;  }  if (theForm.user_phone2.value) {    if (!mygoodPhone(theForm.user_phone2, "Please enter a Second Phone number with area code, format: (nnn) nnn-nnnn, or leave blank."))      return false;  }  if (theForm.user_fax.value) {    if (!mygoodPhone(theForm.user_fax, "Please enter a Fax number with area code, format: (nnn) nnn-nnnn, or leave blank."))      return false;  }  // <--------- End  return true;}function validateEventForm(theForm){  // Customize these calls for your form  // Start ------->         // title  if (!validRequired(theForm.title, "Event Title"))    return false;      if (theForm.recurring.value == "no") {  		// Event Date - required    	if(!goodDate("yyyy-mm-dd", theForm.event_date, "Please enter a valid Event Date in YYYY-MM-DD format"))    	return false;     	  } else {  		// Start Date - required	if(!goodDate("yyyy-mm-dd", theForm.event_date, "Please enter a valid Start Date in YYYY-MM-DD format"))	    return false;  	// End Date - required	if(!goodDate("yyyy-mm-dd", theForm.end_date, "Please enter a valid End Date in YYYY-MM-DD format"))	    return false;	if(!goodDateRange("yyyy-mm-dd", theForm.event_date, theForm.end_date, "Please enter a valid date range."))    	return false;    	  	if (theForm.recurring.value == "every_week") {	  if ((!theForm.weekly_sunday.checked) && (!theForm.weekly_monday.checked) && (!theForm.weekly_tuesday.checked)	  		 && (!theForm.weekly_wednesday.checked) && (!theForm.weekly_thursday.checked) && (!theForm.weekly_friday.checked)	  		 && (!theForm.weekly_saturday.checked)) {	  	if (theForm.weekly_sunday.focus) {	      theForm.weekly_sunday.focus();	    }	  	alert("Please select at least 1 Day of the Week");	    return false;	  }    	}  	if (theForm.recurring.value == "every_month") {  		if (!nonBlank(theForm.monthly_each_or_every, "Please choose Days of Months")) {    		return false;  		}  	}  }  //short description 120 chars  if (!goodStringLen(0, 120, theForm.short_description, "Short Description exceeds maximum length of 120 characters (including spaces and punctuation)."))    return false;  //(description) 10000 chars  if (!goodStringLen(0, 10000, theForm.description, "Long Description exceeds maximum length of 10,000 characters (including spaces and punctuation)."))    return false;      //categories - at least one required  if ((!theForm.cat_art.checked) && (!theForm.cat_books.checked) && (!theForm.cat_business.checked)  		 && (!theForm.cat_charity.checked) && (!theForm.cat_classes.checked)  && (!theForm.cat_comedy.checked)  		 && (!theForm.cat_community.checked) && (!theForm.cat_crafts.checked)  && (!theForm.cat_dance.checked)  		 && (!theForm.cat_fair.checked) && (!theForm.cat_film.checked)  && (!theForm.cat_food.checked)  		 && (!theForm.cat_health.checked) && (!theForm.cat_family.checked)  && (!theForm.cat_lectures.checked)  		 && (!theForm.cat_music.checked) && (!theForm.cat_museum.checked)  && (!theForm.cat_nightlife.checked)  		 && (!theForm.cat_misc.checked) && (!theForm.cat_outdoors.checked)  && (!theForm.cat_politics.checked)  		 && (!theForm.cat_shopping.checked) && (!theForm.cat_sports.checked)  && (!theForm.cat_theater.checked)  		 && (!theForm.cat_farm.checked) && (!theForm.cat_military.checked)  && (!theForm.cat_garden.checked)  		 && (!theForm.cat_religion.checked)) {  	if (theForm.cat_art.focus) {      theForm.cat_art.focus();    }  	alert("Please select at least 1 Category");    return false;  }          //(contact email) valid email  if (theForm.contact_email.value) {    if (!goodEMail(theForm.contact_email, "Invalid Email address, format should be user@sitename.type"))      return false;  }  //(phone) valid phone  if (theForm.phone.value) {    if (!mygoodPhone(theForm.phone, "Please enter a Phone number with area code, format: (nnn) nnn-nnnn"))      return false;  }  //(web site) valid URL - relax this - we want to allow "www.site.com" as well as "http://www.site.com"  //if (theForm.web_site.value) {  //  if (!goodURL(theForm.web_site, "Invalid Web Site address, format should be http://sitename.type"))  //    return false;  //}  //town  if (!validRequired(theForm.town,"Town(s)"))    return false;  // <--------- End  return true;}function validateEventPublicForm(theForm){  // Customize these calls for your form  // Start ------->    // submitter name  if (!validRequired(theForm.submitter_name, "Your Name"))    return false;  // submitter email  if (!validRequired(theForm.submitter_email, "Your Email Address"))    return false;  if (!goodEMail(theForm.submitter_email, "Invalid Email address, format should be user@sitename.type"))      return false;        return (validateEventForm(theForm));  // <--------- End}function validatePromotionForm(theForm){  // Customize these calls for your form  // Start ------->  // title  if (!validRequired(theForm.title, "Event Title"))    return false;  // Start Date - required  if(!goodDate("yyyy-mm-dd", theForm.start_date, "Please enter a valid Start Date in YYYY-MM-DD format"))    return false;  // (End Date) - if present should be a valid date range  if (theForm.end_date.value) {    if(!goodDate("yyyy-mm-dd", theForm.end_date, "Please enter a valid End Date in YYYY-MM-DD format, or leave blank."))      return false;  }  if (theForm.end_date.value) {    if(!goodDateRange("yyyy-mm-dd", theForm.start_date, theForm.end_date, "Please enter a valid date range, or leave End Date blank for one day events."))    return false;  }  //short description 20-100 chars  if (!goodStringLen(20, 100, theForm.short_description, "Short Description must be between 20 and 100 characters (including spaces and punctuation)."))    return false;  //(description) 10000 chars  if (!goodStringLen(0, 10000, theForm.description, "Long Description exceeds maximum length of 10000 characters (including spaces and punctuation)."))    return false;  //contact name  //(contact email) valid email  if (theForm.contact_email.value) {    if (!goodEMail(theForm.contact_email, "Invalid Email address, format should be user@sitename.type"))      return false;  }  //(phone) valid phone  if (theForm.phone.value) {    if (!mygoodPhone(theForm.phone, "Please enter a Phone number with area code, format: (nnn) nnn-nnnn"))      return false;  }  //(web site) valid URL  if (theForm.web_site.value) {    if (!goodURL(theForm.web_site, "Invalid Web Site address, format should be http://sitename.type"))      return false;  }  // <--------- End  return true;}function validateRealEstateForm(theForm){  // Customize these calls for your form  // Start ------->  // property type  if (!nonBlank(theForm.property_type, "Please select a Property Type"))    return false;  // town  if (!validRequired(theForm.town, "Town"))    return false;  // price  if (!validRequired(theForm.price, "Price"))    return false;  // broker  if (!validRequired(theForm.listing_broker, "Broker"))    return false;  // broker's phone  if (!validRequired(theForm.listing_broker_phone, "Broker's Phone"))    return false;      //(phone) valid phone  if (theForm.listing_broker_phone.value) {    if (!mygoodPhone(theForm.listing_broker_phone, "Please enter Broker's Phone number with area code, format: (nnn) nnn-nnnn"))      return false;  }      //(web site) valid URL  if (theForm.listing_broker_url.value) {    if (!goodURL(theForm.listing_broker_url, "Invalid address for Broker's Website, format should be http://sitename.type"))      return false;  }  // <--------- End  return true;}function validateSignSurveyForm(theForm){  // Customize these calls for your form  // Start ------->  // property type  // comments  if (!validRequired(theForm.comments, "Comments"))    return false;  // name  if (!validRequired(theForm.name, "First & Last Name"))    return false;      if (!goodStringLen(5, 80, theForm.name, "First & Last Name must be between 5 and 80 characters (including spaces and punctuation)."))    return false;  // email address  if (!validRequired(theForm.email, "Email Address"))    return false;  //(contact email) valid email  if (theForm.email.value) {    if (!goodEMail(theForm.email, "Invalid Email address, format should be user@sitename.type"))      return false;  }  // <--------- End  return true;}function validateSurveyForm(theForm){  // Customize these calls for your form  // Start ------->  if (!nonBlank(theForm.q1,"Please answer Question 1")) {    return false;  }    if ((!theForm.q2_1.checked) && (!theForm.q2_2.checked) && (!theForm.q2_3.checked) && (!theForm.q2_4.checked)) {  	if (theForm.q2_1.focus) {      theForm.q2_1.focus();    }  	alert("Please answer Question 2");    return false;  }  if ((theForm.q2_2.checked) && ((theForm.q2_2month.value == 0) || (theForm.q2_2year.value == 0))) {  	if (theForm.q2_2month.focus) {      theForm.q2_2month.focus();    }  	alert("Please complete Question 2: indicate when you will visit");    return false;  }  if (!nonBlank(theForm.q3,"Please answer Question 3")) {    return false;  }    if ((!theForm.q4_1.checked) && (!theForm.q4_2.checked) && (!theForm.q4_3.checked)  		 && (!theForm.q4_4.checked) && (!theForm.q4_5.checked)  && (!theForm.q4_6.checked)) {  	if (theForm.q4_1.focus) {      theForm.q4_1.focus();    }  	alert("Please answer Question 4");    return false;  }    if ((!theForm.q5_1.checked) && (!theForm.q5_2.checked) && (!theForm.q5_3.checked)  		 && (!theForm.q5_4.checked) && (!theForm.q5_5.checked)  && (!theForm.q5_6.checked)  		 && (!theForm.q5_7.checked) && (!theForm.q5_8.checked)  && (!theForm.q5_9.checked)  		 && (!theForm.q5_10.checked) && (!theForm.q5_11.checked)  && (!theForm.q5_12.checked)  		 && (!theForm.q5_13.checked) && (!theForm.q5_14.checked)  && (!theForm.q5_15.checked)  		 && (!theForm.q5_16.checked) && (!theForm.q5_17.checked)  && (!theForm.q5_18.checked)  		 && (!theForm.q5_19.checked)) {  	if (theForm.q5_1.focus) {      theForm.q5_1.focus();    }  	alert("Please answer Question 5");    return false;  }    if ((theForm.q6adults.value == 0) && (theForm.q6children.value == 0)) {  	if (theForm.q6adults.focus) {      theForm.q6adults.focus();    }  	alert("Please answer Question 6");    return false;  }    if (!nonBlank(theForm.q8,"Please answer Question 8")) {    return false;  }    if ((!theForm.q9_1.checked) && (!theForm.q9_2.checked) && (!theForm.q9_3.checked)  		 && (!theForm.q9_4.checked) && (!theForm.q9_5.checked) && (!theForm.q9_6.checked)  		 && (!theForm.q9_7.checked) && (!theForm.q9_8.checked) && (!theForm.q9_9.checked)&& (!theForm.q9_10.checked)  		 && (!theForm.q9_11.checked) && (!theForm.q9_12.checked) && (!theForm.q9_13.checked)  		 && (!theForm.q9_14.checked) && (!theForm.q9_15.checked) && (!theForm.q9_16.checked)  		 && (!theForm.q9_17.checked) && (!theForm.q9_18.checked) && (!theForm.q9_19.checked)&& (!theForm.q9_20.checked)  		 && (!theForm.q9_21.checked) && (!theForm.q9_22.checked) && (!theForm.q9_23.checked)  		 && (!theForm.q9_24.checked) && (!theForm.q9_25.checked) && (!theForm.q9_26.checked)  		 && (!theForm.q9_27.checked) && (!theForm.q9_28.checked) && (!theForm.q9_29.checked)&& (!theForm.q9_30.checked)  		 && (!theForm.q9_31.checked) && (!theForm.q9_32.checked) && (!theForm.q9_33.checked)  		 && (!theForm.q9_34.checked) && (!theForm.q9_35.checked) && (!theForm.q9_36.checked)  		 && (!theForm.q9_37.checked) && (!theForm.q9_38.checked) && (!theForm.q9_39.checked)&& (!theForm.q9_40.checked)  		 && (!theForm.q9_41.checked) && (!theForm.q9_42.checked) && (!theForm.q9_43.checked)  		 && (!theForm.q9_44.checked) && (!theForm.q9_45.checked)) {  	if (theForm.q9_1.focus) {      theForm.q9_1.focus();    }  	alert("Please answer Question 9");    return false;  }    if ((theForm.q11state.value == "") && (theForm.q11country.value == "")) {  	alert ("Please answer Question 11");    return false;  }    // email address  if (!nonBlank(theForm.email, "Please provide your Email address")) {    return false;  }    //(contact email) valid email  if (theForm.email.value) {    if (!goodEMail(theForm.email, "Invalid Email address, format should be user@sitename.type"))      return false;  }  // <--------- End  return true;}