/*
 
s: string value
bag: char array

isEmpty(s) : null
isWhitespace (s) : " \t\n\r"
isUserName(s) 
isName(s)
isEmail (s)
isTelNumber(s)
isCardNumber(s) 
isAddress(s)
isCharsInBag (s, bag)
isKeyword(s)
isItemNum(s)
isPassword(s)
isInt(s, item)
isIntEx(s, item, len£¬ bCompare)

isCharsInBagEx (s, bag) : return a bad char

isUserNameOld(s) 
*/

function isEmpty(s)
{  
	return ((s == null) || (s.length == 0))
}

function isWhitespace (s)
{  
  var whitespace = " \t\n\r";
  var i;
  // Is s empty?
  //if (isEmpty(s)) return true;

   // Search through string's characters one by one
   // until we find a non-whitespace character.
   // When we do, return false; if we don't, return true.
   for (i = 0; i < s.length; i++)
   {   
       // Check that current character isn't whitespace.
       var c = s.charAt(i);
       if (whitespace.indexOf(c) >= 0) 
	   {
		  return true;
	   }
   }

   // All characters are whitespace.
   return false;
}

function isCharsInBagEx (s, bag)
{  
  var i,c;
  // Search through string's characters one by one.
  // If character is in bag, append to returnString.
  for (i = 0; i < s.length; i++)
  {   
        c = s.charAt(i);
	if (bag.indexOf(c) > -1) 
        return c;
  }
  return "";
}

function isCharsInBag (s, bag)
{  
  var i;
  // 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) return false;
  }
  return true;
}
