// Checks an HTML field to see if it is blank

  function checkBlank(obj, message) {
    if (obj.value == '') {
      alert(message);
      obj.focus();
      return(false);
    }
    else return(true);
  }
  
// Checks an HTML field isn't just http://
  function checkHttp(obj, message) {
    if (obj.value == 'http://') {
      alert(message);
      obj.focus();
      return(false);
    }
    else return(true);
  } 
  
// Checks an HTML field is numeric

  function checkNumeric(obj, message) {
    if (isNaN(obj.value)) {
    alert(message);
      obj.focus();
      return(false);
    }
    else return(true);
  } 
 

// Checks that an HTML input field does not exceed a specified num of characters

  function checkMaxLength(obj, max, name) {
    if (obj.value.length > max) {
      alert(name + ' must not be more than ' + max + ' characters long');
      obj.focus();
      return(false);
    }
    else return(true);
  }
  
// Checks that an HTML drop down has a selection

  function checkSelected(obj, message) {
    if (obj.value == '') {
      alert(message);
      obj.focus();
      return(false);
    }
    else return(true);
  }

  
// Checks that other field is complete if other is selected

  function checkOther(obj, message) {
    if (obj.value == '') {
      if (aif.nooffiles.value == ''){
        alert(message);
        obj.focus();
        return(false);
      }
      else {
      return(true);
      }
    }
    if (obj.value != '') { 
        return(true);
    }      
 
  }


//Checks that password & confirmed password are the same & valid

  
  function checkPasswords() {
  var invalid = " "; // Invalid character is a space
  var minLength = 6; // Minimum length
  var pw1 = cpf.newpassword.value;
  var pw2 = cpf.confirmnewpassword.value;
  // check for a value in both fields.
  if (pw1 == '' || pw2 == '') {
  alert('Please enter your password twice.');
  return false;
  }
  // check for minimum length
  if (cpf.newpassword.value.length < minLength) {
  alert('Your password must be at least ' + minLength + ' characters long. Try again.');
  return false;
  }
  // check for spaces
  if (cpf.newpassword.value.indexOf(invalid) > -1) {
  alert("Sorry, spaces are not allowed.");
  return false;
  }
  else {
  if (pw1 != pw2) {
  alert ("You did not enter the same new password twice. Please re-enter your new password.");
  return false;
  }
  else { 
  return true;
        }
     }
  } 
  
  //Checks that UID is valid
  
    
    function checkUID() {
    var invalid = " "; // Invalid character is a space
    var minLength = 5; // Minimum length
    var pw1 = cf.uid.value;
    var pw2 = cf.useruid.value;
    // check for minimum length
    if (cf.useruid.value.length < minLength) {
    alert('The Unique ID should be ' + minLength + ' characters long. Try again!');
    return false;
    }
    // check for spaces
    if (cf.useruid.value.indexOf(invalid) > -1) {
    alert("Unique ID is invalid.");
    return false;
    }
    else {
    if (pw1 != pw2) {
    alert ("Unique ID is invalid.");
    return false;
    }
    else { 
    return true;
          }
       }
  }  
