// JavaScript Document
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function showNRE()
{
	document.getElementById('fcnrdiv').style.display = 'none'
	document.getElementById('nrediv').style.display = 'block'
	document.getElementById('rfcadiv').style.display = 'none'
	document.getElementById('eefcdiv').style.display = 'none'
	document.getElementById('nreBtn').className = 'tabshover'
	document.getElementById('fcnrBtn').className = 'tabs'
	document.getElementById('rfcaBtn').className = 'tabs'
	document.getElementById('eefcBtn').className = 'tabs'
	
}

function showFCNR()
{
	document.getElementById('fcnrdiv').style.display = 'block'
	document.getElementById('nrediv').style.display = 'none'
	document.getElementById('rfcadiv').style.display = 'none'
	document.getElementById('eefcdiv').style.display = 'none'
	document.getElementById('nreBtn').className = 'tabs'
	document.getElementById('fcnrBtn').className = 'tabshover'
	document.getElementById('rfcaBtn').className = 'tabs'
	document.getElementById('eefcBtn').className = 'tabs'
}

function showRFCA()
{
	document.getElementById('fcnrdiv').style.display = 'none'
	document.getElementById('nrediv').style.display = 'none'
	document.getElementById('rfcadiv').style.display = 'block'
	document.getElementById('eefcdiv').style.display = 'none'
	document.getElementById('nreBtn').className = 'tabs'
	document.getElementById('fcnrBtn').className = 'tabs'
	document.getElementById('rfcaBtn').className = 'tabshover'
	document.getElementById('eefcBtn').className = 'tabs'
}

function showEEFC()
{
	document.getElementById('fcnrdiv').style.display = 'none'
	document.getElementById('nrediv').style.display = 'none'
	document.getElementById('rfcadiv').style.display = 'none'
	document.getElementById('eefcdiv').style.display = 'block'
	document.getElementById('nreBtn').className = 'tabs'
	document.getElementById('fcnrBtn').className = 'tabs'
	document.getElementById('rfcaBtn').className = 'tabs'
	document.getElementById('eefcBtn').className = 'tabshover'
}

/***Function for maturity yeild calculator***/

