/*
 * @description convert newlines to html break tags.
 * @strValue strValue this is the string value that is modified.
 * @return strValue as a modified string.
 */
function nl2br(strValue)
{
	var re_nlchar = '';
	var strNewValue = escape(strValue);
	if (strNewValue.indexOf('%0D%0A') > -1)
	{
		re_nlchar = /%0D%0A/g;
	}
	else if (strNewValue.indexOf('%0A') > -1)
	{
		re_nlchar = /%0A/g;
	}
	else if (strNewValue.indexOf('%0D') > -1)
	{
		re_nlchar = /%0D/g;
	}
	else
	{
		return unescape(strValue);
	}
	return unescape(strNewValue.replace(re_nlchar, '<br />'));
}
function formatCurrency(intValue)
{
	intValue = intValue.toString().replace(/\$|\,/g, '');
	if (isNaN(intValue))
	{
		intValue = '0';
	}
	strSign = (intValue == (intValue = Math.abs(intValue)));
	intValue = Math.floor(intValue * 100 + 0.50000000001);
	intCents = intValue % 100;
	intValue = Math.floor(intValue / 100).toString();
	if (intCents < 10)
	{
		intCents = '0' + intCents;
	}
	for (var i = 0; i < Math.floor((intValue.length - (1 + i)) / 3); i++)
	{ 
		intValue = intValue.substring(0, intValue.length - (4 * i + 3)) + ',' + intValue.substring(intValue.length - (4 * i + 3));
	}
	return (((strSign) ? '' : '-') + '$' + intValue + '.' + intCents);
}
function trim(strValue)
{
	strValue = strValue.replace(/^(\s)*/, '');
	strValue = strValue.replace(/(\s)*$/, '');
	return strValue;
}
function evalWordCount(objThis, strUpdateId, intWordLimit)
{
	var blnReturn = false;
	var strNewValue = '';
	var strPlural = 's';
	var intWordCount = 0;
	var arrValue = objThis.value.split(' ');
	var intWords = arrValue.length;
	if (intWords > intWordLimit)
	{
		intWords = intWordLimit;
		blnReturn = true;
	}
	for (intI = 0; intI < intWords; intI++)
	{
		if (arrValue[intI].length > 0)
		{
			strNewValue += arrValue[intI] + ' ';
			intWordCount++;
		}
	}
	if (blnReturn)
	{
		objThis.value = strNewValue;
	}
	if (strUpdateId != '')
	{
		var intWordsRemaining = intWordLimit - intWordCount;
		if (intWordsRemaining == 1)
		{
			strPlural = '';
		}
		document.getElementById(strUpdateId).innerHTML = intWordsRemaining + ' word' + strPlural + ' remaining.';
	}
}