function calculate() {

var principal = document.closing_costs.loan_amount.value;
var insurancePremium = document.closing_costs.insurance_premium.value;
var propertyTaxes = document.closing_costs.property_taxes.value;
var appraisalReport = document.closing_costs.appraisal_report.value;
var creditReport = document.closing_costs.credit_report.value;
var escrowAmount = document.closing_costs.escrow_amount.value;
var lenderFees = document.closing_costs.lender_fees.value;
var titleInsurance = document.closing_costs.title_insurance.value;
var escrowInsurtax = document.closing_costs.escrow_insurtax.value;
var prepaidInterest = document.closing_costs.prepaid_interest.value;
var recordingFee = document.closing_costs.recording_fee.value;
var surveyFee = document.closing_costs.survey_fee.value;
var termiteReport = document.closing_costs.termite_report.value;
var transferTax = document.closing_costs.transfer_tax.value;
var miscellaneousFees = document.closing_costs.miscellaneous_fees.value;
var originationPercent = document.closing_costs.origination_percent.value / 100;
var pointsPercent = document.closing_costs.points_percent.value / 100;


// Compute

var amountEscrowInsurtax = (parseInt(escrowInsurtax) * (parseFloat(insurancePremium) / 12)) 
                           + (parseInt(escrowInsurtax) * (parseFloat(propertyTaxes) /12));
document.closing_costs.amount_escrowInsurtax.value = decimal(amountEscrowInsurtax);

var originationAmount = parseFloat(principal) * parseFloat(originationPercent);
document.closing_costs.origination_amount.value = decimal(originationAmount);

var pointsAmount = parseFloat(principal) * parseFloat(pointsPercent);
document.closing_costs.points_amount.value = decimal(pointsAmount);

var estimatedCosts = parseFloat(amountEscrowInsurtax) + parseFloat(appraisalReport)
+ parseFloat(creditReport) + parseFloat(escrowAmount) + parseFloat(lenderFees) + parseFloat(titleInsurance)
+ parseFloat(prepaidInterest) + parseFloat(recordingFee) + parseFloat(surveyFee) + parseFloat(termiteReport)
+ parseFloat(transferTax) + parseFloat(miscellaneousFees) + parseFloat(originationAmount)
+ parseFloat(pointsAmount);

document.closing_costs.estimated_costs.value = decimal(estimatedCosts);
}