function validate()
	{

	if ((document.maturity.principle.value==0) || (isNaN(document.maturity.principle.value)))
		{
			//alert("\nThe principle is either empty or not a number . \n\nPlease re-enter principle.")
			document.maturity.principle.focus();
			return false;
		}
	if ((document.maturity.rate.value==0) || (isNaN(document.maturity.rate.value)))
		{
			//alert("\nThe rate is either empty or not a number . \n\nPlease re-enter rate.")
			document.maturity.rate.focus();
			return false;
		}
	if ((document.maturity.period.value==0) || (isNaN(document.maturity.period.value)))
		{
			//alert("\nThe period is either empty or not a number . \n\nPlease re-enter period.")
			document.maturity.period.focus();
			return false;
		}
			
	var rate=parseFloat(document.maturity.rate.value);
	var principle=parseInt(document.maturity.principle.value);
	var period=parseFloat(document.maturity.period.value);
    var per=parseFloat(document.maturity.period.value);

    var im=document.maturity.select1.selectedIndex;
	var em=parseInt(document.maturity.select1.options[im].value);
	var dur=document.maturity.duration.selectedIndex;
	var duration=parseInt(document.maturity.select2.options[dur].value);
	var comp=document.maturity.select2.selectedIndex;
	var computation=parseInt(document.maturity.select2.options[comp].value);

	if ((em==2)&&(duration==1))
	{
				interest=(principle * (period/365) * (rate/100));
				interest=interest*100;
				interest=Math.round(interest);
				interest=interest/100;
				document.maturity.intrest.value=interest;
				netamt=interest+principle;
				document.maturity.net_amount.value=Math.round(netamt).toFixed(2);
			
	}
    if ((em==2)&&(duration==2))
	{
				interest=Math.round((principle * (period/12) * (rate/100)));
				interest=interest*100;
				interest=Math.round(interest);
				interest=interest/100;
				document.maturity.intrest.value=interest;
				netamt=interest+principle;
				document.maturity.net_amount.value=Math.round(netamt).toFixed(2);
	}
	if ((em==2)&&(duration==4))
	{
				interest=Math.round((principle * (period/1) * (rate/100)));
				interest=interest*100;
				interest=Math.round(interest);
				interest=interest/100;
				document.maturity.intrest.value=interest;
				netamt=interest+principle;
				document.maturity.net_amount.value=Math.round(netamt).toFixed(2);
	}
	if ((em==1)&&(duration==1)&& (computation==1))
	{
			period=period/365;
			inter=(1+(rate/100));
			intermediate=Math.pow(inter,period);
			interest=intermediate*principle;
			interest=interest*100;
			interest=Math.round(interest);
			interest=interest/100;
			document.maturity.net_amount.value=Math.round(interest).toFixed(2);
			init=Math.round((interest-principle)*100);
			init=init/100;
			document.maturity.intrest.value=init;
			document.maturity.net_yield.value=Math.round((Math.pow((1+(rate/100)),1)-1)*10000)/100;			
	}
	if ((em==1)&&(duration==2)&& (computation==1))
	{
			period=period/12;
			inter=(1+(rate/100));
			intermediate=Math.pow(inter,period);
			interest=intermediate*principle;
			interest=interest*100;
			interest=Math.round(interest);
			interest=interest/100;
			document.maturity.net_amount.value=Math.round(interest).toFixed(2);
			init=Math.round((interest-principle)*100);
			init=init/100;
			document.maturity.intrest.value=init;
			document.maturity.net_yield.value=Math.round((Math.pow((1+(rate/100)),1)-1)*10000)/100;			
	}
	if ((em==1)&&(duration==4)&& (computation==1))
	{
			inter=(1+(rate/100));
			intermediate=Math.pow(inter,period);
			interest=intermediate*principle;
			interest=interest*100;
			interest=Math.round(interest);
			interest=interest/100;
			document.maturity.net_amount.value=Math.round(interest).toFixed(2);
			init=Math.round((interest-principle)*100);
			init=init/100;
			document.maturity.intrest.value=init;
			document.maturity.net_yield.value=Math.round((Math.pow((1+(rate/100)),1)-1)*10000)/100;			
	}
	if ((em==1)&&(duration==1)&& (computation==2))
	{
			period=period/360;
			period=period*2;
			inter=(1+((rate/2)/100));
			intermediate=Math.pow(inter,period);
			interest=intermediate*principle;
			interest=interest*100;
			interest=Math.round(interest);
			interest=interest/100;
			document.maturity.net_amount.value=interest;
			init=Math.round((interest-principle)*100);
			init=init/100;
			document.maturity.intrest.value=init;
			document.maturity.net_yield.value=Math.round((Math.pow((1+(rate/200)),2)-1)*10000)/100;			
	}
	if ((em==1)&&(duration==1)&& (computation==4))
	{
			period=period/365;
			period=period*4;
			inter=(1+((rate/4)/100));
			intermediate=Math.pow(inter,period);
			interest=intermediate*principle;
			interest=interest*100;
			interest=Math.round(interest);
			interest=interest/100;
			document.maturity.net_amount.value=Math.round(interest).toFixed(2);
			init=Math.round((interest-principle)*100);
			init=init/100;
			document.maturity.intrest.value=init;
			document.maturity.net_yield.value=Math.round((Math.pow((1+(rate/400)),4)-1)*10000)/100;			
	}
	if ((em==1)&&(duration==2)&& (computation==2))
	{
			period=period/12*365;
			period=period/360;
			period=period*2;
			inter=(1+((rate/2)/100));
			intermediate=Math.pow(inter,period);
			interest=intermediate*principle;
		interest=interest*100;
			interest=Math.round(interest);
			interest=interest/100;
			document.maturity.net_amount.value=interest;
		init=Math.round((interest-principle)*100);
			init=init/100;
			document.maturity.intrest.value=init;
			document.maturity.net_yield.value=Math.round((Math.pow((1+(rate/200)),2)-1)*10000)/100;
			
	}
	if ((em==1)&&(duration==4)&& (computation==2))
	{
	        period=period*365;
			period=period/360;
			period=period*2;
			inter=(1+((rate/2)/100));
			intermediate=Math.pow(inter,period);
			interest=intermediate*principle;
			interest=interest*100;
			interest=Math.round(interest);
			interest=interest/100;
			document.maturity.net_amount.value=interest;
			init=Math.round((interest-principle)*100);
			init=init/100;
			document.maturity.intrest.value=init;
			document.maturity.net_yield.value=Math.round((Math.pow((1+(rate/200)),2)-1)*10000)/100;			
	}
  if ((em==1)&&(duration==2)&& (computation==4))
	{
			period=period/12;
			period=period*4;
			inter=(1+((rate/4)/100));
			intermediate=Math.pow(inter,period);
			interest=intermediate*principle;
			interest=interest*100;
			interest=Math.round(interest);
			interest=interest/100;
			document.maturity.net_amount.value=Math.round(interest).toFixed(2);
			init=Math.round((interest-principle)*100);
			init=init/100;
			document.maturity.intrest.value=init;
			document.maturity.net_yield.value=Math.round(((init/principle)*100*12/per)*100)/100;
//			alert(Math.round((Math.pow((1+(rate/1200)),12)-1)*10000)/100);			
			
	}
	 if ((em==1)&&(duration==4)&& (computation==4))
	{
			period=period*4;
			inter=(1+((rate/4)/100));
			intermediate=Math.pow(inter,period);
			interest=intermediate*principle;
			interest=interest*100;
			interest=Math.round(interest);
			interest=interest/100;
			document.maturity.net_amount.value=Math.round(interest).toFixed(2);
			init=Math.round((interest-principle)*100);
			init=init/100;
			document.maturity.intrest.value=init;
			document.maturity.net_yield.value=Math.round((Math.pow((1+(rate/400)),4)-1)*10000)/100;			
	} 

		
}
function sel()
{
document.maturity.select2.disabled=false;
var si=document.maturity.select1.selectedIndex;
var mp=parseInt(document.maturity.select1.options[si].value);

if (mp==2)
{
document.maturity.select2.disabled=true
}}