function jumpBox(list) { location.href = list.options[list.selectedIndex].value }
function formatNum(Vnum) {

if(Vnum > 99000000) {
alert("Sorry, this will not generate numbers larger that 99 million.");
focus();
} else {

var V10million = parseInt(Vnum / 10000000);

var V1million = (Vnum % 10000000)  / 1000000;
if(V1million / 1000000 == 1) { V1million = 1; } else
if(V1million < 1) { V1million = "0"; } else { V1million = parseInt(V1million,10); }

var V100thousand = (Vnum % 1000000)  / 100000;
if(V100thousand / 100000 == 1) { V100thousand = 1; } else
if(V100thousand < 1) { V100thousand = "0"; } else { V100thousand = parseInt(V100thousand,10); }

var V10thousand = (Vnum % 100000)  / 10000;
if(V10thousand / 10000 == 1) { V10thousand = 1; } else
if(V10thousand < 1) { V10thousand = "0"; } else { V10thousand = parseInt(V10thousand,10); }

var V1thousand = (Vnum % 10000)  / 1000;
if(V1thousand / 1000 == 1) { V1thousand = 1; } else
if(V1thousand < 1) { V1thousand = "0"; } else { V1thousand = parseInt(V1thousand,10); }

var Vhundreds = (Vnum % 1000)  / 100;
if(Vhundreds / 100 == 1) { Vhundreds = 1; } else
if(Vhundreds < 1) { Vhundreds = "0"; } else { Vhundreds = parseInt(Vhundreds,10); }

var Vtens = (Vnum % 100)  / 10;
if(Vtens / 10 == 1) { Vtens = 1; } else
if(Vtens < 1) { Vtens = "0"; } else { Vtens = parseInt(Vtens,10); }

var Vones = (Vnum % 10)  / 1;
if(Vones / 1 == 1) { Vones = 1; } else
if(Vones < 1) { Vones = "0"; } else { Vones = parseInt(Vones,10); }

//START UPGRADE
var Vcents = 0;

if(Vnum % 1 * 100 < 1) { Vcents = 0; } else { Vcents = parseInt(((eval(Vnum % 1) * 100)),10); }
//END UPGRADE

if(Vcents < 1) { Vcents = "00"; }
else
if(Vcents % 10 == 0) { Vcents = Vcents + "0"; }
else
if(Vcents % 10 == Vcents) { Vcents = "0" + Vcents; } else { Vcents = Vcents; }

if(Vcents == "900") { Vcents = "90"; } else
if(Vcents == "800") { Vcents = "80"; } else 
if(Vcents == "700") { Vcents = "70"; } else 
if(Vcents == "600") { Vcents = "60"; } else 
if(Vcents == "500") { Vcents = "50"; } else 
if(Vcents == "400") { Vcents = "40"; } else 
if(Vcents == "300") { Vcents = "30"; } else
if(Vcents == "200") { Vcents = "20"; } else
if(Vcents == "100") { Vcents = "10"; } else { Vcents = Vcents; }

 var Vformat = "";

if(Vnum >= 10000000) { Vformat = (V10million + "" + V1million + "," + V100thousand + "" + V10thousand + "" + V1thousand + "," + Vhundreds + "" + Vtens + "" + Vones + "." + Vcents); }
else
if(Vnum >= 1000000) { Vformat = (V1million + "," + V100thousand + "" + V10thousand + "" + V1thousand + "," + Vhundreds + "" + Vtens + "" + Vones + "." + Vcents); }
else
if(Vnum >= 100000) { Vformat = (V100thousand + "" + V10thousand + "" + V1thousand + "," + Vhundreds + "" + Vtens + "" + Vones + "." + Vcents); }
else
if(Vnum >= 10000) { Vformat = (V10thousand + "" + V1thousand + "," + Vhundreds + "" + Vtens + "" + Vones + "." + Vcents); }
else
if(Vnum >= 1000) { Vformat = (V1thousand + "," + Vhundreds + "" + Vtens + "" + Vones + "." + Vcents); }
else
if(Vnum >= 100) { Vformat = (Vhundreds + "" + Vtens + "" + Vones + "." + Vcents); }
else
if(Vnum >= 10) { Vformat = (Vtens + "" + Vones + "." + Vcents); }
else
if(Vnum >= 1) { Vformat = (Vones + "." + Vcents); } else { Vformat = ("0." + Vcents); }

return Vformat;
  }
}

