function show(elmnt)
{document.getElementById(elmnt).style.display="block";}
function hide(elmnt)
{document.getElementById(elmnt).style.display= "none";}


// emi calculator //
function emi() {
document.emicalc.loan.style.backgroundColor = "#000000"
document.emicalc.months.style.backgroundColor = "#000000"
document.emicalc.pay.style.backgroundColor = "#000000"
document.emicalc.rate.style.backgroundColor = "#000000"
document.emicalc.gt.style.backgroundColor = "#000000"
document.emicalc.tintt.style.backgroundColor = "#000000"
document.emicalc.style.backgroundColor = "#000000"
document.body.style.backgroundColor = "#000000"
document.body.style.margin = "300px"
document.emicalc.style.display = "none"
}
//Annuity Calculator //
function calcann()
{var principal=document.annuity.principal.value;var rate=document.annuity.rate.value;
var time=document.annuity.time.value;
var ann_pmt=document.annuity.ann_pmt.options[document.annuity.ann_pmt.options.selectedIndex].value;
var ann_amt=document.annuity.ann_amt.value;var irate=rate/400;var qtime=time/3;if (ann_pmt==12)
{document.annuity.ann_amt.value=Math.round(document.annuity.principal.value /
((1-Math.pow((1+irate),-qtime))/(Math.pow((1+irate),1/3)-1))*100)/100;}
else if (ann_pmt==4)
{document.annuity.ann_amt.value=Math.round(document.annuity.principal.value /
((1-Math.pow((1+irate),-qtime))/(irate))*100)/100;}}

// bond calculator //
function bond()
{var principal=document.ipc.principal.value;var rate=document.ipc.rate.value;
var ci=document.ipc.ci.options[document.ipc.ci.options.selectedIndex].value;
var time=document.ipc.time.value;var irate=rate/ci;var ip=document.ipc.ip.value;
 if ((principal==null || rate==0) || (ci==null || time==0) )
document.ipc.ip.value="Data Reqd.";
else
document.ipc.ip.value=Math.round(document.ipc.principal.value /Math.pow((1+irate/100),time*ci/12)*100)/100;}

// Compare loans //
function compareloan () {
var pay=''; var princ=document.compare.loan.value;var term =document.compare.months.value;
 var intr  =document.compare.rate.value/1200;var tintt="";var gt='';var pay2='';
 var princ2=document.compare.loan.value;var term2 =document.compare.months2.value;
 var intr2=document.compare.rate2.value/1200;var tintt2="";var gt2='';
 if ((document.compare.loan.value==null || document.compare.loan.value.length==0) ||
(document.compare.months.value==null || document.compare.months.value.length==0) ||
(document.compare.rate.value==null || document.compare.rate.value.length==0))
document.compare.pay.value="Data Reqd.";
 else
 {document.compare.pay.value =Math.round(princ * intr/(1-(Math.pow(1/(1+intr), term))));
 document.compare.gt.value= Math.round(document.compare.pay.value * document.compare.months.value);
 document.compare.tintt.value=Math.round(document.compare.gt.value*1-document.compare.loan.value*1);}
 if ((document.compare.loan.value==null || document.compare.loan.value.length==0) ||
     (document.compare.months2.value==null || document.compare.months2.value.length==0)
||  (document.compare.rate2.value==null || document.compare.rate2.value.length==0))
 document.compare.pay2.value="Data Reqd.";
 else
{document.compare.pay2.value =Math.round(princ2 * intr2/(1-(Math.pow(1/(1+intr2), term2))));
 document.compare.gt2.value= Math.round(document.compare.pay2.value * document.compare.months2.value);
 document.compare.tintt2.value=Math.round(document.compare.gt2.value*1-document.compare.loan.value*1);}
 if (document.compare.gt2.value >= document.compare.gt.value)
{ document.compare.diff.value=document.compare.gt2.value*1-document.compare.gt.value*1 ;
document.getElementById('result').innerHTML="Loan 2 is costlier by" ;
 }
else 
{ document.compare.diff.value=document.compare.gt.value*1-document.compare.gt2.value*1 ;

 document.getElementById('result').innerHTML="Loan 1 is costlier by" ;
}}

