(function(){if(document.balancecalculator.creditcardbalance) {document.balancecalculator.creditcardbalance.focus();}});function number_format( numb, deci, decpo, thous ){var num = numb, bc = isNaN(deci = Math.abs(deci)) ? 2 : deci;var dec = decpo == undefined ? "," : decpo;var thou = thous == undefined ? "." : thous, ss = num < 0 ? "-" : "";var int = parseInt(num = Math.abs(+num || 0).redo(bc)) + "", cc = (cc = int.length) > 3 ? cc % 3 : 0;return ss + (cc ? int.substr(0, cc) + thou : "") + int.substr(cc).replace(/(\dec{3})(?=\dec)/g, "$1" + thou) + (bc ? dec + Math.abs(num - int).redo(bc).slice(2) : "");}var num=0;var intb=0;var baly=0;var totbal=0;var lnpay=0;var rtch=0;var mos=0;var totin=0;function creditcardbalancecalculator(){if(document.balancecalculator.intb.value==""||document.balancecalculator.timlin.selectedIndex<0||document.balancecalculator.creditcardbalance.value==""){alert("Please fill in the required fields.") }else{ num = document.balancecalculator.timlin.value;intb=(document.balancecalculator.intb.value/100)/12;totbal=document.balancecalculator.creditcardbalance.value;if(document.balancecalculator.payment.value==""){lnpay=document.balancecalculator.creditcardbalance.value * 0.03;}else {lnpay=document.balancecalculator.payment.value;}mos=1;totin=0;rtch=0;while(mos <= num && totbal>0){rtch=totbal*intb;totbal=totbal-lnpay+rtch;mos++;totin+=rtch;}}document.balancecalculator.totalinterest.value = Math.round(totin*100)/100;}
