String.prototype.Pad = function(Direct, Char, Len)
{
	var result = this;
	while (result.length < Len)
	{
		if (Direct > 0)
			result += Char;
		else result = Char + result;
	}
	return result;
}

String.prototype.LPad = function(Char, Len)
{
	return this.Pad(-1, Char, Len);
}
	
String.prototype.RPad = function(Char, Len)
{
	return this.Pad(1, Char, Len);
}

String.prototype.Right = function(Len)
{
	return this.substr(this.length - Len, this.length);
}

String.prototype.Left = function(Len)
{
	return this.substr(0, Len);
}

String.prototype.ReplaceAll = function(OldStr, NewStr)
{
	tempThis = this;
	while (tempThis.indexOf(OldStr) != -1 && OldStr != '') tempThis = tempThis.replace(OldStr, NewStr);
	return tempThis;
}

String.prototype.ltrim = function()
{
	return this.replace(/^\s*/, "");
}

String.prototype.rtrim = function()
{
	return this.replace(/\s*$/, "");
}

String.prototype.trim = function()
{
	return this.ltrim().rtrim();
}