function computeForm(form) {

var accumPrincipal = 0;
var accumCost = 0;
var accumPmtAmt = 0;
var accumPmts = 0;
var accumDebts = 0;
var reportRows = "";

//BEGIN DEBT NUMBER 1
var VD1 = form.D1.value;
var Vprin1 = form.prin1.value;
var VintRate1 = form.intRate1.value;
var Vpmt1 = form.pmt1.value;
var VtotCost1 = 0;
var Vnpr1 = 0;

if(Vprin1.length > 0 && VintRate1 > 0 && Vpmt1 > 0) {
VtotCost1 = computeCost(VD1,Vprin1,VintRate1,Vpmt1);
form.cost1.value = formatNum(VtotCost1);
Vnpr1 = computeTerm(VD1,Vprin1,VintRate1,Vpmt1);
accumPmts = Vnpr1;
form.npr1.value = formatNum(accumPmts);
accumCost = VtotCost1;
accumPrincipal = Vprin1;
accumPmtAmt = Vpmt1;
accumDebts++;
reportRow1 = createRow(VD1,Vprin1,form.intRate1.value,Vpmt1,form.cost1.value,form.npr1.value);
reportRows = "" + reportRows + "" + reportRow1 + "";
}
//END DEBT NUMBER 1

//BEGIN DEBT NUMBER 2
var VD2 = form.D2.value;
var Vprin2 = form.prin2.value;
var VintRate2 = form.intRate2.value;
var Vpmt2 = form.pmt2.value;
var VtotCost2 = 0;
var Vnpr2 = 0;

if(Vprin2.length > 0 && VintRate2 > 0 && Vpmt2 > 0) {
VtotCost2 = computeCost(VD2,Vprin2,VintRate2,Vpmt2);
form.cost2.value = formatNum(VtotCost2);
Vnpr2 = computeTerm(VD2,Vprin2,VintRate2,Vpmt2);
form.npr2.value = formatNum(Vnpr2);
if(Vnpr2 > accumPmts) { accumPmts = Vnpr2; }
accumCost = eval(accumCost) + eval(VtotCost2);
accumPrincipal = eval(accumPrincipal) + eval(Vprin2);
accumPmtAmt = eval(accumPmtAmt) + eval(Vpmt2);
accumDebts++;
reportRow2 = createRow(VD2,Vprin2,form.intRate2.value,Vpmt2,form.cost2.value,form.npr2.value);
reportRows = "" + reportRows + "" + reportRow2 + "";
}
//END DEBT NUMBER 2

//BEGIN DEBT NUMBER 3
var VD3 = form.D3.value;
var Vprin3 = form.prin3.value;
var VintRate3 = form.intRate3.value;
var Vpmt3 = form.pmt3.value;
var VtotCost3 = 0;
var Vnpr3 = 0;

if(Vprin3.length > 0 && VintRate3 > 0 && Vpmt3 > 0) {
VtotCost3 = computeCost(VD3,Vprin3,VintRate3,Vpmt3);
form.cost3.value = formatNum(VtotCost3);
Vnpr3 = computeTerm(VD3,Vprin3,VintRate3,Vpmt3);
form.npr3.value = formatNum(Vnpr3);
if(Vnpr3 > accumPmts) { accumPmts = Vnpr3; }
accumCost = eval(accumCost) + eval(VtotCost3);
accumPrincipal = eval(accumPrincipal) + eval(Vprin3);
accumPmtAmt = eval(accumPmtAmt) + eval(Vpmt3);
accumDebts++;
reportRow3 = createRow(VD3,Vprin3,form.intRate3.value,Vpmt3,form.cost3.value,form.npr3.value);
reportRows = "" + reportRows + "" + reportRow3 + "";
}
//END DEBT NUMBER 3

//BEGIN DEBT NUMBER 4
var VD4 = form.D4.value;
var Vprin4 = form.prin4.value;
var VintRate4 = form.intRate4.value;
var Vpmt4 = form.pmt4.value;
var VtotCost4 = 0;
var Vnpr4 = 0;

if(Vprin4.length > 0 && VintRate4 > 0 && Vpmt4 > 0) {
VtotCost4 = computeCost(VD4,Vprin4,VintRate4,Vpmt4);
form.cost4.value = formatNum(VtotCost4);
Vnpr4 = computeTerm(VD4,Vprin4,VintRate4,Vpmt4);
form.npr4.value = formatNum(Vnpr4);
if(Vnpr4 > accumPmts) { accumPmts = Vnpr4; }
accumCost = eval(accumCost) + eval(VtotCost4);
accumPrincipal = eval(accumPrincipal) + eval(Vprin4);
accumPmtAmt = eval(accumPmtAmt) + eval(Vpmt4);
accumDebts++;
reportRow4 = createRow(VD4,Vprin4,form.intRate4.value,Vpmt4,form.cost4.value,form.npr4.value);
reportRows = "" + reportRows + "" + reportRow4 + "";
}
//END DEBT NUMBER 4

//BEGIN DEBT NUMBER 5
var VD5 = form.D5.value;
var Vprin5 = form.prin5.value;
var VintRate5 = form.intRate5.value;
var Vpmt5 = form.pmt5.value;
var VtotCost5 = 0;
var Vnpr5 = 0;

if(Vprin5.length > 0 && VintRate5 > 0 && Vpmt5 > 0) {
VtotCost5 = computeCost(VD5,Vprin5,VintRate5,Vpmt5);
form.cost5.value = formatNum(VtotCost5);
Vnpr5 = computeTerm(VD5,Vprin5,VintRate5,Vpmt5);
form.npr5.value = formatNum(Vnpr5);
if(Vnpr5 > accumPmts) { accumPmts = Vnpr5; }
accumCost = eval(accumCost) + eval(VtotCost5);
accumPrincipal = eval(accumPrincipal) + eval(Vprin5);
accumPmtAmt = eval(accumPmtAmt) + eval(Vpmt5);
accumDebts++;
reportRow5 = createRow(VD5,Vprin5,form.intRate5.value,Vpmt5,form.cost5.value,form.npr5.value);
reportRows = "" + reportRows + "" + reportRow5 + "";
}
//END DEBT NUMBER 5

//BEGIN DEBT NUMBER 6
var VD6 = form.D6.value;
var Vprin6 = form.prin6.value;
var VintRate6 = form.intRate6.value;
var Vpmt6 = form.pmt6.value;
var VtotCost6 = 0;
var Vnpr6 = 0;

if(Vprin6.length > 0 && VintRate6 > 0 && Vpmt6 > 0) {
VtotCost6 = computeCost(VD6,Vprin6,VintRate6,Vpmt6);
form.cost6.value = formatNum(VtotCost6);
Vnpr6 = computeTerm(VD6,Vprin6,VintRate6,Vpmt6);
form.npr6.value = formatNum(Vnpr6);
if(Vnpr6 > accumPmts) {
accumPmts = Vnpr6;
}
accumCost = eval(accumCost) + eval(VtotCost6);
accumPrincipal = eval(accumPrincipal) + eval(Vprin6);
accumPmtAmt = eval(accumPmtAmt) + eval(Vpmt6);
accumDebts++;
reportRow6 = createRow(VD6,Vprin6,form.intRate6.value,Vpmt6,form.cost6.value,form.npr6.value);
reportRows = "" + reportRows + "" + reportRow6 + "";
}
//END DEBT NUMBER 6

//BEGIN DEBT NUMBER 7
var VD7 = form.D7.value;
var Vprin7 = form.prin7.value;
var VintRate7 = form.intRate7.value;
var Vpmt7 = form.pmt7.value;
var VtotCost7 = 0;
var Vnpr7 = 0;

if(Vprin7.length > 0 && VintRate7 > 0 && Vpmt7 > 0) {
VtotCost7 = computeCost(VD7,Vprin7,VintRate7,Vpmt7);
form.cost7.value = formatNum(VtotCost7);
Vnpr7 = computeTerm(VD7,Vprin7,VintRate7,Vpmt7);
form.npr7.value = formatNum(Vnpr7);
if(Vnpr7 > accumPmts) {
accumPmts = Vnpr7;
}
accumCost = eval(accumCost) + eval(VtotCost7);
accumPrincipal = eval(accumPrincipal) + eval(Vprin7);
accumPmtAmt = eval(accumPmtAmt) + eval(Vpmt7);
accumDebts++;
reportRow7 = createRow(VD7,Vprin7,form.intRate7.value,Vpmt7,form.cost7.value,form.npr7.value);
reportRows = "" + reportRows + "" + reportRow7 + "";
}
//END DEBT NUMBER 7

//BEGIN DEBT NUMBER 8
var VD8 = form.D8.value;
var Vprin8 = form.prin8.value;
var VintRate8 = form.intRate8.value;
var Vpmt8 = form.pmt8.value;
var VtotCost8 = 0;
var Vnpr8 = 0;

if(Vprin8.length > 0 && VintRate8 > 0 && Vpmt8 > 0) {
VtotCost8 = computeCost(VD8,Vprin8,VintRate8,Vpmt8);
form.cost8.value = formatNum(VtotCost8);
Vnpr8 = computeTerm(VD8,Vprin8,VintRate8,Vpmt8);
form.npr8.value = formatNum(Vnpr8);
if(Vnpr8 > accumPmts) { accumPmts = Vnpr8; }
accumCost = eval(accumCost) + eval(VtotCost8);
accumPrincipal = eval(accumPrincipal) + eval(Vprin8);
accumPmtAmt = eval(accumPmtAmt) + eval(Vpmt8);
accumDebts++;
reportRow8 = createRow(VD8,Vprin8,form.intRate8.value,Vpmt8,form.cost8.value,form.npr8.value);
reportRows = "" + reportRows + "" + reportRow8 + "";
}
//END DEBT NUMBER 8

//BEGIN DEBT NUMBER 9
var VD9 = form.D9.value;
var Vprin9 = form.prin9.value;
var VintRate9 = form.intRate9.value;
var Vpmt9 = form.pmt9.value;
var VtotCost9 = 0;
var Vnpr9 = 0;

if(Vprin9.length > 0 && VintRate9 > 0 && Vpmt9 > 0) {
VtotCost9 = computeCost(VD9,Vprin9,VintRate9,Vpmt9);
form.cost9.value = formatNum(VtotCost9);
Vnpr9 = computeTerm(VD9,Vprin9,VintRate9,Vpmt9);
form.npr9.value = formatNum(Vnpr9);
if(Vnpr9 > accumPmts) { accumPmts = Vnpr9; }
accumCost = eval(accumCost) + eval(VtotCost9);
accumPrincipal = eval(accumPrincipal) + eval(Vprin9);
accumPmtAmt = eval(accumPmtAmt) + eval(Vpmt9);
accumDebts++;
reportRow9 = createRow(VD9,Vprin9,form.intRate9.value,Vpmt9,form.cost9.value,form.npr9.value);
reportRows = "" + reportRows + "" + reportRow9 + "";
}
//END DEBT NUMBER 9

//BEGIN DEBT NUMBER 10
var VD10 = form.D10.value;
var Vprin10 = form.prin10.value;
var VintRate10 = form.intRate10.value;
var Vpmt10 = form.pmt10.value;
var VtotCost10 = 0;
var Vnpr10 = 0;

if(Vprin10.length > 0 && VintRate10 > 0 && Vpmt10 > 0) {
VtotCost10 = computeCost(VD10,Vprin10,VintRate10,Vpmt10);
form.cost10.value = formatNum(VtotCost10);
Vnpr10 = computeTerm(VD10,Vprin10,VintRate10,Vpmt10);
form.npr10.value = formatNum(Vnpr10);
if(Vnpr10 > accumPmts) { accumPmts = Vnpr10; }
accumCost = eval(accumCost) + eval(VtotCost10);
accumPrincipal = eval(accumPrincipal) + eval(Vprin10);
accumPmtAmt = eval(accumPmtAmt) + eval(Vpmt10);
accumDebts++;
reportRow10 = createRow(VD10,Vprin10,form.intRate10.value,Vpmt10,form.cost10.value,form.npr10.value);
reportRows = "" + reportRows + "" + reportRow10 + "";
}
//END DEBT NUMBER 10

if(accumDebts == 0) {
//alert("Please enter at least one debt before computing current debt costs.");
} else {

form.totalCost.value = formatNum(accumCost);
form.totalPrincipal.value = formatNum(accumPrincipal);
form.totalTerm.value = formatNum(accumPmts);
form.totalPmtAmt.value = formatNum(accumPmtAmt);

form.HtotalCost.value = accumCost;
form.HtotalPrincipal.value = accumPrincipal;
form.HtotalTerm.value = accumPmts;
form.HtotalPmtAmt.value = accumPmtAmt;
form.HtotalDebts.value = accumDebts;

reportRows = "" + reportRows + "<TR><TD COLSPAN=6><HR></TD></TR><TR><TD><B>Current Terms</B></TD><TD ALIGN=RIGHT>$" + form.totalPrincipal.value + "</TD><TD ALIGN=RIGHT>N/A</TD><TD ALIGN=RIGHT>$" + form.totalPmtAmt.value + "</TD><TD ALIGN=RIGHT>$" + form.totalCost.value +  "</TD><TD ALIGN=RIGHT>" + formatNum(accumPmts) + "</TD></TR>";

form.HreportRows.value = reportRows;
} //end of if/else statement that checks to see if any debts were entered
}

