//This code is optimized by the w3compiler from Port80 Software:  BUY w3compiler to remove this comment from your optimized files at www.w3compiler.com!
b=document;g=b.forms;r=true;x=Math;y=x.round;bb=alert;bv=parseInt;ec=Number;hj=0;txtloanamount=0;eb=0;months=0;hk="";var gn;var ga;hl="01234567890";cr="";str="";function gb(){str=b.frmEmi.txtPropertyCost.value;gz=str.length+3;dp=2;txtPropertyCost=str;str=b.frmEmi.txtloanamount.value;gz=str.length+3;dp=2;txtloanamount=str;str=b.frmEmi.interestRate.value;dp=4;eb=str;var bs=/^[0-9]*.?[0-9]*$/;if(txtloanamount==""){bb("Enter Loan Amount");b.frmEmi.txtloanamount.focus();return r}else{if(!bs.test(txtloanamount)||txtloanamount<1||txtloanamount>100000000){bb("Invalid Loan Amount");b.frmEmi.txtloanamount.select();b.frmEmi.txtloanamount.focus();return r}}if(eb==""){bb("Enter Rate of Interest");b.frmEmi.interestRate.focus();return r}else{if(!bs.test(eb)||eb<.0001||eb>99){bb("Invalid Interest Rate");b.frmEmi.eb.select();b.frmEmi.eb.focus();return r}}if(g[0].txtEmi){if(g[0].txtEmi.value==""){bb("Please provide valid EMI to calculate Interest");g[0].txtEmi.focus();return r}else{if(!bs.test(g[0].txtEmi.value)||g[0].txtEmi.value<1||g[0].txtEmi.value>10000000){bb("Please provide valid EMI to calculate Interest");g[0].txtEmi.focus();return r}}}}function calculateAllEMI(){if(gb())return;for(var noMonths=12;noMonths<=84;noMonths+=12){computeEMI(noMonths);}}function computeEMI(months){var bt=1;var interest=eb/(12*100);var finalEmi=0;for(var i=0;i<months;i++){bt*=(1+interest);}finalEmi=(txtloanamount*bt*interest)/(bt-1);if(b.frmEmi.R1[0].checked){bt=1;for(var i=0;i<months-1;i++){bt*=(1+interest);}finalEmi=((txtloanamount-finalEmi)*bt*interest)/(bt-1);}b.getElementById(months+'months').innerHTML='Rs. '+y(finalEmi)+'/-';return finalEmi}function printEMISchedule(months){prtSched(months);}function prtSched(months){if(gb())return;var totalInterest=0;fpv=computeEMI(months);var str="";str=fpv;str=y(str);pct=eb/12/100;if(b.frmEmi.R1[1].checked){ga="Arrears(i.e. Rear Ended EMI's)."}else{ga="Advance."}if(b.frmEmi.R1[0].checked){months--;txtloanamount-=fpv}el="<h3 style='border-bottom:2px solid #555555;font-family:arial, verdana;'>CarWale EMI Schedule</h3>";el+="<div align='right' class='doNotPrint' style='padding:5px;'><a href='javascript:print()' title='Print the EMI schedule'><img border='0' src='/images/icons/print.gif' />&nbsp;Print</a></div>";el+="<p align='justify'>Following  Schedule Is For : "+b.frmEmi.txtloanamount.value+" to repay in "+months+" months.<br>"+"All calculations are based on EMI in "+ga+"</p>"+"<table border='1' cellpadding='0'><tr>"+"<th>EMI Number</th>"+"<th>EMI Amount</th>"+"<th>Interest Amount</th>"+" <th>Principal Reduction</th>"+" <th>Balance Due</th></tr>";for(var j=0;j<months;j++){bp=(txtloanamount*pct);totalInterest=ec(totalInterest)+ec(bp);prp=fpv-bp;if(prp>txtloanamount){prp=txtloanamount}txtloanamount-=prp;if(fpv>(bp+prp)){fpv=bp+prp}str=(j+1)+".";el+='<tr>'+'<td>'+str+'</td>'+'<td>'+'Rs.'+y(fpv)+'</td>'+'<td>'+'Rs.'+y(bp)+'</td>'+'<td>'+'Rs.'+y(prp)+'</td>'+'<td>'+'Rs.'+y(txtloanamount)+'</td>'+'</tr>'}el+='</table>';var emiChart=b.getElementById('emiChart').innerHTML;b.frmEmi.sched.value=el+'<p>Total Interest Amount : Rs. '+y(totalInterest)+'</p>'+'<p>Complete EMI List</p>'+emiChart+'<p>Note: Interest calculated at 1/12th of annual interest rate on'+"    the remaining principal amount. (Rounding errors "+"possible)</p>";printSchedule();}function advanceEMI(calculatedEMI,monthsEMI){gn=calculatedEMI;b.frmEmi.txtloanamount.value=b.frmEmi.txtloanamount.value-calculatedEMI;b.frmEmi.txtloanamount.value=bv(b.frmEmi.txtloanamount.value)+bv(gn);}function printSchedule(){var myWindow=open('','myWindow','toolbars=no,width=650,height=500,scrollbars=yes');myWindow.document.write('<html><head><title>EMI Schedule</title>');myWindow.document.write('<style>body, table, p { font-family:arial, verdana;font-size:11px; }');myWindow.document.write('p { align:justify;padding:10px 0 10px 0; } table { border-collapse:collapse; }');myWindow.document.write('td, th { padding:2px; } .doNotShow { display:none; } th { background-color:#f3f3f3; } @media print { .doNotShow { display:none; } .doNotPrint { display:none;} }</style>');myWindow.document.write('</head><body>');myWindow.document.write('<pre>'+b.getElementById('txtSchedule').value+'</pre>');myWindow.document.write('</body></html>');myWindow.document.close();}function hm(carPrice,months,ha,hb){if(gb())return"";var totalInterest=0;var ex=carPrice;var interest=hb/(12*100);var prp=0,fpv=ha,bp=0;for(var i=0;i<months;i++){bp=ex*interest;totalInterest+=bp;prp=fpv-bp;if(prp>ex){prp=ex}ex-=prp;if(fpv>(bp+prp)){fpv=bp+prp}totalInterest=y(totalInterest,2);}return totalInterest}
