
function calculatePayments(strForm)
{
  trimAll(strForm);
 
  var objPrice     = document.forms[strForm].elements['price'];
  var objRate      = document.forms[strForm].elements['rate'];
  var objDown      = document.forms[strForm].elements['down'];
  var objTerm      = document.forms[strForm].elements['term'];
 
  var objPrincipal = document.forms[strForm].elements['principal'];
  var objPayments  = document.forms[strForm].elements['payments'];
  var objMonthly   = document.forms[strForm].elements['monthly'];
 
  // correct data
 
  objPrice.value = stripNonNumeric(objPrice.value);
  objRate.value  = stripNonNumeric(objRate.value);
  objDown.value  = stripNonNumeric(objDown.value);
  objTerm.value  = stripNonNumeric(objTerm.value);

  // report errors
 
  if (isBlank(objPrice.value) || (objPrice.value == 0)) {
    alert("Please enter the price of your new home.");
    objPrice.focus();
    return false;
  }
 
  if (isBlank(objRate.value) || (objRate.value == 0)) {
    alert("Please enter the interest rate.");
    objRate.focus();
    return false;
  }
 
  if (isBlank(objTerm.value) || (objTerm.value == 0)) {
    alert("Please enter the number of years.");
    objTerm.focus();
    return false;
  }
 
  // calculate payments
 
  price     = stripNonNumeric(objPrice.value);
  rate      = stripNonNumeric(objRate.value);
  down      = stripNonNumeric(objDown.value);
  term      = stripNonNumeric(objTerm.value);
 
  rate      = rate / 100 / 12;
  principal = price - down;
  payments  = term * 12;
  monthly   = Math.floor((principal * rate) / (1 - Math.pow(1 + rate, (-1 * payments))) * 100) / 100
 
  objPrincipal.value = principal;
  objPayments.value  = payments;
  objMonthly.value   = monthly;
 
  return false;
}