function computeLoan(form) {

computeForm(form);

if(form.consolAPR.value == 0 || form.consolAPR.value == "") {
alert("Please enter an annual interest rate for your consolidation loan.");
form.consolAPR.focus();
} else
if(form.consolTerm.value == 0 || form.consolTerm.value == "") {
alert("Please enter the length of the term (number of years) for your consolidation loan.");
form.consolTerm.focus();
} else {

var VconsolName = "Consolidation Loan";
var VconsolPrin = form.HtotalPrincipal.value;
var VconsolAPR = form.consolAPR.value;
var VconsolTerm = form.consolTerm.value;

var i = VconsolAPR;
if (i > 1.0) { i = i / 100.0; }
i /= 12;

var noMonths = VconsolTerm * 12;
var pow = 1;

for (var j = 0; j < noMonths; j++)
pow = pow * (1 + i);
var VconsolPmt = (VconsolPrin * pow * i) / (pow - 1);
var VtotConCost = computeCost(VconsolName,VconsolPrin,VconsolAPR,VconsolPmt);

var pmtSign = "-";
var pmtColor = "green";
var pmtReport = "";
var VHtotalPmt = form.HtotalPmtAmt.value;
form.totalNowPmt.value = formatNum(VHtotalPmt);
form.totalConPmt.value = formatNum(VconsolPmt);
var VpmtDiff = eval(VHtotalPmt) - eval(VconsolPmt);
if(VpmtDiff < 0) {
VpmtDiff *= -1;
pmtSign = "+";
pmtColor = "red";
}
pmtReport = pmtSign + "$" + formatNum(VpmtDiff);
form.pmtDiff.value = pmtSign + "" + formatNum(VpmtDiff);
var termSign = "-";
var termColor = "green";
var termReport = "";
var VHtotalTerm = form.HtotalTerm.value;
form.totalNowTerm.value = formatNum(VHtotalTerm);
form.totalConTerm.value = formatNum(noMonths);
var VtermDiff = eval(VHtotalTerm) - eval(noMonths);
if(VtermDiff < 0) {
VtermDiff *= -1;
termSign = "+";
termColor = "red";
}
termReport = termSign + "" + formatNum(VtermDiff);
form.termDiff.value = termSign + "" + formatNum(VtermDiff);

var VconsolFees = form.consolFees.value;
if(VconsolFees == "") { VconsolFees = 0; }
var intSign = "-";
var intColor = "green";
var intReport = "";
var VHtotalInt = form.HtotalCost.value;
form.totalNowInt.value = formatNum(VHtotalInt);
VtotConCost = eval(VtotConCost) + eval(VconsolFees);
form.totalConInt.value = formatNum(VtotConCost);
var VintDiff = eval(VHtotalInt) - eval(VtotConCost);
if(VintDiff < 0) {
VintDiff *= -1;
intSign = "+";
intColor = "red";
}
intReport = intSign + "$" + formatNum(VintDiff)
form.intDiff.value = intSign + "" + formatNum(VintDiff);

var VHtotalDebts = form.HtotalDebts.value;

if(pmtSign == "-" && termSign == "+" && intSign == "+") {
form.summary.value = "If you consolidate your " + VHtotalDebts + " debts into a single $" + formatNum(VconsolPrin) + " loan, for " + noMonths + " months, at " + form.consolAPR.value + "% APR, your monthly debt payments will be reduced by $" + formatNum(VpmtDiff) + ", but it will take you an additional " + formatNum(VtermDiff) + " months to pay off your debts and you will end up paying an additional $" + formatNum(VintDiff) + " in interest charges and/or loan fees.";
} else
if(pmtSign == "-" && termSign == "-" && intSign == "-") {
form.summary.value = "If you consolidate your " + VHtotalDebts + " debts into a single $" + formatNum(VconsolPrin) + " loan, for " + noMonths + " months, at " + form.consolAPR.value + "% APR, your monthly debt payments will be reduced by $" + formatNum(VpmtDiff) + ", you will pay off your debts " + formatNum(VtermDiff) + " months earlier and you will end up saving $" + formatNum(VintDiff) + " in interest charges and/or loan fees. Just make sure you don't create any new debt paying off your consolidation loan";
} else
if(pmtSign == "-" && termSign == "+" && intSign == "-") {
form.summary.value = "If you consolidate your " + VHtotalDebts + " debts into a single $" + formatNum(VconsolPrin) + " loan, for " + noMonths + " months, at " + form.consolAPR.value + "% APR, your monthly debt payments will be reduced by $" + formatNum(VpmtDiff) + ", it will take you an additional " + formatNum(VtermDiff) + " months to pay off your debts and you will end up saving $" + formatNum(VintDiff) + " in interest charges and/or loan fees. Just make sure you don't do what most people who consolidate do -- they create new debt while they're paying off their consolidation loan.";
} else
if(pmtSign == "-" && termSign == "-" && intSign == "+") {
form.summary.value = "If you consolidate your " + VHtotalDebts + " debts into a single $" + formatNum(VconsolPrin) + " loan, for " + noMonths + " months, at " + form.consolAPR.value + "% APR, your monthly debt payments will be reduced by $" + formatNum(VpmtDiff) + ", you will pay off your debts " + formatNum(VtermDiff) + " months earlier but you will end up paying an additional $" + formatNum(VintDiff) + " in interest charges and/or loan fees.";
} else
if(pmtSign == "+" && termSign == "-" && intSign == "+") {
form.summary.value = "If you consolidate your " + VHtotalDebts + " debts into a single $" + formatNum(VconsolPrin) + " loan, for " + noMonths + " months, at " + form.consolAPR.value + "% APR, your monthly debt payments will increase by $" + formatNum(VpmtDiff) + ", you will pay off your debts " + formatNum(VtermDiff) + " months earlier but you will end up paying an additional $" + formatNum(VintDiff) + " in interest charges and/or loan fees.";
} else {
form.summary.value = "No Summary Available.";
}

var reportRows = form.HreportRows.value;

reportRows = "" + reportRows + "<TR><TD COLSPAN=6><HR></TD></TR><TR><TD><B>Consolidation Terms</B></TD><TD ALIGN=RIGHT>$" + form.totalPrincipal.value + "</TD><TD ALIGN=RIGHT>" + formatNum(form.consolAPR.value) + "%</TD><TD ALIGN=RIGHT>$" + form.totalConPmt.value + "</TD><TD ALIGN=RIGHT>$" + form.totalConInt.value +  "</TD><TD ALIGN=RIGHT>" + form.totalConTerm.value + "</TD></TR><TR><TD COLSPAN=6><HR></TD></TR><TR><TD><B>Difference</B></TD><TD ALIGN=RIGHT></TD><TD ALIGN=RIGHT></TD><TD ALIGN=RIGHT><FONT COLOR=" + pmtColor + ">" + pmtReport + "</FONT></TD><TD ALIGN=RIGHT><FONT COLOR=" + intColor + ">" + intReport +  "</FONT></TD><TD ALIGN=RIGHT><FONT COLOR=" + termColor + ">" + termReport + "</FONT></TD></TR><TR><TD COLSPAN=6><HR></TD></TR><TR><TD COLSPAN=6><B>Summary:</B> " + form.summary.value + "</TD></TR>";

form.HreportRows.value = reportRows;
} //end of if/esle statement that checks to see if top section computed
}

