//Check the email address entered to see if it is at least in the proper format.
function check_email(emailaddress) {
   if (emailaddress.indexOf("@") == -1 || emailaddress.indexOf("@") == 0 || emailaddress.indexOf("@.") == 0 || emailaddress.indexOf(".") == -1) {
      return false;
   }
   else {
      return true;
   }
}
   
function ltrim(string_to_ltrim)
{
   for (var i = 0; i < string_to_ltrim.length && string_to_ltrim.charAt(i) == ' '; i++);
      return string_to_ltrim.substring(i);
}

function rtrim(string_to_rtrim)
{
   for (var i = string_to_rtrim.length; i > 0 && string_to_rtrim.charAt(i - 1) == ' '; i--);

   return string_to_rtrim.substring(0, i);
}

function trim(string_to_trim)
{
   return ltrim(rtrim(string_to_trim));
}

//Check if the current character is a letter a -> z or A -> Z
//Returns true or false.
function isLetter(character)
{   
   if ( (character >= "a" && character <= "z") || (character >= "A" && character <= "Z") )
   {
      return true;
   }
   else
   {
      return false;
   }   
}

//Check if the current character is a number 0 -> 9
//Returns true or false.
function isDigit(character)
{   
   if ( (character >= "0") && (character <= "9") )
   {
      return true;
   }
   else
   {
      return false;
   }   
}

//Returns true if character is a letter or digit.
function isLetterOrDigit(char_string)
{
   blnIs = true;
   for (i = 0; i < char_string.length; i++)
   {   
      //Check if the current character is a letter or number.
      //If one character fails, pass back false. Otherwise, pass back true.
      var c = char_string.charAt(i);
      if (!isLetter(c) && !isDigit(c))
      {
         blnIs = false;
      }
    }
    return blnIs;
}