// Helper function
function StringLib_isInteger(sTest) {
	iTest = parseInt(sTest,10);
	if ( iTest == NaN )
		return false;
	else if ( iTest + "" == sTest )
		return true;
	else
		return false;
} // StringLib_isInteger()

String.prototype.left = function(iChars) {
	if ( !StringLib_isInteger(iChars) )
		return "";
	else if ( iChars >= this.length )
		return this;
	else
		return this.substr(0,iChars);
} // String.left()

String.prototype.right = function(iChars) {
	if ( !StringLib_isInteger(iChars) )
		return "";
	else if ( iChars >= this.length )
		return this;
	else
		return this.substr(this.length-iChars,iChars);
} // String.right()

String.prototype.lpad = function(iLen, sPadChar) {
	if ( !StringLib_isInteger(iLen) )
		return this;
	else if ( iLen <= this.length )
		return this;
	else if ( sPadChar.length > 1 )
		return this;
	else
		var padStr = this;
		do {
			padStr = sPadChar + padStr;
		} while ( padStr.length < iLen );
		return padStr;
} // String.lpad()

String.prototype.ltrim = function() {
	return this.replace(/^\s+/, '');
} // String.trim()

String.prototype.rtrim = function() {
	return this.replace(/\s+$/, '');
} // String.rtrim()

String.prototype.trim = function() {
	return this.replace(/^\s+/, '').replace(/\s+$/, '');
} // String.trim()


