﻿// JScript File

function stripNum(num) {

var iPercent
var iDollar
var iSpace
var iComma
var numLength = num.length

//lalalla Line #114

if(numLength > 0) {

   num=num.toString();

   iPercent = num.indexOf("%");
   if(iPercent >= 0) {
      num=num.substring(0,iPercent) + "" + num.substring(iPercent + 1,numLength);
      numLength=num.length;
      }
   iDollar = num.indexOf("$");
   if(iDollar >= 0) {
      num=num.substring(0,iDollar) + "" + num.substring(iDollar + 1,numLength);
      numLength=num.length;
      }
   iSpace = num.indexOf(" ");
   if(iSpace >= 0) {
      num=num.substring(0,iSpace) + "" + num.substring(iSpace + 1,numLength);
      numLength=num.length;
      }
   iComma = num.indexOf(",");
   if(iComma >= 0) {
      while(iComma >=1) {
         num=num.substring(0,iComma) + "" + num.substring(iComma + 1,numLength);
         numLength=num.length;
         iComma = num.indexOf(",");
      }
      }

      num = eval(num);


} else {

num = 0;

}

return num;

}




function computeMonthlyPayment(prin, numPmts, intRate) {

var pmtAmt = 0;

if(intRate == 0) {
   pmtAmt = prin / numPmts;
} else {
   
   if (intRate >= 1.0) {
     intRate = intRate / 100.0;
   }
   intRate /= 12;

   var pow = 1;
   for (var j = 0; j < numPmts; j++)
      pow = pow * (1 + intRate);

   pmtAmt = (prin * pow * intRate) / (pow - 1);

}

return pmtAmt;

}




function formatNumberDec(num, places, comma) {

var isNeg=0;

    if(num < 0) {
       num=num*-1;
       isNeg=1;
    }

    var myDecFact = 1;
    var myPlaces = 0;
    var myZeros = "";
    while(myPlaces < places) {
       myDecFact = myDecFact * 10;
       myPlaces = eval(myPlaces) + eval(1);
       myZeros = myZeros + "0";
    }
    
	onum=Math.round(num*myDecFact)/myDecFact;
		
	integer=Math.floor(onum);

	if (Math.ceil(onum) == integer) {
		decimal=myZeros;
	} else{
		decimal=Math.round((onum-integer)* myDecFact)
	}
	decimal=decimal.toString();
	if (decimal.length<places) {
        fillZeroes = places - decimal.length;
	   for (z=0;z<fillZeroes;z++) {
        decimal="0"+decimal;
        }
     }

   if(places > 0) {
      decimal = "." + decimal;
   }

   if(comma == 1) {
	integer=integer.toString();
	var tmpnum="";
	var tmpinteger="";
	var y=0;

	for (x=integer.length;x>0;x--) {
		tmpnum=tmpnum+integer.charAt(x-1);
		y=y+1;
		if (y==3 & x>1) {
			tmpnum=tmpnum+",";
			y=0;
		}
	}

	for (x=tmpnum.length;x>0;x--) {
		tmpinteger=tmpinteger+tmpnum.charAt(x-1);
	}


	finNum=tmpinteger+""+decimal;
   } else {
      finNum=integer+""+decimal;
   }

    if(isNeg == 1) {
       finNum = "-" + finNum;
    }

	return finNum;
}


