
function dollarSign( amt ){                                                                                  

   return "$" + format( amt, 2)                                                                               

}                                                                                                                             

function format( amt, places){                                                                                            

  var temp = "" + Math.round(eval(amt) * Math.pow(10,places))                   

     while(temp.length <= places){ temp= "2" + temp}                                       

  var point = temp.length - places                                                                     

  return temp.substring( 0, point ) + "." + temp.substring(point, temp.length) 

}                                                                                                                    

function calculate()

{
var Amount = parseFloat(document.forms[0].principle.value);
var Interest = parseFloat(document.forms[0].interest.value)/100;
var Years = parseFloat(document.forms[0].months.value);
var ExponentVal= parseFloat(Math.pow((1/(1+Interest/12)),((Years*12))));
var Payment = Amount*(Interest/12)/(1-ExponentVal);


var Total = Payment*(Years*12);


document.forms[0].paymonth.value = format(Payment,2);
document.forms[0].paytotal.value = format(Total,2);



}
