function radioCheck() {
var check_length = 0
var result = false
if(document.form.hereabout.length!=null){//when multiple radios
check_length=document.form.hereabout.length
for (var counter = 0; counter < document.form.hereabout.length; counter++)
{
if (document.form.hereabout[counter].checked)
result = true
}
}else{ // when there is only one radio button
if (document.form.hereabout.checked)
result = true
}
if(!result)
alert('Please select were you heard about our services.')
return result
}

function validateEmail(addr,man,db) {
if (addr == '' && man) {
   if (db) alert('email address is mandatory');
   email.focus();
   return false;
}
var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
for (i=0; i<invalidChars.length; i++) {
   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
      if (db) alert('email address contains invalid characters');
      email.focus();
      return false;
   }
}
for (i=0; i<addr.length; i++) {
   if (addr.charCodeAt(i)>127) {
      if (db) alert("email address contains non ascii characters.");
      email.focus();
      return false;
   }
}

var atPos = addr.indexOf('@',0);
if (atPos == -1) {
   if (db) alert('email address must contain an @');
   form.email.focus();
   return false;
}
if (atPos == 0) {
   if (db) alert('email address must not start with @');
   email.focus();
   return false;
}
if (addr.indexOf('@', atPos + 1) > - 1) {
   if (db) alert('email address must contain only one @');
   email.focus();
   return false;
}
if (addr.indexOf('.', atPos) == -1) {
   if (db) alert('email address must contain a period in the domain name');
   email.focus();
   return false;
}
if (addr.indexOf('@.',0) != -1) {
   if (db) alert('period must not immediately follow @ in email address');
   email.focus();
   return false;
}
if (addr.indexOf('.@',0) != -1){
   if (db) alert('period must not immediately precede @ in email address');
   email.focus();
   return false;
}
if (addr.indexOf('..',0) != -1) {
   if (db) alert('two periods must not be adjacent in email address');
   email.focus();
   return false;
}
var suffix = addr.substring(addr.lastIndexOf('.')+1);
if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
   if (db) alert('invalid primary domain in email address');
   email.focus();
   return false;
}
return true;
}

function valButton(btn) {
var cnt = -1;
for (var i=btn.length-1; i > -1; i--) {
   if (btn[i].checked) {cnt = i; i = -1;}
   }
if (cnt > -1) return btn[cnt].value;
else return false;
}
 
function checkRequired(form) {
  var bFail;

  bFail = true; // Default to pass

  for(iElement = 0; iElement < form.elements.length; iElement++) {

    if(form.elements[iElement].className == 'RequiredTextBox' ||
       form.elements[iElement].className == 'FailedTextBox') {

      if(form.elements[iElement].value == '') {
        bFail = false;
        form.elements[iElement].className = 'FailedTextBox';

      } else {
		
        form.elements[iElement].className = 'RequiredTextBox';

      }

    }

  }
 
    if(bFail) {
      return bFail;
    } else {
	alert('You have not filled in all required fields. Please go back and ensure all fields with a red asterisk are filled in.');
      return bFail;
    }

} 