function computeCost(name,principal,interest,payment) {
var i = interest;
if (i > 1.0) { i = i / 100.0; }
i /= 12;

var prin = principal;
var count = 0;
var prinPort = 0;
var intPort = 0;
var pmt = payment;
var accumInt = 0;

while(eval(prin) > eval(pmt)) {
intPort = prin * i;
accumInt = accumInt + intPort;
prinPort = pmt - intPort;
prin = prin - prinPort;
count = count +1;
if(count > 600) {
neverPayOff(name);
break;
  }
}

intPort = prin * i;
accumInt = accumInt + intPort;
prinPort = pmt - intPort;
prin = prin - prinPort;
var totalInt = accumInt;
return totalInt;
}

function computeTerm(name,principal,interest,payment) {
var i = interest;
if (i > 1.0) { i = i / 100.0; }
i /= 12;

var prin = principal;
var count = 0;
var prinPort = 0;
var intPort = 0;
var pmt = payment;
var accumInt = 0;
var lastPmt = 0;

while(eval(prin) > eval(pmt)) {
intPort = prin * i;
prinPort = pmt - intPort;
prin = prin - prinPort;
count = count +1;
if(count > 600) {
break;
 }
}

totalPmts = prin / payment + count;
return totalPmts;
}

function neverPayOff(name) { alert("Based on the terms you entered for " + name + ", your monthly interest charge is greater than your monthly payment -- which means you will never pay off " + name + ". Please increase the payment amount until this alert message disappears."); }