function computeForm(form) {

//IF REQUIRED FIELDS EMPTY, ALERT AND KILL SCRIPT
if(form.grossPay.value == "" || form.grossPay.value == 0) {
   alert("Please enter your gross annual income.");
   form.grossPay.focus();
   } else
if(form.intRate.value == "" || form.intRate.value == 0) {
   alert("Please enter the annual interest rate you expect to pay.");
   form.intRate.focus();
   } else {
//START REQUIRED FIELD VARIFICATION

//SET OPTIONAL BLANK FIELDS EQUAL TO ZERO;
var VmonthlyDebtPmts = stripNum(form.moDebts.value);
var VmoInsurance = stripNum(form.moInsurance.value);
var VannPropTaxPerc = stripNum(form.propTaxPerc.value);
if(VannPropTaxPerc >= 1) {
   VannPropTaxPerc = VannPropTaxPerc / 100;
}
var VmoPropTaxPerc = VannPropTaxPerc / 12;

//var VmoPropTax = stripNum(form.moPropTax.value);
//var VmoPropTax = 0;



//COMPUTE MONTHLY INCOME BASED ON ANNUAL INCOME
var VgrossPay = stripNum(form.grossPay.value);
var monthlyIncome = VgrossPay /12;

//MORTGAGE PAYMENT CAN'T EXCEED 28% OF MONTHLY INCOME
var VpmtRatio = stripNum(form.pmtRatio.value);
if(VpmtRatio >= 1) {
   VpmtRatio /= 100;
}
var maxIncomePmt = monthlyIncome * VpmtRatio;

//MORTGAGE PAYMENT PLUS DEBT PMTS CAN'T EXCEED 36% OF MONTHLY INCOME
var VdebtRatio = stripNum(form.debtRatio.value);
if(VdebtRatio >= 1) {
   VdebtRatio /= 100;
}
var maxDebtToIncomePmt = eval(VdebtRatio * monthlyIncome) - eval(VmonthlyDebtPmts);

//USE THE LOWER OF 28% OR 36% AS MAXIMUM HOUSE PAYMENT
var maxHousePmt = 0;
if(maxIncomePmt > maxDebtToIncomePmt) {
   maxHousePmt = maxDebtToIncomePmt;
   } else {
   maxHousePmt = maxIncomePmt;
   }



//IF MAX HOUSE PAYMENT IS LESS THAN $1, ALERT & KILL SCRIPT
if(maxHousePmt < 1) {
   form.downPay2.value = "";
   form.loanAmt.value = "";
   form.homePrice.value = "";
   form.moPay.value = "";
   alert("Based on industry standards you would not qualify for a home mortgage. In order to qualify you will need to either increase your annual income or lower your monthly debt payments, or a combination of both.")
   } else {
//START HOUSE PAYMENT VERIFICATION

//ADJUST HOUSE PAYMENT DOWN TO REFLECT MONTHLY PMI, INSURANCE & TAX

//GATHER VARIABLES FOR PAYMENT AND PRINCIPLE COMPUTATIONS
var Vi = stripNum(form.intRate.value);
var VintRate = stripNum(form.intRate.value);
if(VintRate >= 1) {
   VintRate = VintRate / 100;
} else {
   VintRate = VintRate;
}

VintRate = VintRate / 12;

var Vterm = 0;
if(form.term.selectedIndex == 0) {
   Vterm = 180;
} else
if(form.term.selectedIndex == 1) {
   Vterm = 240;
} else {
   Vterm = 360;
}


//MAKE INITIAL DETERMINATION OF NEW MAX HOUSE PMT

//COMPUTE PRINCIPAL PAID ON MAXIMUM MONTHLY PAYMENT
var pow = 1;

for (var j = 0; j < Vterm; j++) {
    pow = pow * (1 + VintRate);
}

var maxLoanAmt = ((pow - 1) * maxHousePmt) / (pow * VintRate);


//DETERMINE INITIAL HOME PRICE
var VdownPay = stripNum(form.downPay.value);
var maxHomePrice = eval(maxLoanAmt) + eval(VdownPay);

//DETERMINE INITIAL PMI
var VmoPMIPercent = stripNum(form.moPMIPercent.value);
if(form.moPMIPercent.value.length == 0) {
   var downPayPerc = VdownPay / maxHomePrice;
   var PMIPerc = 0;
   if(downPayPerc < .05) {
      PMIPerc = 0;
   } else
   if(downPayPerc < .10) {
      PMIPerc = .00065;
   } else
   if(downPayPerc < .15) {
      PMIPerc = .00043;
   } else
   if(downPayPerc < .20) {
      PMIPerc = .00027;
   } else {
      PMIPerc = 0;
   }
} else {
   PMIPerc = VmoPMIPercent / 1000;
}
var monthlyPMI = maxLoanAmt * PMIPerc;

//DETERMINE INITIAL PROPERTY TAX
var monthlyPropTax = maxHomePrice * VmoPropTaxPerc;

var initMaxHousePmt = eval(maxHousePmt);

//var initMaxHousePmt = eval(maxHousePmt) - eval(monthlyPMI) - eval(VmoInsurance) - eval(monthlyPropTax);

var newMaxHousePmt = 0;
var newMaxLoanAmt = 0;
var newMaxHomePrice = 0;
var totalOfPmts = eval(maxHousePmt) + eval(monthlyPMI) + eval(VmoInsurance) + eval(monthlyPropTax);;
var count = 0;

while(totalOfPmts > maxHousePmt) {

   initMaxHousePmt = eval(initMaxHousePmt) - eval(1);

   //MAKE INITIAL DETERMINATION OF NEW MAX HOUSE PMT

   //COMPUTE PRINCIPAL PAID ON MAXIMUM MONTHLY PAYMENT
   newMaxLoanAmt = ((pow - 1) * initMaxHousePmt) / (pow * VintRate);

   //DETERMINE NEW HOME PRICE
   newMaxHomePrice = eval(newMaxLoanAmt) + eval(VdownPay);

   //DETERMINE INITIAL PMI
if(form.moPMIPercent.value.length == 0) {
   downPayPerc = VdownPay / newMaxHomePrice;
   PMIPerc = 0;
   if(downPayPerc < .05) {
      PMIPerc = 0;
   } else
   if(downPayPerc < .10) {
      PMIPerc = .00065;
   } else
   if(downPayPerc < .15) {
      PMIPerc = .00043;
   } else
   if(downPayPerc < .20) {
      PMIPerc = .00027;
   } else {
      PMIPerc = 0;
   }
} else {
   PMIPerc = VmoPMIPercent / 1000;
}
   monthlyPMI = newMaxLoanAmt * PMIPerc;

   //DETERMINE INITIAL PROPERTY TAX
   monthlyPropTax = newMaxHomePrice * VmoPropTaxPerc;

   totalOfPmts = eval(initMaxHousePmt) + eval(monthlyPMI) + eval(VmoInsurance) + eval(monthlyPropTax);

   count = eval(count) + eval(1);
   if(count > 1000) {
      break;
   } else {
      continue;
   }
}




//ENTER TOTALS
form.downPay2.value = "$" + formatNumberDec(VdownPay,2,1);
form.loanAmt.value = "$" + formatNumberDec(newMaxLoanAmt,2,1);
form.homePrice.value = "$" + formatNumberDec(eval(VdownPay) + eval(newMaxLoanAmt),2,1);
form.moPMI.value = "$" + formatNumberDec(monthlyPMI,2,1);
form.moIns.value = "$" + formatNumberDec(VmoInsurance,2,1);
form.moTax.value = "$" + formatNumberDec(monthlyPropTax,2,1);
form.moPay.value = "$" + formatNumberDec(initMaxHousePmt,2,1);
form.moTotal.value = "$" + formatNumberDec(totalOfPmts,2,1);

//DISPLAY SUMMARY
form.enterHelp.value = ("After testing your entries against mortgage industry standards the highest priced house you could qualify for is " + form.homePrice.value + ".  Obviously this amount is merely an estimate.  The actual amount will vary from lender to lender.")

//DISPLAY SUMMARY
form.resultHelp.value = ("Place your mouse over the question marks at left to see an explanation of each result.")

//END HOUSE PAYMENT VERIFICATION
      }

//END REQUIRED FIELD VARIFICATION
   }

}

