function pmt(C,A,D,E){var B;if(C==0){B=-(E+D)/A}else{ir=Math.pow(1+C,A);B=-((C*(E+ir*D))/(ir-1))}return B}function cleanNumber(A){if(!A){return A}A=A.replace(/\D/g,"");return A}function format(E,C,B){var G=new String(E);var A=G.length;var H;var F="";var D=3-(A%3);if(D==3){D=0}for(H=0;A>H;H++){if(D==3){F+=B;D=0}D++;F+=G.substring(H,H+1)}if(C=="%"){return F+C}else{return C+F}}function numFormat(C,B,A){if(C.value==""){C.value=format("0",B,A);return true}var D=parseInt(cleanNumber(C.value),10);if(B=="$"){if(0>D){alert("You have exceeded the range for the price.\nPlease check your information and try again.");D=0}if(D>100000000){alert("You have exceeded the range for the price.\nPlease check your information and try again.");D=100000000}}if(isNaN(D)){alert("You have entered an incorrect character on this field. \nPlease check your information and try again.");C.value=format("0",B,A);C.focus();return false}C.value=format(D,B,A);return true}function dpCalc(D,C){var B=C;var A=0;A=B*(D/100);return A}function calcRate(E,P,H){if(E==null){return }var K=cleanNumber(E.ap.value);var A=false;var G=E.dp.selectedIndex;var N=E.dp.options[G].value;var D;var M=E.dpt.length;for(i=0;i<M;i++){if(E.dpt[i].checked){var J=E.dpt[i].value}}if(J=="d"){D=cleanNumber(E.dpd.value)}else{D=dpCalc(N,K)}var C=E.ir.selectedIndex;var I=E.ir.options[C].value;var B=360;var R=E.numPayments1.value;var Q=E.numPayments2.value;var T=null;if(E.elin1!=null){T=E.elin1.value}var S=null;if(E.elin2!=null){S=E.elin2.value}numFormat(E.ap,"$",",");if((K==0)&&(P!=0)){alert("Please enter an asking price that is greater than zero.");E.ep.value="";if(E.elout1!=null){E.elout1.value=""}if(E.elout2!=null){E.elout2.value=""}}else{var F=parseInt(-pmt(I/1200,B,K-D,0));var O=null;if(T!=null){O=parseInt(-pmt(T/1200,R,K-D,0))}var L=null;if(S!=null){L=parseInt(-pmt(S/1200,Q,K-D,0))}if(F<0){E.ep.value="";if(elout1!=null){E.elout1.value=""}if(elout2!=null){E.elout2.value=""}}else{E.ep.value=F;numFormat(E.ep,"$",",");if(O!=null){E.elout1.value=O;numFormat(E.elout1,"$",",")}if(L!=null){E.elout2.value=L;numFormat(E.elout2,"$",",")}}}}function calcRateAndUpdate(F,H,J,B,G){calcRate(F,H);var I=cleanNumber(F.ap.value);var N=F.dp.selectedIndex;var C=F.dp.options[N].value;var L=F.ir.selectedIndex;var A=F.ir.options[L].value;var E=F.dpt.length;for(i=0;i<E;i++){if(F.dpt[i].checked){var M=F.dpt[i].value}}var D=cleanNumber(F.dpd.value);var O=C;var K;if(M=="d"){K=2}else{K=1}setCalcValuePrefs(J,K,O,D,A,B)}function setCalcValuePrefs(H,E,D,G,F,B){var C="type="+E+"&dpRate="+D+"&amt="+G+"&intRate="+F+"&id="+H;B=B+"?"+C;var A=YAHOO.util.Connect.asyncRequest("GET",B)};