function pmt(p,i,y)
{
  with (Math)
  {
    // parseInt()
    var r = i/1200;
    var x = pow(1+r, -12*y);
    var pmt = p*r/(1-x);
    pmt = round(100*pmt)/100;
    return pmt;
  }
}
//alert(pmt(177000,4.25,10));
function cents(n)
{
  var s = "" + Math.round(100*n);
  while (s.length < 3)  s = "0"+s;
  return s.substring(0, s.length-2) + "." + s.substring(s.length-2);
}

function c()
{
  var p = document.fp.p.value;
  var i = document.fp.i.value;
  var y = document.fp.y.value;
  if (p && i && y)
  {
    var z = pmt(p,i,y);
    if (isNaN(z) || z <= 0)
      document.fp.z.value = "Out of range";
    else
      document.fp.z.value = "$"+cents(z);
  }
}

function filterNum(str) {
re = /^\$|%|,/g;
// remove "$", "%" and ","
return str.replace(re, "");
}

