/*
  string.js
  
  string function library
  
  author. Toni Kustiana
  date. June, 03 2002
  
  doc. http://www.tonikustiana.com/lib/js/string.doc.html
  
  ***********************************************************

  function htmlSpecialChars(str);
  // convert special character
  
  function htmlSpecialCharsInverse(str);
  // convert special chars in html to original character
  
  function isAlphabet(str);
  // return true if str contents only alphabet
  
  function isAplhaNumeric(str);
  // return true if str content only aplhabet and numeric
  
  function isCreditCard(str);
  // return true if str content number and space
  
  function isEmail(str);
  // return true if str meet email rule
  
  function isLogin(str);
  // return true if str is valid login
  
  function isCompany(str);
  // return true if str is valid company name
    
  function isName(str);
  // return true if str contents only alphabet, space or single quote
  
  function isNumeric(str);
  // return true if str content only numeric
  
  function isUsername(str);
  // return true if str content only alphanumeric and _
  
  function lTrim(str);
  // remove space leader

  function rTrim(str);
  // remove space trailer

  function trim(str);
  // remove space leading and trailer
      
  function ucFirst(str);
  // make first character in str be capital  

*/  

  function isAlphabet(str) {
  		if (! str) return '';
  		
      re = /[^a-zA-Z]/g
      return ! re.test(str);
  }
  
  function isAlphaNumeric(str) {
  		if (! str) return '';
  		
      re = /[^a-zA-Z0-9 _\-]/g
      return ! re.test(str);
  }
  
  function isCreditCard(str) {
  		if (! str) return '';
  		
  		re = /[^0-9 ]/g
  		return ! re.test(str);
	}

	function isEmail(str) {			
		if (! str) return '';
		re = /(^[\w\d\-]+(\.[\d\w\-\_]+)*@[\w\d\-]+(\.[\d\w]+)+$)/
		return re.test(str);
	}

  function isLogin(str) {
  		if (! str) return '';
  		
  	  re = /[^a-zA-Z0-9_\-\.]/g
  	  return ! re.test(str);
  }

  function isCompany(str) {
  	  re = /[^a-zA-Z0-9 _\-\.]/g
  	  return ! re.test(str);
  }
  
  function isName(str) {
  		if (! str) return '';
  		
      re = /[^a-zA-Z0-9 \-\'\"_]/g
      return ! re.test(str);
  }
  
  function isNumeric(str) {
  		if (! str) return '';
  		
      re = /[^0-9\.\,]/g
      return ! re.test(str);
  }

  function isUsername(str) {
  		if (! str) return '';
  		
      re = /[^a-zA-Z0-9_]/g
      return ! re.test(str);
  }

  function htmlSpecialChars(str) {
  		if (! str) return '';
  	
      re = /&/gi
      str = str.replace(re, '&amp;');
  	
      re = /\"/gi
      str = str.replace(re, '&quot;');
            
      re = /\'/gi
      str = str.replace(re, '&#039;');
      
      re = /</gi
      str = str.replace(re, '&lt;');

      re = />/gi
      str = str.replace(re, '&gt;');
      
      return str;
  }

  function htmlSpecialCharsInverse(str) {
  		if (! str) return '';
  	
      re = /&quot;/gi
      str = str.replace(re, '"');
      
      re = /&amp;/gi
      str = str.replace(re, '&');
      
      re = /&#039;/gi
      str = str.replace(re, "'");
      
      re = /&lt;/gi
      str = str.replace(re, "<");

      re = /&gt;/gi
      str = str.replace(re, ">");
            
      return str;            
  }

  function lTrim(str) {
  		if (! str) return '';
  		
      re = /^\s*/g
      return str.replace(re, '');
  }
  
  function rTrim(str) {
  		if (! str) return '';
  		
      re = /\s*$/g
      return str.replace(re, '');
  }
  
  function trim(str) {
  		if (! str) return '';
  		
      re = /(^\s*)|(\s*$)/gi
      return str.replace(re, '');
  }
    
  function ucFirst(str) {
  		if (! str) return '';
      if (str.length == 0) return str;
      var char1 = str.substring(0, 1);
      char1 = char1.toUpperCase();
      
      return (char1 + str.substring(1, str.length));
  }
  