String.prototype.lpad = function(padString, length) {
	var str = this;
	while (str.length < length)
		str = padString + str;
	return str;
}
 
String.prototype.rpad = function(padString, length) {
	var str = this;
	while (str.length < length)
		str = str + padString;
	return str;
}

/** Converts numeric degrees to radians */
if (typeof(Number.prototype.toRad) === "undefined") {
	Number.prototype.toRad = function() {
		return this * Math.PI / 180;
	}
}

/** Converts radians to numeric (signed) degrees */
if (typeof(Number.prototype.toDeg) === "undefined") {
	Number.prototype.toDeg = function() {
		return this * 180 / Math.PI;
	}
}

if (typeof(Number.prototype.round) === 'undefined') {
	Number.prototype.round = function(scale) {
		if(! scale)
			scale = 0;
		scale = Math.pow(10, scale);
		return Math.round(this * scale) / scale;
	}
}

