/* Useful functions and extensions for existing Javascript Objects */

var STR_PAD_LEFT 	= "LEFT";
var STR_PAD_RIGHT 	= "RIGHT";

String.prototype.repeat = function(times) {
	var value = "";
	
	for(var t = 0; t < times; t ++) {
		value += this;
	}
	
	return value;
};

String.prototype.pad = function(text, length /*, padOption */) {
	var value = this;
	
	if(!value) value = "";

	var times = length - value.length;
	if(times <= 0) return value;
	
	switch(arguments[2]) {
		case STR_PAD_RIGHT:
			return value + text.repeat(times);
			break;
		case STR_PAD_LEFT:
		default:
			return text.repeat(times) + value;
			break;
	}
};