//GIVE ENTRY INSTRUCTIONS
function skipTo(form) {
form.enterHelp.value = "";
form.downPay.focus();
}

function help01(form) {
form.enterHelp.value = ("ENTER: Your gross annual household income.  This is the amount before taxes are deducted.");
}

function help02(form) {
form.enterHelp.value = ("ENTER: The total of your non-mortgage monthly debt payments. This would include car loans, student loans, credit card payments and so on.");
}

function help03(form) {
form.enterHelp.value = ("ENTER: The amount you have available to cover the mortgage down payment and closing costs.");
}

function help04(form) {
form.enterHelp.value = ("ENTER: The annual interest rate you expect to pay on this mortgage. You can enter the rate either as a percentage (8.25) or as a decimal (.0825), whichever you prefer.");
}

function help05(form) {
form.enterHelp.value = ("ENTER: The monthly Private Mortgage Insurance Percentage(PMI) you expect to pay (usually between .02% and .07% of loan amount). If you don't know what the percentage is, leave the field blank and the calculator will estimate your monthly PMI based on industry standards. If you DO know what the PMI percentage is, move the decimal place 1 digit to the right when entering (enter .04% simply as .4).");
}

function help06(form) {
form.enterHelp.value = ("ENTER: The monthly insurance payment you expect to pay. As a rule of thumb, you can expect to pay .125% (home price X .00125) of the purchase price per month.");
}

function help07(form) {
form.enterHelp.value = ("ENTER: The annual property tax percentage you expect to pay. As a rule of thumb, you can expect to pay 1.1% of the purchase price per year (Enter 1.1% as 1.1).");
}

function help08(form) {
form.enterHelp.value = ("ENTER: Your area's maximum mortgage payment to income ratio. The default ratio is 28%, in which case your mortgage payment cannot exceed 28% of your monthly income.");
}

