# Bi-Weekly Mortgage Calculator, HELP!

I've tried forever to make this problem work. I can't figure out the algorithym. I've looked all over the internet, but financial companies use another type of bi-weekly calculator that's a little easier. I guess that's why my prof. chose this one. This would be easier if I could do this in C++ but I can't.

I can't figure out how to get this output:
Paid Off In
Interest Savings
Equivalent Interest Rate

The input:
Mortgage Amount
Interest Rate
15 or 30 years

The output I can figure out is:
Monthly Payments
Bi-weekly
Payments

Here is what I have so far.
_____________________________________

function valid(cForm) {
// Check existing fields
mortgage = check(cForm.mortgage);
interest_rate = check(cForm.interest_rate);
period1 = check(cForm.period1);
payment_period = 12; //check(cForm.payment_period);

//Define target fields
monthly_payments = 0;
biweekly_payments = 0;
paid_off_in = 0;
interest_savings = 0;
equal_interest_rate = 0;

return true;
}

function check(item) {
if (item.value.length == 0)
item.value = "0";
item.value = parseFloat(item.value);
return item.value;
}

function calculate() {
// Calculate monthly payments
j = (interest_rate / payment_period) * .01;
n = period1 * payment_period;
monthly_payments = mortgage * (j / (1 - Math.pow((1 + j), -n)));

// Calculate bi-weekly payments
payment_period = 24;
j = (interest_rate / payment_period) * .01;
n = period1 * payment_period;
biweekly_payments = mortgage * (j / (1 - Math.pow((1 + j), -n)));

//paid_off_in = biweekly_payments * n;
//interest_savings = paid_off_in - mortgage;
//equal_interest_rate
}

function finalize(cForm) {
cForm.monthly_payments.value = limitFloat(monthly_payments);
cForm.biweekly_payments.value = limitFloat(biweekly_payments);
cForm.paid_off_in.value = limitFloat(paid_off_in);
cForm.interest_savings.value = limitFloat(interest_savings);
cForm.equal_interest_rate.value = limitFloat(equal_interest_rate);
}

function process(cForm) {
if ( valid (cForm)) {
calculate();
finalize(cForm);
}
}
function limitFloat(f) {
return parseFloat(Math.round(f * 100) / 100);
}