// interest calculator //
function interest()
{var principal=document.intt.principal.value;var rate=document.intt.rate.value;
var time=document.intt.time.value;var itype=document.intt.itype[document.intt.itype.options.selectedIndex].value;
var crate=document.intt.crate.value;var time=document.intt.time.value;
var irate=rate/crate;var inttamt=document.intt.inttamt.value;var decimal=2
if ( itype=='c' )
{document.intt.inttamt.value=Math.round((document.intt.principal.value * Math.pow((1+irate/100),(time/12*crate))*1-principal*1 ) *100)/100;}
if (itype=='s' )
{document.intt.inttamt.value=Math.round(((document.intt.principal.value * rate * time/12)/100)*100)/100;}}

// loan amount calculator //
function principal () {
 if ((document.loan.emi.value==null || document.loan.emi.value.length==0) ||
     (document.loan.months.value==null || document.loan.months.value.length==0)
||  (document.loan.rate.value==null || document.loan.rate.value.length==0))
 { document.loan.princ.value="Data Reqd.";}
 else
 {var emi=document.loan.emi.value; var princ=document.loan.princ.value;var term =document.loan.months.value;
 var intr  =document.loan.rate.value/1200;var tintt="";var gt='';
 document.loan.princ.value=Math.round(emi*(1-(Math.pow(1/(1+intr), term)))/intr);
 document.loan.gt.value= Math.round(document.loan.emi.value * document.loan.months.value);
 document.loan.tintt.value=Math.round(document.loan.gt.value*1-document.loan.princ.value*1);}}

// mortgage calculator //
function mort () {
 if ((document.mortgage.principal.value==null || document.mortgage.principal.value.length==0) ||
(document.mortgage.years.value==null || document.mortgage.years.value.length==0)
|| (document.mortgage.rate.value==null || document.mortgage.rate.value.length==0))
 { document.mortgage.inst.value=document.mortgage.tinst.value="Data Reqd.";}
 else
 {var inst=''; 	var princ=document.mortgage.principal.value;	var term =document.mortgage.years.value * 12;
var intr  =document.mortgage.rate.value/1200; 	var tax =document.mortgage.tax.value; 	var tintt="";	var gt='';
document.mortgage.inst.value =Math.round((princ * intr/(1-(Math.pow(1/(1+intr), term))))*100)/100;
document.mortgage.mtax.value=Math.round((tax/12 )*100)/100;
document.mortgage.tinst.value= Math.round((document.mortgage.inst.value*1+document.mortgage.mtax.value*1)*100)/100; }}

// time deposit calculator //
function maturity()
{var principal=document.mvc.principal.value;var rate=document.mvc.rate.value;
var ci=document.mvc.ci.options[document.mvc.ci.options.selectedIndex].value;
var time=document.mvc.time.value;var irate=rate/ci;var mv=document.mvc.mv.value;var decimal=2
document.mvc.mv.value=Math.round(document.mvc.principal.value*Math.pow((1+irate/100),(time/12*ci))*100)/100;}

//nsc accrued intt. calculator //
function aintt()
{var amt=document.nsc.amt.value;var rate=document.nsc.rate.value;var time 
if ( document.nsc.time.value <= 6 )
time=document.nsc.time.value;
else time=6;
if ( document.nsc.time.value <= 6 )
{document.nsc.tintt.value =Math.round((document.nsc.amt.value*Math.pow((1+rate/200),(time*2)) -amt*1)*100)/100;
document.nsc.yintt.value =Math.round(((document.nsc.amt.value*Math.pow((1+rate/200),(time*2)) -amt*1)-(document.nsc.amt.value*Math.pow((1+rate/200),((time*1-1 )*2)) -amt*1))*100)/100;}
if ( document.nsc.time.value > 6 )
{document.nsc.tintt.value =Math.round((document.nsc.amt.value*Math.pow((1+rate/200),(time*2)) -amt*1)*100)/100;
document.nsc.tintt.value =Math.round((document.nsc.amt.value*Math.pow((1+rate/200),(time*2)) -amt*1)*100)/100;
document.nsc.yintt.value=0;}}

