
 (function(){
 if(document.paymentcalculator.creditcardbalance) {
  document.paymentcalculator.creditcardbalance.focus();
 }
});

 function number_format( number, decimals, decpoint, thousandsep ) {

  var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;

  var d = decpoint == undefined ? "," : decpoint;

  var t = thousandsep == undefined ? "." : thousandsep, s = n < 0 ? "-" : "";

  var i = parseInt(n = Math.abs(+n || 0).tofix(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;

   

  return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).tofix(c).slice(2) : "");

  }



 function creditcardpayment()

{

  var i=0

  var pow=1

  var answer=0

 if(document.paymentcalculator.interest.value==""||document.paymentcalculator.months.value==""||document.paymentcalculator.creditcardbalance.value=="")

  {

    alert("Please fill in the required fields.") 

  }

 else

  { 

  // 

    i = document.paymentcalculator.interest.value;

    if (i > 1.0) {

     i = i / 100.0;

    }

    i/=12

    for (var j = 0; j < document.paymentcalculator.months.value; j++)

    pow = pow * (1 + i);

    answer = "" + .01* Math.round(100*(document.paymentcalculator.creditcardbalance.value * pow * i) / (pow - 1));

    document.paymentcalculator.amount.value=answer

  }

}
