<!--

function selectcell() {
  document.inputForm.moInc.select()
  document.inputForm.moInc.focus()
}

function newwindow() {
  window.open("mc_notes0.html","Enter","scrollbars,width=420,height=400")
}

function newwindow2() {
  window.open("mc_notes0.html#Financial_Info","Finan","scrollbars,width=420,height=400")
}

function newwindow3() {
  window.open("mc_notes1.html#Available_Funds","Funds","scrollbars,width=420,height=400")
}

function newwindow4() {
  window.open("mc_notes2.html#Taxes","Tax","scrollbars,width=420,height=400")
}

function newwindow5() {
  window.open("mc_notes3.html#Loan_Conditions","Loan","scrollbars,width=420,height=400")
}

function newwindow6() {
  window.open("mc_notes4.html","Est","scrollbars,width=420,height=400")
}

function newwindow7() {
  window.open("mc_notes5.html#Down","Down","scrollbars,width=420,height=400")
}

function newwindow8() {
  window.open("mc_notes6.html#Mo_Payment","Pay","scrollbars,width=420,height=400")
}

function newwindow9() {
 window.open("mc_notes7.html#Mo_Housing_Exp","Housing","scrollbars,width=420,height=400")
}


function chknos(nos)
{
var str = nos.value;
if(str.length == 0) {
 return false;
}

oneDecimal = false;
for (var i = 0; i <str.length; i++) {
 var y = str.substring(i, i + 1);
 if (y == "." && !oneDecimal) {
    oneDecimal = true;
    continue
 }
 if (y < "0" || y > "9") {
 alert("Please enter positive numbers only. Calculator will use the default value for this entry. Click on underlined items for help and default values.");
 return false;
 }
}
 return true;
}

function number(nos,def)
{
if(!chknos(nos)) {
 return def;
}

var use = nos.value;
if(use == "" || use == null || (0 + use) == 0) {
 return def;
}

return parseFloat(use);
}

function f1(nos, y) {
var str = "" + Math.round(nos);
if (str.length == 0) {
   str = "0";
}
str = "$" + str;
i = y - str.length;
while (0 < i--) {
 str = " " + str;
}
return str;
}

function f2(nos, y, dec) {
  var str = "" + Math.round(eval(nos)*Math.pow(10,dec));
    while (str.length <= dec) {
      str = "0" + str;
    }
  var decpoint = str.length - dec;
  str = str.substring (0,decpoint) + "." +
    str.substring (decpoint, str.length);
if (str.length == 0) {
    str = "0";
}
str = str;
i = y - str.length;
while (0 < i--) {
 str = " " + str;
}
return str;
}

function f3(nos, y) {
var str = "" + Math.round(nos);
if (str.length == 0) {
     str = "0";
}
i = y - str.length;
while (0 < i--) {
 str = " " + str;
}
return str;
}

var newLoan = 0;

