ZillowSimpleLoanCalc={};ZillowSimpleLoanCalc.CURRENT_RATES_LINK_ID_MAP={"2":"thirtyYearFixedLink","8":"fifteenYearFixedLink","128":"fiveOneARMLink"};
ZillowSimpleLoanCalc.calculateMonthlyPayment=function(i,d,c,a){var h=i/1200;var f=d;var g=Math.pow(h+1,f);
var b=g-1;var e=a||0;return Math.round(c*h*g/b)+a;};ZillowSimpleLoanCalc.getLoanTermFromMask=function(a){switch(a){case"2":years=30;
break;case"8":years=15;break;case"128":years=30;break;}return years*12;};ZillowSimpleLoanCalc.getRateFromMask=function(c){var d=6;
var b;switch(c){case"2":b="thirtyYearFixedRate";break;case"8":b="fifteenYearFixedRate";break;case"128":b="fiveYearAdjustableRate";
break;default:return d;}var a=parseFloat(document.getElementById(b).value);if(a<=0){a=d;}return a.toFixed(2);
};ZillowSimpleLoanCalc.updateMonthlyPayment=function(){myLoanAmount=document.getElementById("loanAmount").value.replace(/\D/g,"")||0;
loanTypeMask=document.getElementById("loanTypeSelect").value;interestRate=document.getElementById("rate").value;
var a=(ZillowSimpleLoanCalc.calculateMonthlyPayment(interestRate,ZillowSimpleLoanCalc.getLoanTermFromMask(loanTypeMask),myLoanAmount,0));
document.getElementById("popupMonthlyPaymentAmount").innerHTML=a;};ZillowSimpleLoanCalc.updateInterestRate=function(a){var b=a.value;
document.getElementById("rate").value=ZillowSimpleLoanCalc.getRateFromMask(b);ZillowSimpleLoanCalc.updateCurrentRatesLink(b);
};ZillowSimpleLoanCalc.updateCurrentRatesLink=function(h){var a=ZillowSimpleLoanCalc.CURRENT_RATES_LINK_ID_MAP[h];
if(a){var g=document.getElementById(a);if(g){var d=document.getElementById("loanTypeSelect").options,b=0;
if(d){var f,c,e;for(b=0;b<d.length;b++){f=d[b].value;c=ZillowSimpleLoanCalc.CURRENT_RATES_LINK_ID_MAP[f];
e=document.getElementById(c);if(e){e.style.display="none";}}}g.style.display="";}}};
