This
calculator will calculate
the cost of a mortgage as
well as your monthly payments.
Fill in the information below
and press the 'Calculate Mortgage'
button.
This calculator is currently inactive, please call 01225 423271 for further assitance.
");
resultsWin.document.writeln("");
var monthlyInt = inputForm.int_rate.value / 1200;
var numMonths = inputForm.years.value * 12;
var startMonth = inputForm.start_month.selectedIndex;
var principle = inputForm.principle.value;
principle = principle.replace(/\,/g, "");
var temp = 1 + monthlyInt;
var expon = 1;
var i;
for(i = 0; i < numMonths; i++)
{
expon = temp * expon;
}
expon = 1 / expon;
expon = 1 - expon;
expon = monthlyInt / expon;
var monthlyPayment = principle * expon;
var months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
resultsWin.document.writeln("Mortgage costs results ");
resultsWin.document.writeln("Starting with a principal value of " + inputForm.principle.value + "");
resultsWin.document.writeln(" with an interest rate of " + inputForm.int_rate.value + "%");
resultsWin.document.writeln("A " + inputForm.years.value + " year loan starting in ");
resultsWin.document.writeln("" + months[inputForm.start_month.options[startMonth].value] + " " + inputForm.start_year.value + "");
resultsWin.document.writeln(" will yield a monthly payment of " + getDisplayNumber(monthlyPayment) + " ");
var totalInt = 0;
if(inputForm.full_table.options[inputForm.full_table.selectedIndex].value == "N")
{
// Just show first year amortization and then totals for other years.
resultsWin.document.writeln("The mortgage for the first year (" + inputForm.start_year.value + ") would then result in
");
resultsWin.document.writeln("");
resultsWin.document.writeln("| Month | Principal | Interest | Balance | ");
var currMonth = startMonth;
var currInt;
var workPrinciple = principle;
var currPrinciple;
for(i = 0; i < 12; i++)
{
if(currMonth == 12)
{
currMonth = 0;
}
currInt = workPrinciple * monthlyInt;
currPrinciple = monthlyPayment - currInt;
workPrinciple = workPrinciple - currPrinciple;
resultsWin.document.writeln("| " + months[currMonth] + " | " + getDisplayNumber(currPrinciple) + " | " + getDisplayNumber(currInt) + " | " + getDisplayNumber(workPrinciple) + " | ");
currMonth++;
}
resultsWin.document.writeln("
");
resultsWin.document.writeln("Yearly Statistics ");
resultsWin.document.writeln("");
resultsWin.document.writeln("| Year | Total Principal | Total Interest | Balance | ");
var totalInt;
var totalPrin;
var j;
var year = inputForm.start_year.value;
var totalInterest = 0;
workPrinciple = principle;
for(i = 0; i < inputForm.years.value; i++)
{
totalInt = 0;
totalPrin = 0;
for(j = 0; j < 12; j++)
{
if(currMonth == 12)
{
currMonth = 0;
}
currInt = workPrinciple * monthlyInt;
currPrinciple = monthlyPayment - currInt;
workPrinciple = workPrinciple - currPrinciple;
totalInt = totalInt + currInt;
totalPrin = totalPrin + currPrinciple;
currMonth++;
}
resultsWin.document.writeln("| " + year + " | " + getDisplayNumber(totalPrin) + " | " + getDisplayNumber(totalInt) + " | " + getDisplayNumber(workPrinciple) + " | ");
year++;
totalInterest = totalInterest + totalInt;
}
resultsWin.document.writeln(" ");
}
else
{
// Full amortization tables for all years in months.
var i;
var j;
var totalInt;
var totalPrin;
var totalInterest = 0;
var currMonth;
var currInt;
var workPrinciple = principle;
for(i = 0; i < inputForm.years.value; i++)
{
totalInt = 0;
totalPrin = 0;
resultsWin.document.writeln("Monthly Statistics for ");
var tempYear = (inputForm.start_year.value - 0) + i;
var remain = inputForm.years.value - i;
resultsWin.document.writeln(tempYear + "(" + remain + " years remaining) ");
resultsWin.document.writeln("");
resultsWin.document.writeln("| Month | Principal | Interest | Balance | ");
currMonth = startMonth;
for(j = 0; j < 12; j++)
{
if(currMonth == 12)
{
currMonth = 0;
}
currInt = workPrinciple * monthlyInt;
currPrin = monthlyPayment - currInt;
workPrinciple = workPrinciple - currPrin;
totalInt = totalInt + currInt;
totalPrin = totalPrin + currPrin;
resultsWin.document.writeln("| " + months[currMonth] + " | " + getDisplayNumber(currPrin) + " | " + getDisplayNumber(currInt) + " | " + getDisplayNumber(workPrinciple) + " | ");
currMonth++;
}
totalInterest = totalInterest + totalInt;
resultsWin.document.writeln(" ");
resultsWin.document.writeln("Total principal for the year will be " + getDisplayNumber(totalPrin) + " ");
resultsWin.document.writeln("Total interest for the year will be " + getDisplayNumber(totalInt) + " ");
resultsWin.document.writeln("Your balance at end of " + tempYear + " will be " + getDisplayNumber(workPrinciple) + "
");
}
}
var avgInt = totalInterest / numMonths;
var finalTotal = (principle - 0) + totalInterest;
resultsWin.document.writeln("Your Final Summary: ");
resultsWin.document.writeln("- Monthly Payment: " + getDisplayNumber(monthlyPayment) + "
");
resultsWin.document.writeln(" - Total Interest (No pre-payment): " + getDisplayNumber(totalInterest) + "
");
resultsWin.document.writeln(" - Average interest each month: " + getDisplayNumber(avgInt) + "
");
resultsWin.document.writeln(" - Total amount paid over the time period: " + getDisplayNumber(finalTotal) + "
");
resultsWin.document.writeln(" ");
resultsWin.document.writeln(" | | | | |