function compute(input)
{
var table = input.form;

percentDown = number(table.percentDown, 3);

moTtlInc = number(table.moInc,0)
moDebt = number(table.moDebt, 0)
percentCC = number(table.percentCC, 3);

if (percentDown < 5) {
    percentDown = 3.0;
}

if (percentDown >= 20) {
   pmi_rate = 0;
   availInc = moTtlInc * 0.33;
   if ((moTtlInc * 0.38 - moDebt) <= (moTtlInc * 0.33)) {
      availInc = moTtlInc * 0.38 - moDebt;
   }
}

if (percentDown < 20) {
   availInc = moTtlInc * 0.28;
   if ((moTtlInc * 0.36 - moDebt) <= (moTtlInc * 0.28)) {
      availInc = moTtlInc * 0.36 - moDebt;
   }
}

if (percentDown <= 15) {
   pmi_rate = 0.0073 - (percentDown - 3) * 0.000108;
}

if (percentDown > 15 && percentDown < 20) {
    pmi_rate = 0.0060 - (percentDown - 15) * 0.00076;
}

taxRate = number(table.taxRate, 1.2) / 1200;

intRate = table.rate.options[table.rate.selectedIndex].text;

term = table.term.options[table.term.selectedIndex].text;

insRate = number(table.insRate, 0.3) / 1200;

downTotal = number(table.down, 0);

moFees = number(table.fees, 0) / 12;

loan = (1 - Math.pow(intRate/1200 + 1, -term*12))*
 (availInc) / (intRate/1200);

moTax = loan * taxRate * (1/(1 - percentDown/100));

moIns = loan * insRate * (1/(1 - percentDown/100));

mopmi = pmi_rate * loan /12;

for ( var i = 1; i <= 100; i++) {
    moPI2 = availInc - moFees - moTax - moIns - mopmi;
    moPI1 = (Math.round((moPI2)*Math.pow(10,3)))/1000;
    newLoan = (1 - Math.pow(intRate/1200 + 1, -term*12)) * moPI1 / (intRate/1200);
    moTax = newLoan * taxRate * (1/(1 - percentDown/100));
    moIns = newLoan * insRate * (1/(1 - percentDown/100));
    mopmi = pmi_rate * newLoan /12;
    moPI2 = availInc - moFees - moTax - moIns - mopmi;
    moPI = (Math.round((moPI2)*Math.pow(10,3)))/1000;
    if ((moPI1 - moPI) == 0) {

       i = 100;
    }
}


downPay = newLoan * ((1/(1 - percentDown/100)) - 1);



propValue = newLoan + downPay;

downClose = propValue * percentCC/100;

down_close = downClose + downPay;

addDown = downTotal - down_close;

table.moInc.value = f3(moTtlInc, 1);
table.moDebt.value = f3(moDebt, 1);
table.down.value = f3(downTotal, 1);
table.taxRate.value = f2(taxRate*1200, 1, 2);
table.insRate.value = f2(insRate*1200, 1, 2);
table.fees.value = f3(moFees*12, 1);


table.percentDown.value = f2(percentDown, 1, 1);
table.percentCC.value = f2(percentCC, 1, 1);

totalPay = moPI + moTax + moIns + moFees + mopmi;
if (newLoan <= 0) totalPay =0;
table.totalPay.value = f1(totalPay, 10);

if (newLoan <= 0) moTax = 0;
table.moTax.value = f1(moTax, 10);

if (newLoan <= 0) moIns =0;
table.moIns.value = f1(moIns, 10);

table.moFees.value = f1(moFees, 10);

if (newLoan <= 0) downClose = 0;
table.downClose.value = f1(downClose, 10);

if (newLoan <= 0) mopmi = 0;
table.mopmi.value = f1(mopmi, 10);

if (newLoan <= 0) down_close = 0;
table.down_close.value = f1(down_close, 10);

if (newLoan <= 0) addDown = 0;
table.addDown.value = f1(addDown, 10);

if (moPI <= 0) moPI = 0;
table.moPI.value=f1(moPI, 10);

if(newLoan <= 0) newLoan = 0;
table.maxLoan.value = f1(newLoan, 10);

if (newLoan <= 0) propValue = 0;
table.propValue.value = f1(propValue, 10);

if (newLoan <= 0) downPay = 0;
table.downPay.value = f1(downPay, 10);

intRate=intRate*1000
document.cookie="condition_loan="+intRate.toString()+term.toString()+(Math.round(newLoan)).toString()

}

function checkLoan(form) {
   var moInc = document.inputForm.moInc.value;
   if (isNaN(newLoan) || newLoan == 0 || newLoan < 1000 || moInc == 0) {
        alert("Maximum Mortgage Amount is either blank, zero or less than 1000. You must enter enough income to generate a mortgage loan amount of 1000 or greater to run an Amortization Table.")
   document.inputForm.moInc.select()
   document.inputForm.moInc.focus()

   }else{

window.open("amortz.html","Amortz","menubar,scrollbars,width=520,height=400")
}
}


<!-->