function help09(form) {
form.enterHelp.value = ("ENTER: Your area's maximum mortgage payment plus debt payments to income ratio. The default ratio is 36%, in which case your mortgage payment plus your debt payments cannot exceed 36% of your monthly income.");
}



//GIVE RESULT EXPLANATIONS
function help10(form) {
form.resultHelp.value = ("RESULT: This is your original down payment amount.");
}

function help11(form) {
form.resultHelp.value = ("RESULT: This is the maximum mortgage you would qualify for based on your current entries.");
}

function help12(form) {
form.resultHelp.value = ("RESULT: This is home price you could afford (the total of your down payment and your maximum mortgage amount).");
}

function help13(form) {
form.resultHelp.value = ("RESULT: This is your estimated monthly PMI payment amount.");
}

function help14(form) {
form.resultHelp.value = ("RESULT: This is your estimated monthly insurance payment amount.");
}

function help15(form) {
form.resultHelp.value = ("RESULT: This is your estimated monthly property tax payment amount.");
}

function help16(form) {
form.resultHelp.value = ("RESULT: This is your estimated monthly principal and interest payment amount.");
}

function help17(form) {
form.resultHelp.value = ("RESULT: This is the estimated total of all monthly payments associated to size of the mortgage that the calculator determined you would qualify for.");
}

