//
// This is the javascript validation for the Contact form (contact.php). If all of the
// validation passes then the form is posted using AJAX (not the normal form POST). The response
// is then processed and we either show a <DIV> that has the confirmation message or we display
// a javascript alert popup with the error message returned from the PHP script.
//
function validate_enewsletter_form() {
  //Form validation
  var bError = false;
  if ($j('#enews_first_name').val() == '') { addErrorEnews('enews_first_name'); bError = true; } else { removeErrorClassEnews('enews_first_name'); }
//  if ($j('#enews_last_name').val() == '') { addErrorEnews('enews_last_name'); bError = true; } else { removeErrorClassEnews('enews_last_name'); }
  if ($j('#enews_zip').val() == '') { addErrorEnews('enews_zip'); bError = true; } else { removeErrorClassEnews('enews_zip'); }
//  if ($j('#enews_country').val() == '') { addErrorEnews('enews_country'); bError = true; } else { removeErrorClassEnews('enews_country'); }

  var sEmail = $j('#enews_email').val();
  if (sEmail == '' || !sEmail.match(/^\b[A-Z0-9._%+-]+@(?:[A-Z0-9\-]+\.)+[A-Z]{2,4}\b$/i)) { addErrorEnews('enews_email'); bError = true; } else { removeErrorClassEnews('enews_email'); }

//  if ($j('#enews_security_code').val() == '') { addErrorEnews('enews_security_code'); bError = true; } else { removeErrorClassEnews('enews_security_code'); }

  if (bError == true) {
    alert ("Please correct the highlighted fields.");
    return false;
  }
  else {
    return true;
  }
}

function removeErrorClassEnews(control_id) {
  $j('#'+control_id).parent().parent().removeClass('error');
  return true;
}

function addErrorEnews(control_id) {
//  $j('#'+control_id).select().focus();
  $j('#'+control_id).parent().parent().addClass('error');
  return true;
}
