var formValidationConfig={formname:"refinance",success:function(A){frm=document.forms[A.formname];dCurrentPayment=parseFloat(frm.elements.current_monthly_payment.value.stripCurrency());amort=AmortScheduleCalculator();newvar=amort.calculate(parseFloat(frm.elements.new_loan_amount.value.stripCurrency()),parseFloat(frm.elements.property_value.value.stripCurrency()),parseFloat(frm.elements.new_interest_rate.value.stripCurrency())/100,0,0,1,parseFloat(frm.elements.expected_years_before_selling.value)*12,0,0,0,0,0.28,parseFloat(frm.elements.estimated_monthly_mi.value.stripCurrency()),false,parseFloat(frm.elements.new_loan_term.value)*12,parseFloat(frm.elements.new_loan_term.value)*12,0,0,0,0,0,0);
dNewPayment=newvar.getMonthlyPayment(0);dClosingCosts=EstimatedClosingCostsCalculate(parseFloat(frm.elements.new_loan_amount.value.stripCurrency()),parseFloat(frm.elements.new_loan_term.value),parseFloat(frm.elements.new_interest_rate.value.stripCurrency())/100,0,parseFloat(frm.elements.down_payment.value.stripCurrency()));dMonthlyCashDifference=(Math.round(dCurrentPayment*100)/100)-(Math.round(dNewPayment*100)/100);document.getElementById("div_current_monthly_payment").innerHTML=getIndicator("#4D4DFF","spaceimage",(Math.round(dCurrentPayment*100)/100).toCurrency());
document.getElementById("div_new_monthly_payment").innerHTML=getIndicator("#238E23","spaceimage",(Math.round(dNewPayment*100)/100).toCurrency());document.getElementById("div_monthly_cash_difference").innerHTML=getIndicator("#FFBF25","spaceimage",(Math.round(dMonthlyCashDifference*100)/100).toCurrency());document.getElementById("div_refinance_cost").innerHTML=getIndicator("#25FFFC","spaceimage",(Math.round(dClosingCosts*100)/100).toCurrency());document.getElementById("div_months_to_break_even").innerHTML=(dMonthlyCashDifference<0)?"NO BREAK EVEN":(Math.round((dClosingCosts/dMonthlyCashDifference)*100)/100);
this.graphIt(A)},graphIt:function(F){ProxyXyChart_Reset(1);var I={};I.type="line";I.color=5066239;I.width=2;var B={};B.type="line";B.color=2330147;B.width=2;var A={};A.type="line";A.color=16760613;A.width=2;var C={};C.type="line";C.color=2490364;C.width=2;frm=document.forms[F.formname];dCurrentPayment=parseFloat(frm.elements.current_monthly_payment.value.stripCurrency());amort=AmortScheduleCalculator();newvar=amort.calculate(parseFloat(frm.elements.new_loan_amount.value.stripCurrency()),parseFloat(frm.elements.property_value.value.stripCurrency()),parseFloat(frm.elements.new_interest_rate.value.stripCurrency())/100,0,0,1,parseFloat(frm.elements.expected_years_before_selling.value)*12,0,0,0,0,0.28,parseFloat(frm.elements.estimated_monthly_mi.value.stripCurrency()),false,parseFloat(frm.elements.new_loan_term.value)*12,parseFloat(frm.elements.new_loan_term.value)*12,0,0,0,0,0,0);
dNewPayment=newvar.getMonthlyPayment(0);dDifference=dCurrentPayment-dNewPayment;dClosingCosts=EstimatedClosingCostsCalculate(parseFloat(frm.elements.new_loan_amount.value.stripCurrency()),parseFloat(frm.elements.new_loan_term.value),parseFloat(frm.elements.new_interest_rate.value.stripCurrency())/100,0,parseFloat(frm.elements.down_payment.value.stripCurrency()));for(var E=1;E<=parseInt(frm.elements.expected_years_before_selling.value);E++){var G=0;var J=0;var H=0;var D=0;G=dCurrentPayment*E;J=dNewPayment*E;H=dDifference*E;
D=dClosingCosts;I[E]=Math.round(G);B[E]=Math.round(J);A[E]=Math.round(H);C[E]=Math.round(D)}ProxyXyChart_Data(1,I);ProxyXyChart_Data(1,B);ProxyXyChart_Data(1,A);ProxyXyChart_Data(1,C);ProxyXyChart_Option(1,{axislegend:"left",auto:true,scalepadpct:2});ProxyXyChart_Option(1,{axislegend:"bottom",auto:true,scalepadpct:5,autozero:false,displaymodulus:2});ProxyXyChart_Option(1,{hrules:true,width:1,color:12500670,alpha:0.7});ProxyXyChart_Option(1,{background:true,position:"nottop",color1:15592941,color2:4934475,alpha1:0.2,alpha2:0.2});
ProxyXyChart_Draw(1);this.similarProperties(F)},similarProperties:function(A){var C=document.forms[A.formname];var B=new QueryString("/includes/calculators/similarproperties.jsp");B.add("svf","lsp");B.add("maxprice",C.elements.property_value.value.stripCurrency());B.add("where",C.elements.strWhere.value);B.nocache=true;g_CyberAjaxQueue.schedule("GetFirstResults",B,function(){var E=obj("similarproperties");var G=E.getElementsByTagName("div");var F="";if(this.xmlObject.responseText.replace("\t","","g").replace("\r\n","","g")==""){F="none"
}for(var D=0;D<G.length;D++){G[D].style.display=F}obj("SearchPreview").innerHTML=this.xmlObject.responseText},function(){alert("error")},false,false)},reset:function(){ProxyXyChart_Reset(1);frm=document.forms[this.formname];for(fld in this.fields){var A=frm.elements[fld];if(A&&A.type=="text"){A.value=""}}},fields:{current_interest_rate:{label:"Current Interest Rate",required:true,type:"number",range:{start:0,end:28},"default":6},current_loan_balance:{label:"Current Loan Balance",required:true,type:"currency",range:{start:20000,end:1000000000},"default":20000},current_monthly_payment:{label:"Current Payment",required:true,type:"currency",range:{start:0,end:1000000000},"default":0},property_value:{label:"Property Value",required:true,type:"currency",range:{start:0,end:1000000000},"default":0},expected_years_before_selling:{label:"Years Before Selling",required:true,type:"currency",range:{start:0,end:1000000000},"default":0},new_loan_term:{label:"New Loan Term",required:true,type:"number",range:{start:0,end:30},"default":30},new_interest_rate:{label:"New Interest Rate",required:true,type:"currency",range:{start:0,end:28},"default":6},new_loan_amount:{label:"New Loan Amount",required:true,type:"currency",range:{start:0,end:1000000000},"default":0},down_payment:{label:"Down Payment",required:true,type:"currency",range:{start:0,end:1000000000},"default":0},estimated_monthly_mi:{label:"Mortgage Insurance",required:true,type:"currency",range:{start:0,end:1000000000},"default":0}}};