
function validatePostmanMenu() {
  alias = trim(document.forms[0].alias.value);
  if (alias.length == 0) {
    alert("Please provide the SolarMail alias")
    return false
  }
  return true
}

function checkLastName() {
  lastname = trim(document.forms[0].lastname.value);
  if (lastname.length == 0) {
    alert("Please provide a new last name")
    return false
  }
  return true
}

function checkFirstName() {
  firstname = trim(document.forms[0].firstname.value);
  if (firstname.length == 0) {
    alert("Please provide a new first name")
    return false
  }
  return true;
}

function checkAlias() {
  alias = trim(document.forms[0].newalias.value)
  if (alias.length == 0) {
    alert("Please provide a new alias")
    return false
  }
  return true
}

function validateSendPassword() {
  alias = trim(document.forms[1].alias.value);
  if (alias.length == 0) {
    alert("Please provide your SolarMail alias");
    return false
  }
  return true
}

function validateUpdateAccount() {
  form = document.forms[0]

  inst = trim(form.loc.value);
  if (inst.length == 0) {
    alert("Please provide your institution")
    return false
  }

  user1 = trim(form.user1.value);
  host1 = trim(form.host1.value);
  if (user1.length == 0 ||
      host1.length == 0) {
    alert("Please provide a forwarding email address")
    return false
  }
  return true
}

function validateFindAccount() {
  form = document.forms[0];

  alias = trim(form.alias.value);
  if (alias.length == 0) {
    alert("Please provide your SolarMail alias")
    return false
  }

  if (form.password.value.length == 0) {
    alert("Please provide your password")
    return false
  }

  return true 
}

function validateNewUser() {
  form = document.forms[0]
  lastname =trim(form.lastname.value);
  if (lastname.length == 0) {
    alert("Please provide your last name")
    return false
  }

  firstname = trim(form.firstname.value);
  if (firstname.length == 0) {
    alert("Please provide your first name")
    return false
  }

  loc = trim(form.loc.value);
  if (loc.length == 0) {
    alert("Please provide your institution")
    return false
  }

  user1 = trim(form.user1.value);
  host1 = trim(form.host1.value);
  if (user1.length == 0 ||
      host1.length == 0) {
    alert("Please provide a forwarding email address")
    return false
  }

  if (form.password.value.length == 0) {
    alert("Please provide a password")
    return false
  }

  return true
}

function validateChangePassword() {
  form = document.forms[0]

  if (form.password.value.length == 0) {
    alert("Please provide a password")
    return false
  }

  if (form.password.value != form.password2.value) {
    alert("Password entries don't match. Please reenter")
    return false
  }

  return true
}

// Copied from http://www.irt.org/script/1310.htm
function trim(strText) { 
    // this will get rid of leading spaces 
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);

    // this will get rid of trailing spaces 
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);

   return strText;
} 
