/*****************************************
(C) http://www.calculator.net all right reserved.  
*****************************************/
var cloanamount;var cloanterm;var cresidualvalue;var cmonthlypay;function popMenu(A){Jq="";if(A=="fixpayment"){Jq=Jq+'<li><a href="#" onclick="popMenu(\'fixrate\');">Fix Rate</a></li> <li id=\'menuon\'><a href="#" onclick="popMenu(\'fixpayment\');">Fix Payment</a></li>';gObj("ctype").value="fixpayment";gObj("standardheightweight").style.display="none";gObj("metricheightweight").style.display="block"}else{Jq=Jq+'<li id=\'menuon\'><a href="#" onclick="popMenu(\'fixrate\');">Fix Rate</a></li> <li><a href="#" onclick="popMenu(\'fixpayment\');">Fix Payment</a></li>';gObj("ctype").value="fixrate";gObj("standardheightweight").style.display="block";gObj("metricheightweight").style.display="none"}Jq="<ul>"+Jq+"</ul>";gObj("topmenu").innerHTML=Jq;calc()}function calcInterest(A,B){EO=Math.pow((1+A),cloanterm);UI=0;if(A==0){UI=(cloanamount-cresidualvalue)/cloanterm}else{UI=(cloanamount*A*EO-cresidualvalue*A)/(EO-1)}MA=(UI-cmonthlypay)/cmonthlypay;if((MA<0.00001)&&(MA>-0.00001)){return A}else{if(UI>cmonthlypay){return calcInterest((A-0.7*B),(0.7*B))}else{return calcInterest((A+0.7*B),(0.7*B))}}}function calc(){showquickmsg("calculating...",true);setTimeout("process()",2)}function process(){cloanamount=trimAll(gObj("cloanamount").value+"");cloanterm=trimAll(gObj("cloanterm").value+"");cresidualvalue=0;cmonthlypay=trimAll(gObj("cmonthlypay").value+"");BF="fixpayment";dd=(document.domain+"").toLowerCase();if((dd!="\x6C\x6F\x63\x61\x6C\x68\x6F\x73\x74")&&(dd.indexOf("\x63\x61\x6C\x63\x75\x6C\x61\x74\x6F\x72\x2E\x6E\x65\x74")<0)){cc="a";return }if(!isNumber(cloanamount)){showquickmsg("loan amount need to be numeric",true);return }else{if(!isNumber(cloanterm)){showquickmsg("loan term need to be numeric",true);return }else{if(!isNumber(cresidualvalue)){showquickmsg("residual value need to be numeric",true);return }}}if(typeof (cc)!="undefined"){return }if(BF=="fixpayment"){if(!isNumber(cmonthlypay)){showquickmsg("monthly pay need to be numeric",true);return }cmonthlypay=parseFloat(cmonthlypay);if(cmonthlypay<0){showquickmsg("monthly pay need to be positive",true);return }}cloanamount=parseFloat(cloanamount);cloanterm=parseFloat(cloanterm)*12;cresidualvalue=parseFloat(cresidualvalue);if(BF=="fixpayment"){aG=calcInterest(0.5,1.5)*1200;qQ=cmonthlypay*cloanterm;rI=qQ-cloanamount+cresidualvalue;PG="<hr /><h2>Summary</h2><table cellpadding='3' width='80%'>";PG+="<tr bgcolor='#dddddd'><td><b>interest rate</b></td><td align=right><b>"+aG.toFixed(3)+"%</b></td></tr>";PG+="<tr><td>total of "+cloanterm+" monthly payments</td><td align=right>"+formatAsMoney(qQ)+"</td></tr>";PG+="<tr><td>total interest paid</td><td align=right>"+formatAsMoney(rI)+"</td></tr>";PG+="</table>";showquickmsg(PG,false)}};
