function floor(number)
{
  return Math.floor(number*Math.pow(10,2))/Math.pow(10,2);
}

function calcRet(form)
{
  form.Yearly.value = form.Salary.value * form.Contribution.value / 100.0;
  var m = parseFloat(form.Yearly.value, 10) / 12.0;
  m = m + (form.Salary.value * form.Matching.value / 100.0 / 12.0);
  form.MatchContrib.value = (form.Salary.value * form.Matching.value / 100.0);
  var tot = parseFloat(form.CurrentValue.value, 10);
  var i = 0;
  var r = parseFloat(form.PreRate.value, 10) / 100.0 / 12.0;
  var t = (parseFloat(form.RetirementAge.value, 10) -       parseFloat(form.CurrentAge.value, 10)) * 12;
  var ir = parseFloat(form.InflationRate.value, 10) / 100.0 / 12.0;

  for (i=1; i<=t; i=i+1)
  {
    tot = tot*Math.exp(r) + m;
    if (i % 12 == 0)
    {
       m = m + (m * form.SalaryRate.value / 100.0);
    }
  }
  form.AccountValue.value = floor(tot);

  var RetirementNeeds = parseFloat(form.DesiredIncome.value, 10);

  for (i=1; i<=t; i=i+1)
  {
    RetirementNeeds = RetirementNeeds*Math.exp(ir);
  }

  var r = parseInt(form.PostRate.value, 10) / 100.0 / 12.0;

  for (i=1; i<=12; i=i+1)
  {
    tot = tot*Math.exp(r);
    RetirementNeeds = RetirementNeeds*Math.exp(ir);
    tot = tot - RetirementNeeds / 12.0;
  }
  form.OneYear.value = floor(tot);
  for (i=1; i<=12; i=i+1)
  {
    tot = tot*Math.exp(r);
    RetirementNeeds = RetirementNeeds*Math.exp(ir);
    tot = tot - RetirementNeeds / 12.0;
  }
  form.TwoYear.value = floor(tot);
  for (i=1; i<=12; i=i+1)
  {
    tot = tot*Math.exp(r);
    RetirementNeeds = RetirementNeeds*Math.exp(ir);
    tot = tot - RetirementNeeds / 12.0;
  }
  form.ThreeYear.value = floor(tot);
  for (i=1; i<=12; i=i+1)
  {
    tot = tot*Math.exp(r);
    RetirementNeeds = RetirementNeeds*Math.exp(ir);
    tot = tot - RetirementNeeds / 12.0;
  }
  form.FourYear.value = floor(tot);
  for (i=1; i<=12; i=i+1)
  {
    tot = tot*Math.exp(r);
    RetirementNeeds = RetirementNeeds*Math.exp(ir);
    tot = tot - RetirementNeeds / 12.0;
  }
  form.FiveYear.value = floor(tot);
  for (i=1; i<=12*5; i=i+1)
  {
    tot = tot*Math.exp(r);
    RetirementNeeds = RetirementNeeds*Math.exp(ir);
    tot = tot - RetirementNeeds / 12.0;
  }
  form.TenYear.value = floor(tot);
  for (i=1; i<=12*5; i=i+1)
  {
    tot = tot*Math.exp(r);
    RetirementNeeds = RetirementNeeds*Math.exp(ir);
    tot = tot - RetirementNeeds / 12.0;
  }
  form.FifteenYear.value = floor(tot);
  for (i=1; i<=12*5; i=i+1)
  {
    tot = tot*Math.exp(r);
    RetirementNeeds = RetirementNeeds*Math.exp(ir);
    tot = tot - RetirementNeeds / 12.0;
  }
  form.TwentyYear.value = floor(tot);
  for (i=1; i<=12*10; i=i+1)
  {
    tot = tot*Math.exp(r);
    RetirementNeeds = RetirementNeeds*Math.exp(ir);
    tot = tot - RetirementNeeds / 12.0;
  }
  form.ThirtyYear.value = floor(tot);
  for (i=1; i<=12*10; i=i+1)
  {
    tot = tot*Math.exp(r);
    RetirementNeeds = RetirementNeeds*Math.exp(ir);
    tot = tot - RetirementNeeds / 12.0;
  }
  form.FourtyYear.value = floor(tot);
}
