function jumpBox(list) {
   location.href = list.options[list.selectedIndex].value
   }

//!-- license number 13110010 --!

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) {

if(form.principal.value == "" || form.principal.value == 0) {
   alert("Please enter an amount in Line #1.");
   form.principal.focus();
   } else
      if(form.intRate.value == "" || form.intRate.value == 0) {
      alert("Please enter an amount in Line #2.");
      form.intRate.focus();
   } else
      if(form.numYears.value == "" || form.numYears.value == 0) {
      alert("Please enter an amount in Line #3.");
      form.numYears.focus();
   } else {

var Vprincipal = form.principal.value;

var intRate = form.intRate.value;

if (intRate > 1.0) {

        intRate = intRate / 100.0;
        } else {
        intRate = intRate;
        }

intRate = intRate / 12;

var numMonths = form.numYears.value * 12;

//FIGURE PAYMENT NEEDED TO PAY OFF $1,000

    var factor = 1;

    for (var j = 0; j < numMonths; j++) {

        factor = factor * (eval(1) + eval(intRate));
        }


    var moPmt = (Vprincipal * factor * intRate) / (eval(factor) - eval(1));

    form.moPmt.value = "$" + formatNum(moPmt);
    form.HmoPmt.value = moPmt;

//END VARIFICATION IF STATEMENT
   }
    
}


function createReport(form) {

//GRAB VARIABLES

var aPrin = form.principal.value;

var aIntRate = form.intRate.value;
if(aIntRate > 1) {
   aIntRate = aIntRate / 100;
   } else {
   aIntRate = aIntRate;
   }
aIntRate = aIntRate /12;

var aNPer = form.numYears.value *12;

if(form.HmoPmt.value == 0 || form.HmoPmt.value == "") {
   alert("Please compute the payment before creating the schedule.");
   } else {

var aPmt = form.HmoPmt.value;

var aIntPort = 0;
var aAccumInt = 0;
var aPrinPort = 0;
var aAccumPrin = 0;
var aCount = 0;
var aPmtRow = "";
var aPmtNum = 0;

var today = new Date();
var dayFactor = today.getTime();

var pmtDay = today.getDate();
var loanMM = today.getMonth() + 1;
var loanYY = today.getYear();
var loanDate = (loanMM + "/" + pmtDay + "/" + loanYY);
var monthMS = 86400000 * 30.4;
var pmtDate = 0;

while(aCount < aNPer) {
   aIntPort = aPrin * aIntRate;
      aAccumInt = eval(aAccumInt) + eval(aIntPort);
   aPrinPort = eval(aPmt) - eval(aIntPort);
      aAccumPrin = eval(aAccumPrin) + eval(aPrinPort);
   aPrin = eval(aPrin) - eval(aPrinPort);
   aCount = eval(aCount) + eval(1);
   aPmtNum = eval(aPmtNum) + eval(1);
   dayFactor = eval(dayFactor) + eval(monthMS);
   pmtDate = new Date(dayFactor);
   pmtMonth = pmtDate.getMonth();
   pmtMonth = pmtMonth + 1;
   pmtYear = pmtDate.getYear();
   pmtString = (pmtMonth + "/" + pmtDay + "/" + pmtYear);
   aPmtRow = ("" + aPmtRow + "<TR><TD ALIGN=CENTER>" + aPmtNum + "</TD><TD ALIGN=CENTER>" + pmtString + "</TD><TD ALIGN=CENTER>" + formatNum(aPrinPort) + "</TD><TD ALIGN=CENTER>" + formatNum(aIntPort) + "</TD><TD ALIGN=CENTER>" + formatNum(aPrin) + "</TD></TR>");
      if(aCount > 600) {
         alert("Using your current entries you will never pay off this loan.");
         break;
         } else {
         continue;
         }
    }

var part1 = ("<HEAD><TITLE>American Mortgage Consultants Amortization Schedule</TITLE><link rel=stylesheet href=style.css type=text/css></HEAD>" + "<BODY BGCOLOR = '#FFFFFF'>");

var part2 = ("<CENTER><TABLE width=98% CELLPADDING=4 class=txt><TR><TD COLSPAN=5><span class=txt5>Amortization Schedule</span><br><br><B>Loan Date:</b> " + loanDate + "<BR><B>Principal:</b> $" + formatNum(form.principal.value) + "<BR><B># of Payments:</b> " + aNPer + "<BR><B>Interest Rate:</b> " + formatNum(aIntRate * 12 * 100) + "%<BR><B>Payment:</b> $" + formatNum(form.HmoPmt.value) + "</B></TD></TR><TR><TD COLSPAN=5><CENTER><b>Schedule of Payments</b><BR>Please allow for slight rounding differences.</CENTER></TD></TR><TR><TD align=center><B>Pmt #</B></TD><TD align=center><B>Date</B></TD><TD align=center><B>Principal</B></TD><TD align=center><B>Interest</B></TD><TD align=center><B>Balance</B></TD></TR>");

var part3 = ("" + aPmtRow + "");

var part4 = ("<TR><TD align=center><B>Totals</B></TD><TD></TD><TD align=center><B>" + formatNum(aAccumPrin) + "</B></TD><TD align=center><B>" + formatNum(aAccumInt) + "</B></TD><TD></TD></TR></TABLE><!-- Start of StatCounter Code -->
<script type="text/javascript">
var sc_project=4531860; 
var sc_invisible=1; 
var sc_partition=34; 
var sc_click_stat=1; 
var sc_security="d5915a76"; 
</script>

<script type="text/javascript"
src="http://www.statcounter.com/counter/counter.js"></script><noscript><div
class="statcounter"><a title="counter on myspace"
href="http://www.statcounter.com/myspace/"
target="_blank"><img class="statcounter"
src="http://c.statcounter.com/4531860/0/d5915a76/1/"
alt="counter on myspace" ></a></div></noscript>
<!-- End of StatCounter Code --></body></HTML>");

var schedule = (part1 + "" + part2 + "" + part3 + part4 + "");

  reportWin = window.open("","","width=500,height=300,toolbar=yes,menubar=yes,scrollbars=yes");
  reportWin.document.write(schedule);
  reportWin.document.close();

   }
}




function clearForm(form) {
   form.principal.value = "";
   form.intRate.value = "";
   form.numYears.value = "";
   form.moPmt.value = "";
   form.HmoPmt.value = "";
   }