/*These functions to error check on forgotten passwords sent to the user
  Placed in the public domain by Affordable Production Tools
  April 27, 1998
  Web site: http://www.aptools.com
  December 2, 1998 -- Modified to allow specification of
  character to be trimmed.
  This function trims spaces (default) or the specified
  character from the left of a string or form field.
*/

function LeftTrim(String,TrimChar){
  String += "";         // Force argument to string.
  TrimChar += "";       // Force argument to string.
  if((TrimChar == "") || (!(TrimChar.length == 1))) {
   TrimChar = " ";
  }
  if(String.length == 0) {
    return(String);
  }
  var Count = 0;
  for(Count = 0;Count < String.length;Count++) {
    if(!(String.charAt(Count) == TrimChar)) {
      return(String.substring(Count,String.length));
    }
  }
  return("");
}

/* This function trims spaces (default) or the specified
   character from the right of a string or form field.
*/

function RightTrim(String,TrimChar){
  String += "";        // Force argument to string.
  TrimChar += "";      // Force argument to string.
  if((TrimChar == "") || (!(TrimChar.length == 1))){
   TrimChar = " ";
  }
  if(String.length == 0){
    return(String);
  }
  var Count = 0;
  for(Count = String.length -1;Count >= 0;Count--){
    if(!(String.charAt(Count) == TrimChar)){
      return(String.substring(0,Count + 1));
    }
  }  
  return("")
}

/* This function trims spaces (default) or the specified
   character from the left and the right of a string or form field.
   Note that this functions uses two other library functions,
  TrimLeft() and TrimRight().
*/

function AllTrim(String,TrimChar){
  String += "";        // Force argument to string.
  TrimChar += "";      // Force argument to string.
  if((TrimChar == "") || (!(TrimChar.length == 1))){
    TrimChar = " ";
  }
  return(RightTrim(LeftTrim(String,TrimChar),TrimChar));
}
