﻿
if (typeof String.prototype.trim !== 'function')
{
	/** 
	Trims spaces from around the string
	@param {String}		str		The string to trim.
	@returns {String}			The trimmed string.
	*/
	String.prototype.trim = function ()
	{
		return this.replace(/^\s+|\s+$/g, '');
	}
}

if (typeof String.prototype.replaceAll !== 'function')
{
	/** 
	Replaces all instances of the given substring.
	@param {String}		strTarget		The substring to find.
	@param {String}		strSubString	The new substring to put instead.
	@returns {String}	The resulting string.
	*/
	String.prototype.replaceAll = function (strTarget, strSubString)
	{
		var strText = this;
		var intIndexOfMatch = strText.indexOf(strTarget);

		while (intIndexOfMatch != -1)
		{
			strText = strText.replace(strTarget, strSubString)
			intIndexOfMatch = strText.indexOf(strTarget);
		}
		return strText;
	}
}