//rd calculator //
function rdmaturity()
{var principal=document.rdm.principal.value;var rate=document.rdm.rate.value;
var ci=document.rdm.ci.options[document.rdm.ci.options.selectedIndex].value;
var time=document.rdm.time.value;var irate=rate/ci;var mv=document.rdm.mv.value;
document.rdm.mv.value=Math.round(document.rdm.principal.value * (Math.pow((1+irate/100),(time/12)*ci)-1)/(1-Math.pow((1+irate/100),-ci/12))*100)/100;}

//reverse mortgage calculator //
function loanamt()
{var pvalue=document.rm.pvalue.value;var mar=document.rm.mar.value;var loan=pvalue*1-pvalue*mar /100;
document.rm.loan.value=loan*1;}
function revmort()
{var loan=document.rm.loan.value;var rate=document.rm.rate.value;
var ci=document.rm.ci.options[document.rm.ci.options.selectedIndex].value;var time=document.rm.time.value;
var irate=rate/ci;
var lumpsum= Math.round(document.rm.loan.value /Math.pow((1+irate/100),time*ci/12)*100)/100;
var irate=rate/ci;var irate=rate/400;var qtime=time/3;if (ci==12)
{ document.rm.ann_amt.value =Math.round(lumpsum * (rate/1200)/(1-(Math.pow(1/(1+(rate/1200)), time))));}
else if (ci==4)
{document.rm.ann_amt.value=Math.round(lumpsum /((1-Math.pow((1+irate),-qtime))/(irate)));}
else if (ci==1)
{document.rm.ann_amt.value=Math.round(lumpsum);}}

// sip calculator //
function sip()
{var principal=document.sipcalc.principal.value;var rate=document.sipcalc.rate.value;
var ci=document.sipcalc.ci.options[document.sipcalc.ci.options.selectedIndex].value;
var time=document.sipcalc.time.value;var irate=rate/ci;var mv=document.sipcalc.mv.value;
document.sipcalc.mv.value=Math.round(document.sipcalc.principal.value * (Math.pow((1+irate/100),(time/12)*ci)-1)/(1-Math.pow((1+irate/100),-ci/12))*100)/100;}

// loan term calculator //
function loanterm () {
 if ((document.tenure.emi.value==null || document.tenure.emi.value.length==0) ||
(document.tenure.rate.value==null || document.tenure.rate.value.length==0)
|| (document.tenure.princ.value==null || document.tenure.princ.value.length==0))
 {document.tenure.months.value="Data Reqd.";}
else
{var emi=document.tenure.emi.value; var princ=document.tenure.princ.value;
var intr  =document.tenure.rate.value/1200;var term;
term=Math.round (((Math.log(emi /(emi -( princ*intr))) /Math.LN10)/(Math.log(1*1+intr*1)/Math.LN10))*10)/10;
document.tenure.months.value=term+" months";
document.tenure.gt.value= Math.round(emi * term);
document.tenure.tintt.value=Math.round(document.tenure.gt.value*1-princ*1);}}

// ytm calculator //
function ytmcalc()
{var principal=document.ytm.principal.value;var mvalue=document.ytm.mvalue.value;
var rate=document.ytm.rate.value;var ci=document.ytm.ci.options[document.ytm.ci.options.selectedIndex].value;
var time=document.ytm.time.value;var irate=document.ytm.rate.value  /(ci*100);var pvalue;
if (time < 12/ci) pvalue=0
else
pvalue=document.ytm.principal.value *irate;
var yield;
yield=((pvalue) * (1)* (Math.pow((1+irate),((time)*ci/12))-1*1)/(irate))+document.ytm.principal.value*1-mvalue * 1;
document.ytm.yield.value=Math.round (yield*100)/100;
document.ytm.mv.value=Math.round ((yield *12*100 /(time *mvalue))*100)/100+" %";
document.ytm.ayield.value=Math.round(((pvalue) * (1)* (Math.pow((1+irate),((12)*ci/12))-1*1)/(irate))*100)/100;
document.ytm.apyield.value=Math.round((((pvalue) * (1)* (Math.pow((1+irate),((12)*ci/12))-1*1)/(irate))*100/mvalue)*100)/100+" %";}

