// JavaScript Document
function replace(originalString, searchText, replaceText)
{
	var strLength = originalString.length;
	var txtLength = searchText.length;
	if ((strLength == 0) || (txtLength == 0))
	{ return originalString; }
	var i = originalString.indexOf(searchText);
	if ((!i) && (searchText != originalString.substring(0, txtLength)))
	{ return originalString; }
	if (i == -1)
	{ return originalString; }
	var newstr = originalString.substring(0, i) + replaceText;
	if (i + txtLength < strLength)
	{ newstr += replace(originalString.substring(i + txtLength, strLength), searchText, replaceText); }
	return newstr;
}

function formatCurrency(strValue)
{
	strValue = strValue.toString().replace(/\$|\,/g, '');
	dblValue = parseFloat(strValue);

	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue * 100 + 0.50000000001);
	intCents = dblValue % 100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue / 100).toString();
	if (intCents < 10)
		strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length - (1 + i)) / 3); i++)
		dblValue = dblValue.substring(0, dblValue.length - (4 * i + 3)) + ',' +
		dblValue.substring(dblValue.length - (4 * i + 3));
	return (((blnSign) ? '' : '-') + '$' + dblValue + '.' + strCents);
}

String.left = function(str, n)
/***
IN: str - the string we are LEFTing
n - the number of characters we want to return

RETVAL: n characters from the left side of the string
***/
{
	if (n <= 0)     // Invalid bound, return blank string
		return "";
	else if (n > String(str).length)   // Invalid bound, return
		return str;                // entire string
	else // Valid bound, return appropriate substring
		return String(str).substring(0, n);
}

String.right = function(str, n)
/***
IN: str - the string we are RIGHTing
n - the number of characters we want to return

RETVAL: n characters from the right side of the string
***/
{
	if (n <= 0)     // Invalid bound, return blank string
		return "";
	else if (n > String(str).length)   // Invalid bound, return
		return str;                     // entire string
	else
	{ // Valid bound, return appropriate substring
		var iLen = String(str).length;
		return String(str).substring(iLen, iLen - n);
	}
}