function amortSchedule(form) {

if(form.loanAmt.value.length == 0) {

   alert("Please calculate the form before attempting to create the amortization schedule.");
   form.grossPay.focus();
} else

if(document.mortCalc.intRate.value == 0) {
   alert("Please calculate the form before attempting to create the amortization schedule.");
   form.intRate.focus();

} else {

var Vprincipal = stripNum(form.loanAmt.value);

var VintRate = stripNum(form.intRate.value);

var VnumYears = form.term.options[form.term.selectedIndex].value;

var VnumPmts = VnumYears * 12;

var pmtAmt = stripNum(form.moPay.value);

var prin = Vprincipal;

var Vint = VintRate;

if(Vint >= 1) {

   Vint /= 100;

   }

Vint /= 12;


var nPer = VnumPmts;

var intPort = 0;

var accumInt = 0;

var prinPort = 0;

var accumPrin = 0;

var count = 0;

var pmtRow = "";

var pmtNum = 0;

var today = new Date();

var dayFactor = today.getTime();

var pmtDay = today.getDate();

var loanMM = today.getMonth() + 1;

var loanYY = today.getYear();
if(loanYY < 1900) {
   loanYY += 1900;
}

var loanDate = (loanMM + "/" + pmtDay + "/" + loanYY);

var monthMS = 86400000 * 30.4;

var pmtDate = 0;

var displayPmtAmt = 0;

var accumYearPrin = 0;
var accumYearInt = 0;

while(count < nPer) {

   if(count < (nPer - 1)) {

      intPort = prin * Vint;
      intPort *= 100;
      intPort = Math.round(intPort);
      intPort /= 100;

      accumInt = eval(accumInt) + eval(intPort);
      accumYearInt = eval(accumYearInt) + eval(intPort);

      prinPort = eval(pmtAmt) - eval(intPort);
      prinPort *= 100;
      prinPort = Math.round(prinPort);
      prinPort /= 100;

      accumPrin = eval(accumPrin) + eval(prinPort);
      accumYearPrin = eval(accumYearPrin) + eval(prinPort);

      prin = eval(prin) - eval(prinPort);

      displayPmtAmt = eval(prinPort) + eval(intPort);

   } else {

      intPort = prin * Vint;
      intPort *= 100;
      intPort = Math.round(intPort);
      intPort /= 100;

      accumInt = eval(accumInt) + eval(intPort);
      accumYearInt = eval(accumYearInt) + eval(intPort);

      prinPort = prin;

      accumPrin = eval(accumPrin) + eval(prinPort);
      accumYearPrin = eval(accumYearPrin) + eval(prinPort);

      prin = 0;

      //pmtAmt = eval(intPort) + eval(prinPort);
      displayPmtAmt = eval(prinPort) + eval(intPort);
   }

   count = eval(count) + eval(1);

   pmtNum = eval(pmtNum) + eval(1);

   dayFactor = eval(dayFactor) + eval(monthMS);

   pmtDate = new Date(dayFactor);

   pmtMonth = pmtDate.getMonth();

   pmtMonth = pmtMonth + 1;

   pmtYear = pmtDate.getYear();
   if(pmtYear < 1900) {
      pmtYear += 1900;
   }


   pmtString = (pmtMonth + "/" + pmtDay + "/" + pmtYear);

   pmtRow = ("" + pmtRow + "<tr><td align=right><font face='arial'><small>" + pmtNum + "</small></font></td><td align=right><font face='arial'><small>" + pmtString + "</small></font></td><td align=right><font face='arial'><small>" + formatNumberDec(prinPort,2,1) + "</small></font></td><td align=right><font face='arial'><small>" + formatNumberDec(intPort,2,1) + "</small></font></td><td align=right><font face='arial'><small>" + formatNumberDec(displayPmtAmt,2,1) + "</small></font></td><td align=right><font face='arial'><small>" + formatNumberDec(prin,2,1) + "</small></font></td></tr>");

   if(pmtMonth == 12 || count == nPer) {

pmtRow = ("" + pmtRow + "<tr bgcolor='#dddddd'><td align=right><font face='arial'><small>Total</small></font></td><td align=left><font face='arial'><small>" + pmtYear + "</small></font></td><td align=right><font face='arial'><small>" + formatNumberDec(accumYearPrin,2,1) + "</small></font></td><td align=right><font face='arial'><small>" + formatNumberDec(accumYearInt,2,1) + "</small></font></td><td align=right><font face='arial'><small> </small></font></td><td align=right><font face='arial'><small> </small></font></td></tr>");

   accumYearPrin = 0;
   accumYearInt = 0;

   }

      if(count > 600) {

         alert("Using your current entries you will never pay off this loan.");

         break;

         } else {

         continue;

         }

    }



var part1 = ("<head><title>Amortization Schedule</title></head>" + "<body bgcolor= '#FFFFFF'><br><br><center><font face='arial'><big><strong>Amortization Schedule</strong></big></font></center>");



var part2 = ("<center><table border=1 cellpadding=2 cellspacing=0><tr><td colspan=6><font face='arial'><small><b>Loan Date: " + loanDate + "<br>Principal: $" + formatNumberDec(Vprincipal,2,1) + "<br># of Payments: " + nPer + "<br>Interest Rate: " + formatNumberDec(VintRate,3,0) + "%<br>Payment: $" + formatNumberDec(pmtAmt,2,1) + "</b></small></font></td></tr><tr><td colspan=6><center><font face='arial'><b>Schedule of Payments</b></font><br><font face='arial'><small><small>Please allow for slight rounding differences.</small></small></font></center></td></tr><tr bgcolor='silver'><td align='center'><font face='arial'><small><b>Pmt #</b></small></font></td><td align='center'><font face='arial'><small><b>Date</b></small></font></td><td align='center'><font face='arial'><small><b>Principal</b></small></font></td><td align='center'><font face='arial'><small><b>Interest</b></small></font></td><td align='center'><font face='arial'><small><b>Payment</b></small></font></td><td align='center'><font face='arial'><small><b>Balance</b></small></font></td></tr>");



var part3 = ("" + pmtRow + "");

var totalPmts = eval(accumPrin) + eval(accumInt);

var part4 = ("<tr><td colspan='2'><font face='arial'><small><b>Grand Total</b></small></font></td><td align=right><font face='arial'><small><b>" + formatNumberDec(accumPrin,2,1) + "</b></small></font></td><td align=right><font face='arial'><small><b>" + formatNumberDec(accumInt,2,1) + "</b></small></font></td><td><font face='arial'><small><b>" + formatNumberDec(totalPmts,2,1) + "</b></small></font></td><td> </td></tr></table><br><center><form method='post'><input type='button' value='Close Window' onClick='window.close()'></form></center></body></html>");



var schedule = (part1 + "" + part2 + "" + part3 + part4 + "");



  reportWin = window.open("","","width=500,height=400,toolbar=yes,menubar=yes,scrollbars=yes");

  reportWin.document.write(schedule);

  reportWin.document.close();



   }



}

