// $Id: xString.js,v 1.2 2002/11/11 16:58:31 tim Exp $

String.prototype.leftTrim = function() {
	return this.replace( /^\s+/,"");
}

String.prototype.rightTrim = function() {
	return this.replace( /\s+$/g,"");
}

String.prototype.allTrim = function() {
	return this.replace(/^\s*(\S[\d\D]*\S)\s*$/,"$1");
}

String.prototype.trim	=	String.prototype.allTrim;

String.prototype.capitalize = function() {
	return this.substr(0,1).toUpperCase()+this.substr(1).toLowerCase();
}

String.prototype.capitalizeAll = function() {
	var pattern = /(\b.)(\w*\b)(.*)/;
	var oldValue = this;
	var returnString = '';
	var tmp;
	while(pattern.exec(oldValue)) {
		tmp = pattern.exec(oldValue);
		returnString += tmp[1].toUpperCase()+tmp[2].toLowerCase() + ' ';
		oldValue = tmp[3];
	}
	return returnString.rightTrim();
}

String.prototype.removeWhiteSpace = function(){
	var returnString = '';
	for(i=0;i<this.length;i++) {   
  	if(this.charAt(i)!=' ') {
   		returnString += this.charAt(i);
   	}
  }
  return returnString;
}
