<!--
// This JavaScript was last created by Nathan Kerr on 14/06/2005
// This is a direct copy of /javascript/budgetPlanner/formatter.js

function removeComma(num)
{
// All variables are decalared here
	var re =/,/g;
	var str = num.toString();

// This function looks at the incoming string and removes all the commas from it.
	str = str.replace(re,"");

	return parseFloat(str);
}

// This function clears the field when clicked on
function clearField(field)
{
	field.value = "";
}

function formatAmount(Expr)
{

// All variables are decalared here

        var DecPlaces = 2;

        var str = "" + Math.round(eval(Expr) * Math.pow(10, DecPlaces));
        var DecPoint;
        var Result;
        var re;

// This function looks at the incoming string and formats it with two decimal places
// and a comma for every 3 digits.

        while (str.length <= DecPlaces)
        {
                str = "0" + str;
        }
        
        DecPoint = str.length - DecPlaces;

        Result = str.substring(0, DecPoint) + "." + str.substring(DecPoint, str.length);

        re = /(-?\d+)(\d{3})/;

        while (re.test(Result))
        {
                Result = Result.replace(re, "$1,$2");
        }

        return Result;
}

// -->
