// These are helper functions for the info-*.js validation functions.  You
// must include this file if you will be including any one (or more) of
// those files.
//
// 18 Feb 97 created Eric Krock
//
// (c) 1997 Netscape Communications Corporation
// 1998 Supplemented by Dawn Bushong


var infodigits = "0123456789";
var infoletters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"


// Removes all characters which do NOT appear in string bag 
// from string s.

function stripInfoCharsNotInBag (s, bag) {
  var i;
  var returnString = "";

  // Search through string's characters one by one.
  // If character is in bag, append to returnString.

  for (i = 0; i < s.length; i++) {   
    // Check that current character isn't whitespace.
    var c = s.charAt(i);
    if (bag.indexOf(c) != -1) returnString += c;
  }

  return returnString;
}

function isInfoLetter(c) {
  return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) );
}

function isInfoDigit(c) {
  return ((c >= "0") && (c <= "9"));
}

// isInfoInteger(STRING s [, BOOLEAN emptyOK])
// 
// Returns true if all characters in string s are numbers.
//
// Accepts non-signed integers only. Does not accept floating 
// point, exponential notation, etc.
//
// We don't use parseInt because that would accept a string
// with trailing non-numeric characters.

function isInfoInteger(s) {
  if (isEmpty(s)) return emptyReturn(isInfoInteger.arguments);

  // Search through string's characters one by one
  // until we find a non-numeric character.
  // When we do, return false; if we don't, return true.

  for (var i = 0; i < s.length; i++) {   
    // Check that current character is number.
    var c = s.charAt(i);

    if ( !((c >= "0") && (c <= "9")) ) return false;
  }

  // All characters are numbers.
  return true;
}