function printFriendForm(form) {


var printRows = "";

printRows = printRows + "<TR>";
printRows = printRows + "<TD colspan='2'>";
printRows = printRows + "<font face='arial'><small><b>";
printRows = printRows + "Inputs";
printRows = printRows + "</b></small></font>";
printRows = printRows + "</tr>";

printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Gross annual income:";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";

var VgrossPay = stripNum(form.grossPay.value);
printRows = printRows + "$" + formatNumberDec(VgrossPay,2,1);

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";


printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Monthly debt payments:";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";

var VmoDebts = stripNum(form.moDebts.value);
printRows = printRows + "$" + formatNumberDec(VmoDebts,2,1);

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";


printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Down payment:";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";

var VdownPay = stripNum(form.downPay.value);
printRows = printRows + "$" + formatNumberDec(VdownPay,2,1);

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";


printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Annual interest rate:";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";

var VintRate = stripNum(form.intRate.value);
printRows = printRows + "" + formatNumberDec(VintRate,3,0) + "%";

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";


printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Monthly Private Mortgage Insurance (PMI %):";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";

var VmoPMIAmt = stripNum(form.moPMI.value);
var VhomePrice = stripNum(form.homePrice.value);
var VmoPMIPercent = VmoPMIAmt / VhomePrice * 100;
printRows = printRows + "" + formatNumberDec(VmoPMIPercent,2,0) + "%";

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";


printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Monthly insurance:";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";

var VmoInsurance = stripNum(form.moInsurance.value);
printRows = printRows + "$" + formatNumberDec(VmoInsurance,2,1);

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";


printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Annual property tax percent:";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";

var VpropTaxPerc = stripNum(form.propTaxPerc.value);
printRows = printRows + formatNumberDec(VpropTaxPerc,2,1) + "%";

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";



printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Length of the mortgage:";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";

var Vterm = form.term.options[form.term.selectedIndex].value;
printRows = printRows + "" + Vterm;

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";


printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Maximum mortgage payment to income ratio (%):";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";

var VpmtRatio = stripNum(form.pmtRatio.value);
printRows = printRows + "" + formatNumberDec(VpmtRatio,2,1) + "%";

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";


printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Maximum debt payments to income ratio (%):";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";

var VdebtRatio = stripNum(form.debtRatio.value);
printRows = printRows + "" + formatNumberDec(VdebtRatio,2,1) + "%";

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";

printRows = printRows + "<TR>";
printRows = printRows + "<TD colspan='2'>";
printRows = printRows + "<font face='arial'><small><b>";
printRows = printRows + "Results";
printRows = printRows + "</b></small></font>";
printRows = printRows + "</tr>";


printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Downpayment:";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";

var VdownPay2 = stripNum(form.downPay2.value);
printRows = printRows + "$" + formatNumberDec(VdownPay2,2,1);

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";


printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Loan Amount:";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";

var VloanAmt = stripNum(form.loanAmt.value);
printRows = printRows + "$" + formatNumberDec(VloanAmt,2,1);

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";



printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Home Price:";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";


printRows = printRows + "$" + formatNumberDec(VhomePrice,2,1);

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";


printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Monthly PMI Payment:";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";

var VmoPMI = stripNum(form.moPMI.value);
printRows = printRows + "$" + formatNumberDec(VmoPMI,2,1);

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";


printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Monthly Insurance:";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";

var VmoIns = stripNum(form.moIns.value);
printRows = printRows + "$" + formatNumberDec(VmoIns,2,1);

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";

printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Monthly property tax payment:";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";

var VmoTax = stripNum(form.moTax.value);
printRows = printRows + "$" + formatNumberDec(VmoTax,2,1);

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";



printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Monthly principal & interest payment:";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";

var VmoPay = stripNum(form.moPay.value);
printRows = printRows + "$" + formatNumberDec(VmoPay,2,1);

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";

printRows = printRows + "<TR>";
printRows = printRows + "<TD>";
printRows = printRows + "<font face='arial'><small>";
printRows = printRows + "Total of all mortgage related payments:";
printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "<TD align='right'>";
printRows = printRows + "<font face='arial'><small>";

var VmoTotal = stripNum(form.moTotal.value);
printRows = printRows + "$" + formatNumberDec(VmoTotal,2,1);

printRows = printRows + "</small></font>";
printRows = printRows + "</td>";
printRows = printRows + "</tr>";


var part1 = ("<head><title>Calculator Results</title></head>" + "<body bgcolor= '#FFFFFF'><br><br><center><font face='arial'><big><strong>Mortgage Qualification Calculations</strong></big></font></center>");



var part2 = ("<center><table border=1 cellpadding=2 cellspacing=0>");



var part3 = ("" + printRows + "");



var part4 = ("</table><br><center><form method='post'><input type='button' value='Close Window' onClick='window.close()'></form></center></body></html>");



var schedule = (part1 + "" + part2 + "" + part3 + part4 + "");



  reportWin = window.open("","","width=500,height=400,toolbar=yes,menubar=yes,scrollbars=yes");

  reportWin.document.write(schedule);

  reportWin.document.close();

}
