function removeCommas(str)
{
	var re = /,/gi;
	return str?str.replace(re,""):str;
}

function formatMoneyString(value,withCommas)
{
	var floatAmount = 0;
	if(isNaN(value))
	{
		value = removeCommas(value);
		floatAmount = parseFloat(value);
	}
	else
	{
		floatAmount = value;
	}

	var money = ""+parseFloat(""+(Math.round(floatAmount *= 100)) / 100.0);
	if(money.indexOf(".")==-1)
		money += ".00";
	else if(money.indexOf(".")==(money.length-2))
		money += "0";

	if(withCommas)
	{
		var temp = money;
		var index = temp.indexOf(".");
		money = temp.substring(index);

		while(index>0)
		{
			index -= 3;
			if(index>0)
				money = "," + temp.substring(index,index+3) + money;
		}
		money = temp.substring(0,index+3) + money;
		
		if(money.indexOf("-,")==0)
			money = money.replace("-,","-");
	}

	return money;
}

function getDollarAmount(strValue)
{
	if(strValue == null || strValue.length==0)
		return 0;
	else
		return Number(removeCommas(strValue));
}
