<!-- 
function FormatNumber(Number,Decimals,Separator)
{
 // **********************************************************
 // Placed in the public domain by Affordable Production Tools
 // March 21, 1998
 // Web site: http://www.aptools.com/
 //
 // November 24, 1998 -- Error which allowed a null value
 // to remain null fixed. Now forces value to 0.
 //
 // This function accepts a number to format and number
 // specifying the number of decimal places to format to. May
 // optionally use a separator other than '.' if specified.
 //
 // If no decimals are specified, the function defaults to
 // two decimal places. If no number is passed, the function
 // defaults to 0. Decimal separator defaults to '.' .
 //
 // If the number passed is too large to format as a decimal
 // number (e.g.: 1.23e+25), or if the conversion process
 // results in such a number, the original number is returned
 // unchanged.
 // **********************************************************
 Number += ""          // Force argument to string.
 Decimals += ""        // Force argument to string.
 Separator += ""       // Force argument to string.
 if((Separator == "") || (Separator.length > 1))
  Separator = "."
 if(Number.length == 0)
  Number = "0"
 var OriginalNumber = Number  // Save for number too large.
 var Sign = 1
 var Pad = ""
 var Count = 0
 // If no number passed, force number to 0.
 if(parseFloat(Number)){
  Number = parseFloat(Number)} else {
  Number = 0}
 // If no decimals passed, default decimals to 2.
 if((parseInt(Decimals,10)) || (parseInt(Decimals,10) == 0)){
  Decimals = parseInt(Decimals,10)} else {
  Decimals = 2}
 if(Number < 0)
 {
  Sign = -1         // Remember sign of Number.
  Number *= Sign    // Force absolute value of Number.
 }
 if(Decimals < 0)
  Decimals *= -1    // Force absolute value of Decimals.
 // Next, convert number to rounded integer and force to string value.
 // (Number contains 1 extra digit used to force rounding)
 Number = "" + Math.floor(Number * Math.pow(10,Decimals + 1) + 5)
 if((Number.substring(1,2) == '.')||((Number + '')=='NaN'))
  return(OriginalNumber) // Number too large to format as specified.
 // If length of Number is less than number of decimals requested +1,
 // pad with zeros to requested length.
 if(Number.length < Decimals +1) // Construct pad string.
 {
  for(Count = Number.length; Count <= Decimals; Count++)
   Pad += "0"
 }
 Number = Pad + Number // Pad number as needed.
 if(Decimals == 0){
  // Drop extra digit -- Number is formatted.
  Number = Number.substring(0, Number.length -1)} else {
  // Or, format number with decimal point and drop extra decimal digit.
 Number = Number.substring(0,Number.length - Decimals -1) +
          Separator +
          Number.substring(Number.length - Decimals -1,
          Number.length -1)}
 if(Sign == -1)
  Number = "-" + Number  // Set sign of number.
 if(Number.length == 0)
  Number="0"
 return(Number)
}
// -->


<!-- 

//PLATFORMS: Netscape Navigator 3.0 and higher,
//           Microsoft Internet Explorer 3.02 and higher
/*======================================================================
   computeForm(form)
   
   Description: 
        Compute all fields within the form
   
====================================================================== */
function computeForm() {
    var pmt1 = document.loanform.payment.value;
    var prin1 = document.loanform.principal.value;
    var intPort1 = 0;
    var prinPort1 = 0;
    var accumInt1 = 0;
    var accumPrin1 = 0;
    var i1 = document.loanform.intRate.value;

    if (i1 > 1.0) {
        i1 = i1 / 100.0;
        document.loanform.intRate.value = i1;
    }

    var i1  = i1  / 12;
    var i2 = document.loanform.intRate2.value;

       if (i2 > 1.0) {
           i2 = i2 / 100.0;
           document.loanform.intRate2.value = i2;
       }

    var i2  = i2  / 12;
    var count1 = 0;
    while(prin1 > 0) {
        intPort1 = prin1 * i1;
        prinPort1 = pmt1 - intPort1;
        prin1 = prin1 - prinPort1;
        accumPrin1 = accumPrin1 + prinPort1;
        accumInt1 = accumInt1 + intPort1;
        count1 = count1 + 1;
        if(count1 > 600) {break; } else {continue; }
       }

    document.loanform.origInt.value = "$" + parseInt(accumInt1,10);
    var pow = 1;
    for (var j = 0; j < document.loanform.nper2.value *12; j++)
        pow = pow * (1 + i2);
    var fpayment2 = (document.loanform.principal.value * pow * i2) / (pow - 1);
    document.loanform.payment2.value = "$" + parseInt(fpayment2,10) + "." + parseInt(fpayment2 % 1 * 100,10);
    var fmoSave = document.loanform.payment.value - fpayment2;
	 var UnFormatedMoSave = parseInt(fmoSave,10) + "." + parseInt(fmoSave % 1 *100,10);
	 var FormatedMoSave = FormatNumber(UnFormatedMoSave,2,'.');
    document.loanform.moSave.value = "$" + FormatedMoSave;
// modulus is the remainder of the division of two numbers
	var ftotInt2 = (fpayment2 * document.loanform.nper2.value *12) - document.loanform.principal.value;
    document.loanform.totInt2.value = "$" + parseInt(ftotInt2,10);
    var fintSave = accumInt1 - ftotInt2;
    document.loanform.intSave.value = "$" + parseInt(fintSave,10);
    var fnetSave = fintSave - document.loanform.closingCost.value;
    document.loanform.netSave.value = "$" + parseInt(fnetSave,10);
}
// -->