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);
     }

  var Vcents = parseInt(((Vnum % 1) * 100),10);

 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.downPay.value == "" || form.downPay.value == 0) {
   alert("Please enter an amount in Line #1.");
   form.downPay.focus();
   } else
      if(form.intRate.value == "" || form.intRate.value == 0) {
      alert("Please enter an amount in Line #3.");
      form.intRate.focus();
   } else
      if(form.numYears.value == "" || form.numYears.value == 0) {
      alert("Please enter an amount in Line #4.");
      form.numYears.focus();
   } else {

var VdownPay = form.downPay.value;

var VsaveBal = 0;
   if(form.saveBal.value == "") {
      VsaveBal = 0;
      } else {
      VsaveBal = form.saveBal.value;
      }

var VnumYears = form.numYears.value;

var intRate = form.intRate.value;

if (intRate > 1.0) {

        intRate = intRate / 100.0;
        } else {
        intRate = intRate;
    }

    

//FIGURE FUTURE VALUE OF PRESENT SAVINGS

    var factor1 = eval(intRate) + eval(1);

    var denom1 = 1;

    var count1 = 0;

     while(count1 < VnumYears) {
        denom1 = denom1 * factor1;
        count1 = eval(count1) + eval(1);
      }

    var VsaveFV = VsaveBal * denom1;

    form.saveFV.value = "$" + formatNum(VsaveFV);

    var VsaveGap = eval(VdownPay) - eval(VsaveFV);

    form.saveGap.value = "$" + formatNum(VsaveGap);

//FIGURE PRESENT VALUE OF ADJUSTED SAVINGS GAP
   
   var count2 = 0;

   var intRate2 = intRate / 12;

   var numMonths = VnumYears * 12;

   var factor2 = eval(1) + eval(intRate2);

   var denom2 = 1;
    
    while(count2 < numMonths) {
       denom2 = denom2 * factor2;
        count2 = eval(count2) + eval(1);
        }

    var Vpv = eval(denom2) - eval(1);

    Vpv = intRate2 / Vpv;

    Vpv = Vpv * VsaveGap;

    form.moSave.value = "$" + formatNum(Vpv);


//END VARIFICATION IF STATEMENT
   }
    
}

function help0(form) {
form.saveBal.focus();
//form.help.value = "";
//form.help.value = ("Instructions: To see a more detailed instruction/explanation of //any text-entry field, simply click in the desired text field and the //instructions/explanations will appear in this text area.");
}

function help1(form) {
form.help.value = "";
form.help.value = ("Line #1: ENTER: Your the amount of your future savings goal.");
}

function help2(form) {
form.help.value = "";
form.help.value = ("Line #2: ENTER: The amount of money you currently have set aside (in an interest earning account) for applying to toward your future savings goal.");
}

function help3(form) {
form.help.value = "";
form.help.value = ("Line #3: ENTER: The annual percentage rate (APR) at which you expect your savings to grow.");
}

function help4(form) {
form.help.value = "";
form.help.value = ("Line #4: ENTER: The number of years between now and when you want to accomplish your savings goal. Then click on the \"Compute\" button.");
}

function help5(form) {
form.help.value = "";
form.help.value = ("Line #5: RESULT: The amount your current savings will grow to at the end of the specified number of years.");
}

function help6(form) {
form.help.value = "";
form.help.value = ("Line #6: RESULT: The total additional amount you will need to meet your savings goal.");
}

function help7(form) {
form.help.value = "";
form.help.value = ("Line #7: RESULT: How much money you'll have to save every month to reach your future savings goal.");
}


function clearForm(form)

{

    form.downPay.value = "";

    form.saveBal.value = "";

    form.intRate.value = "";

    form.numYears.value = "";

    form.saveFV.value = "";

    form.saveGap.value = "";

    form.moSave.value = "";

    form.downPay.focus();

}

