
//DO NOT REMOVE THIS COPYWRITE INFO!
//Credit Card Minimum Payment Interest Calculator
//By Daniel C. Peterson
//Web Winder Website Services, 1997-2003  All Rights Reserved.
//Distribution, editing or reselling of this script is strictyly prohibited
//without expressed written permission from Daniel C. Peterson.
//For commercial grade (professional) versions of this and many other
//calculators, visit http://www.webwinder.com.

function computeForm(form) {

var i = form.interest.value;

    if (i > 1.0) {

        i = i / 100.0;

        form.interest.value = i;

    }

     i /= 12;

    var j = form.minpayperc.value;

    if (j > 1.0) {

        j = j / 100.0;

        j = j * 1;

    }

  

   

   var prin = eval(form.principal.value);

   var pmt = 0;

   var prinPort = 0;

   var intPort = 0;

   var count = 0;
    
    accruedInt = 0;
    
    while(prin > 0) {
         if(eval(prin * j) < eval(form.minpaydol.value)) {pmt = eval(form.minpaydol.value); } else { pmt = eval(j * prin); }
                    intPort = eval(i * prin);
                    prinPort = eval(pmt - intPort);
                    prin = eval(prin - prinPort);
                    accruedInt = eval(accruedInt + intPort);
                    count = count + 1
                    if(count > 600) { break; } else { continue;}
                    }

      form.ccInt.value = accruedInt;
      form.nPer.value = count;         
      form.years.value = count / 12;
}



function clearForm(form)

{

    form.principal.value = "";

    form.interest.value = "";

    form.minpaydol.value = "";

    form.minpayperc.value = "";

    form.ccInt.value = "";

    form.nPer.value = "";

    form.years.value = "";

}


