function calculate() {

var salary = document.afford_loan.salary_amount.value;
var interestDividends = document.afford_loan.interest_dividends.value;
var otherIncome = document.afford_loan.other_income.value;

var creditCards = document.afford_loan.credit_cards.value;
var autoPayments = document.afford_loan.auto_payments.value;
var loanPayments = document.afford_loan.loan_payments.value;

var debtPercent = document.afford_loan.debt_percent.value;
var mortgagePercent = document.afford_loan.mortgage_percent.value;


// Compute

var monthlyIncome = parseFloat(salary) + parseFloat(interestDividends) + parseFloat(otherIncome);
document.afford_loan.monthly_income.value = decimal(monthlyIncome);

var monthlyDebt = parseFloat(creditCards) + parseFloat(autoPayments) + parseFloat(loanPayments);
document.afford_loan.monthly_debt.value = decimal(monthlyDebt);

var maximumPayment = parseFloat(monthlyIncome)  * mortgagePercent;
document.afford_loan.maximum_payment.value = decimal(maximumPayment);

var debtIncome = parseFloat(monthlyDebt)  / parseFloat(monthlyIncome);
document.afford_loan.debt_income.value = decimal(debtIncome);

var totalDebtIncome = (parseFloat(monthlyDebt) + parseFloat(maximumPayment))  / parseFloat(monthlyIncome);
document.afford_loan.total_debt_income.value = decimal(totalDebtIncome);

var differenceDebtPercent = debtPercent - totalDebtIncome;
document.afford_loan.difference_debt_percent.value = decimal(differenceDebtPercent);

}