function return1(form) { form.D2.focus(); }
function return2(form) { form.D3.focus(); }
function return3(form) { form.D4.focus(); }
function return4(form) { form.D5.focus(); }
function return5(form) { form.D6.focus(); }
function return6(form) { form.D7.focus(); }
function return7(form) { form.D8.focus(); }
function return8(form) { form.D9.focus(); }
function return9(form) { form.D10.focus(); }
function return10(form) { form.D11.focus(); }
function return11(form) { form.D12.focus(); }
function return12(form) { form.D13.focus(); }
function return13(form) { form.D14.focus(); }
function return14(form) { form.D15.focus(); }
function createRow(name,principal,interest,payment,cost,term) {
reportRow = "<TR><TD>" + name + "</TD><TD ALIGN=RIGHT>$" + formatNum(principal) + "</TD><TD ALIGN=RIGHT>" + formatNum(interest) + "%</TD><TD ALIGN=RIGHT>$" + formatNum(payment) + "</TD><TD ALIGN=RIGHT>$" + cost +  "</TD><TD ALIGN=RIGHT>" + term + "</TD></TR>";

return reportRow;
}

function createReport(form) {
computeForm(form);
computeLoan(form);

var report = "<HEAD><TITLE>Loan Consolidation Report</TITLE></HEAD>" + "<BODY BGCOLOR = '#FFFFFF'><BR><BR><CENTER><FONT SIZE=+3>Loan Consolidation Report</FONT><BR><FONT SIZE=-1>(Please allow for slight rounding differences)</FONT></CENTER><P><CENTER><TABLE BORDER=0 CELLPADDING=3 with=550><TR><TD BGCOLOR=\"#BFBFBF\"><B>Debt Name<B></TD><TD BGCOLOR=\"#BFBFBF\" ALIGN=CENTER><B>Principal<BR>Balance<B></TD><TD BGCOLOR=\"#BFBFBF\" ALIGN=CENTER><B>APR<B></TD><TD BGCOLOR=\"#BFBFBF\" ALIGN=CENTER><B>Monthly<BR>Payment<B></TD><TD BGCOLOR=\"#BFBFBF\" ALIGN=CENTER><B>Interest<BR>Cost<B></TD><TD BGCOLOR=\"#BFBFBF\" ALIGN=CENTER><B>Number<BR>of Pmts<B></TD></TR> " + form.HreportRows.value + " </TABLE><P></CENTER></BODY></HTML>";

reportWin = window.open("","","resizable=yes,toolbar=yes,menubar=yes,scrollbars=yes");
reportWin.document.write(report);
reportWin.document.close();
}
