function computeForm(b){var r=b.payment.value;var p=b.principal.value;var o=0;var c=0;var n=0;var k=0;var h=b.intRate.value;if(h>1){h=h/100;b.intRate.value=h}var h=h/12;var g=b.intRate2.value;if(g>1){g=g/100;b.intRate2.value=g}var g=g/12;var m=0;while(p>0){o=p*h;c=r-o;p=p-c;k=k+c;n=n+o;m=m+1;if(m>600){break}else{continue}}b.origInt.value="$"+parseInt(n,10);var l=1;for(var i=0;i<b.nper2.value*12;i++){l=l*(1+g)}var f=(b.principal.value*l*g)/(l-1);b.payment2.value="$"+parseInt(f,10)+"."+parseInt(f%1*100,10);var a=b.payment.value-f;b.moSave.value="$"+parseInt(a,10)+"."+parseInt(a%1*100,10);var q=(f*b.nper2.value*12)-b.principal.value;b.totInt2.value="$"+parseInt(q,10);var e=n-q;b.intSave.value="$"+parseInt(e,10);b.closeMo.value=parseInt(b.closingCost.value/a,10);var d=e-b.closingCost.value;b.netSave.value="$"+parseInt(d,10);b.summary.value="If you refinance your current "+parseInt(b.intRate.value*100,10)+"."+parseInt(b.intRate.value*100%1*100,10)+"% mortgage to a "+parseInt(b.intRate2.value*100,10)+"."+parseInt(b.intRate2.value*100%1*100,10)+"% mortgage, your monthly payment will drop by "+b.moSave.value+" and you will save "+b.intSave.value+" in interest charges over the life of the mortgage.  However, in order for this refinancing to yield any savings at all you will need to stay in your current home for at least "+b.closeMo.value+" months.  That's how long it will take for your monthly payment savings to offset the closing costs attributable to refinancing."}function clearForm(a){a.principal.value="";a.payment.value="";a.intRate.value="";a.intRate2.value="";a.nper2.value="";a.closingCost.value="";a.payment2.value="";a.moSave.value="";a.closeMo.value="";a.intSave.value="";a.origInt.value="";a.netSave.value="";a.totInt2.value="";a.summary.value=""};
