function opt_smartinteger (t) {
  // assist user in entering a valid integer
  // but a blank is allowed. This is the optional part!
  var result;
  var pattern = /^\d+$/;
  var efield = t.value;

  result = efield.match(pattern);
  if (result != null) {
      return true;
  } else {
      t.value = '';
      t.focus();
      alert("Please enter a number");
      t.focus();
      return true;
  }

}
function opt_smartemail (objId) {
  // assist user in entering a valid email address
  // but a blank is allowed. This is the optional part!
  var result;
  var pattern = /^[\w\-\.]+@[\w\-\.]+$/;
  var efield = $(objId).val();

  if (efield == "") {
      return true; // blank is ok
  }
  result = efield.match(pattern);
  if (result != null) {
      return true;
  } else {
      $(objId).val('');
      alert("Please enter a valid email address");
      $(objId).focus();
      setTimeout("$('" + objId + "').focus();",0);
      return false;
  }

}

function opt_smartphone(t) {
// Check for correct phone number
  var result;
  var pattern = /^(\d\d\d)(\d\d\d)(\d\d\d\d)$/;
  var pattern2 = /^(\d\d\d)-(\d\d\d)-(\d\d\d\d)$/;
  var efield = t.value;

  if (t.value == "") {
      return true; // blank is ok
  }
  result = efield.match(pattern);
  if (result != null) {
      // add dashes now
      t.value = result[1] + "-" + result[2] + "-" + result[3];
      return true;
  } else {
      result = efield.match(pattern2);
      if (result != null) {
          return true;
      } else {
          t.value = '';
          t.focus();
          alert("Please enter a valid phone number in the form xxx-xxx-xxxx");
          t.focus();
          return true;
      }
  }
}

function validateFaqForm(theform) {
  if (theform.question.value == "") {
      alert("Question cannot be blank");
      theform.question.focus();
      return false;
  }
  if (theform.answer.value == "") {
      alert("Answer cannot be blank");
      theform.answer.focus();
      return false;
  }
  if (theform.sortOrder.value == "") {
      alert("Sort Order cannot be blank");
      theform.sortOrder.focus();
      return false;
  }
}

function validateWorkshopForm(theform) {
  if (theform.name.value == "") {
      alert("Name cannot be blank");
      theform.name.focus();
      return false;
  }
  if (theform.description.value == "") {
      alert("Description cannot be blank");
      theform.description.focus();
      return false;
  }
  if (theform.sortOrder.value == "") {
      alert("Sort Order cannot be blank");
      theform.sortOrder.focus();
      return false;
  }
}

function validateBioForm(theform) {
  if (theform.name.value == "") {
      alert("Name cannot be blank");
      theform.name.focus();
      return false;
  }
  if (theform.bio.value == "") {
      alert("Bio cannot be blank");
      theform.bio.focus();
      return false;
  }
  if (theform.sortOrder.value == "") {
      alert("Sort Order cannot be blank");
      theform.sortOrder.focus();
      return false;
  }
}

function validatePresenterForm(theform) {
  if (theform.name.value == "") {
      alert("Name cannot be blank");
      theform.name.focus();
      return false;
  }
  if (theform.bio.value == "") {
      alert("Description cannot be blank");
      theform.bio.focus();
      return false;
  }
  if (theform.sortOrder.value == "") {
      alert("Sort Order cannot be blank");
      theform.sortOrder.focus();
      return false;
  }
}

