
function  doMath()
{
    // Create numberFormat oject to format values
    var num = new NumberFormat();
    num.setInputDecimal('.');
    num.setPlaces('2', false);
    num.setCurrencyValue('$');
    num.setCurrency(true);
    num.setSeparators(true, ',', ',');
    var cost_equip = new NumberFormat(document.calcform.cost_equip.value).toUnformatted();
    var deduction;
    if (cost_equip >= 500000)
    {
        deduction = 500000;
    }
    else
    {
        deduction = cost_equip;
    }
    var bonus_dep = (cost_equip - deduction) * .5;
    var depriciation = bonus_dep * .2;
    var tot_deduc = deduction + bonus_dep + depriciation;
    var cash_save    = tot_deduc * .35;
    var lowered_cost = cost_equip - cash_save;
    num.setNumber(cost_equip);
    document.calcform.cost_equip.value   = num.toFormatted();
    num.setNumber(bonus_dep);
    document.calcform.bonus_dep.value    = num.toFormatted();
    num.setNumber(deduction);
    document.calcform.deduction.value    = num.toFormatted();
    num.setNumber(depriciation);
    document.calcform.depriciation.value = num.toFormatted();
    num.setNumber(tot_deduc);
    document.calcform.tot_deduc.value    = num.toFormatted();
    num.setNumber(cash_save);
    document.calcform.cash_save.value    = num.toFormatted();
    num.setNumber(lowered_cost);
    document.calcform.lowered_cost.value = num.toFormatted();
}

function custRound(x,places) { return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places) }

