function calculate() {

    var principal = document.calc.cost.value - document.calc.downTrade.value;
	
    var interest  = document.calc.APR.value / 100 / 12;
	var myterm = document.calc.term.selectedIndex;
	var payments  = document.calc.term.options[myterm].value;
	
    var x = Math.pow(1 + interest, payments);
    var monthly = (principal*x*interest)/(x-1);

	
    if (!isNaN(monthly) && 
        (monthly != Number.POSITIVE_INFINITY) &&
        (monthly != Number.NEGATIVE_INFINITY)) {

        //document.calc.payment.value = round(monthly);
        //document.loandata.total.value   = round(monthly * payments);
        //document.loandata.totalinterest.value = 
            round((monthly * payments) - principal);
			document.getElementById("paymenttxt").innerHTML= "$" + round(monthly);
			return false;
    }
    else {
        document.calc.payment.value       = 0;
        //document.loandata.total.value         = "do not know";
        //document.loandata.totalinterest.value = "whatever";
    }
}
function round(x) { return Math.round(x*100)/100; }
