
function ClearAmountToSave_amtsave()
{
document.getElementById("AmountToResult").style.display="none";
document.getElementById("TrExplain").style.display="none";
document.getElementById("spnclear").style.display = "none";
}
function ExplainAmount_amtsave()
{
document.getElementById("TrExplain").style.display="inline";
}
function cl_calculate_amtsave()
{
var CL_current;           
var CL_roi;
var CL_tenure;
var CL_remain;
var CL_fv;
var CL_cst;
var CL_inf;                 
var CL_tp;
var CL_sav;
CL_tenure=parseFloat(document.form1.CL_tenure.value,10);
CL_current=parseFloat(document.form1.CL_current.value,10);
CL_roi=parseFloat(document.form1.CL_roi.value,10)/1200;
CL_cst=parseFloat(document.form1.CL_cst.value);
CL_inf=parseFloat(document.form1.CL_inf.value)/100;
CL_fv=CL_cst*Math.pow(1+CL_inf,CL_tenure)
CL_remain=CL_fv-CL_current*Math.pow((1+CL_roi*12),CL_tenure);
CL_sav=parseFloat(document.form1.CL_sav.value)
CL_tp=CL_sav*(Math.pow(1+CL_roi,CL_tenure*12)-1)/CL_roi;

if(isNaN(Math.round((CL_remain*CL_roi)/(Math.pow((1+CL_roi),CL_tenure*12)-1))))
{
	alert('One or more of the numeric fields is wrong. Please Check');
}
else
{
	if(document.layers)
	{
	document.getElementById("CL_emi").value=Math.max(Math.round((CL_remain*CL_roi)/(Math.pow((1+CL_roi),CL_tenure*12)-1)),0);
	document.getElementById("CL_current_value").value=Math.round(CL_tp+CL_current*Math.pow((1+CL_roi*12),CL_tenure));
	document.getElementById("CL_fv").value=Math.round(CL_fv);
	if(CL_tp+CL_current*Math.pow((1+CL_roi*12),CL_tenure)<CL_fv)
	{
	document.getElementById("extra").value=Math.round(CL_fv-CL_tp-CL_current*Math.pow((1+CL_roi*12),CL_tenure));
	}
	else
	{
	    document.getElementById("extra").value=0;
	}
	}
	else
	{
	document.getElementById("CL_emi").value=Math.max(Math.round((CL_remain*CL_roi)/(Math.pow((1+CL_roi),CL_tenure*12)-1)),0);
	document.getElementById("CL_fv").value=Math.round(CL_fv);
	document.getElementById("CL_current_value").value=Math.round(CL_tp+CL_current*Math.pow((1+CL_roi*12),CL_tenure));
	
	if(CL_tp+CL_current*Math.pow((1+CL_roi*12),CL_tenure)<CL_fv)
	{
	    document.getElementById("extra").value=Math.round(CL_fv-CL_tp-CL_current*Math.pow((1+CL_roi*12),CL_tenure));
	}
	else
	{
	document.getElementById("extra").value=0;
	}
	}
	document.getElementById("AmountToResult").style.display="inline";
	document.getElementById("spnclear").style.display = "inline";
	formatNumber('CL_emi');
	formatNumber('CL_fv');
	formatNumber('CL_current_value');
	formatNumber('extra');
}
}

var CL_viewHide;
if (document.layers) {
visible = 'show';
hidden = 'hide';
} else if (document.all) {

visible = 'visible';
hidden = 'hidden';
}
function cl_check_amtsave(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function CL_display_amtsave(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = visible;
}
function CL_hid_amtsave(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = hidden;
}
function cl_validate_amtsave(frm)
{
if(isNaN(parseFloat(frm.CL_current.value))||parseFloat(frm.CL_current.value)<0)
{
	alert('Savings should be greater than or equal to 0.');
	frm.CL_current.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_cst.value))||parseFloat(frm.CL_cst.value)<=0)
{
	alert('Cost should be greater than or equal to 0');
	frm.CL_cst.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_tenure.value))||parseFloat(frm.CL_tenure.value)<=0)
{
	alert('Period should be greater than 0.');
	frm.CL_tenure.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_roi.value))||parseFloat(frm.CL_roi.value)<=0)
{
	alert('Return on investment should be greater than 0.');
	frm.CL_roi.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_sav.value))||parseFloat(frm.CL_sav.value)<0)
{
	alert('Your monthly savings should be greater than or equal to 0.');
	frm.CL_sav.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_inf.value))||parseFloat(frm.CL_inf.value)<0)
{
	alert('Inflation should be greater than or equal to 0');
	frm.CL_inf.focus();
	return false;
}
return true;
}
/*-------------------------------------------------------------------------*/
/*AutoEmiCalculator*/
function loan_autoemi()
{
var ap=parseFloat(document.form1.ap.value);
}
function asset_autoemi()
{
var p=parseFloat(document.form1.p.value);
}
function calculate_autoemi()
 {
 var p=parseFloat(document.form1.p.value);
 if(!p) p=0;
 var i=parseFloat(document.form1.i.value)/100;
 if(!i) i=0;
 var tenure=parseFloat(document.form1.tenure.value);
 if(!tenure) tenure=0;
 var timetype=document.form1.timetype.options[document.form1.timetype.options.selectedIndex].value;
 var reset=parseFloat(document.form1.reset.options[document.form1.reset.options.selectedIndex].value);
 var adv=parseFloat(document.form1.adv.value);
 if(!adv) adv=0;
 var dep=parseFloat(document.form1.dep.value)/100;
 if(!dep) dep=0;
 var idep=parseFloat(document.form1.idep.value)/100;
 if(!idep) idep=0;
 var comp=parseFloat(document.form1.comp.options[document.form1.comp.options.selectedIndex].value);
 if(!comp) comp=0;
 if (timetype=='yr') tenure=tenure*12;
 var k=1/(1+i*reset/12)
 var x=tenure/reset;
 var fvsc=0;
 if(dep && !isNaN(dep))
 {
	if(comp<=-1)
	{		
	fvsc=dep*p*(1+tenure/12*idep);
	}
	else 
	{
	fvsc=dep*p*Math.pow(1+comp*idep/12,tenure/comp)
	}
	fvsc=fvsc*Math.pow(k,x);
 }
 
 var amt=p+fvsc-dep*p;
 x=(tenure-adv)/reset;
 var gp=(Math.pow(k,x)-1)/(k-1)*k
 gp+=adv/reset;
 var emi=amt/gp/reset;
 document.form1.emi.value=Math.round(emi);
 formatNumber('emi');
}
var str=window.location.href;
var viewHide;
if (document.layers) {
visible = 'show';
hidden = 'hide';
} else if (document.all) {
visible = 'visible';
hidden = 'hidden';
}
function hide_autoemi()
{
  document.getElementById("TrAutoEmiCalculator").style.display="none";
  document.getElementById("spnclear").style.display = "none";
}
function show_autoemi()
{
  document.getElementById("TrAutoEmiCalculator").style.display="inline";
  document.getElementById("spnclear").style.display = "inline";
} 
function check_autoemi(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function display_autoemi(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = visible;
viewHide = content;
}
function validate_autoemi(frm) {
if(!frm.p.value||frm.p.value<=0)
{
alert("Loan Amount should be greater than 0");
frm.p.focus();
return false;
}
if(!frm.i.value||frm.i.value<=0)
{
alert("Rate of Interest should be greater than 0");
frm.i.focus();
return false;
}
if(!frm.tenure.value||parseFloat(frm.tenure.value)<=0)
{
alert("Repayment period should be greater than 0");
frm.tenure.focus();
return false;
}
if(!frm.adv.value||parseFloat(frm.adv.value)<0||10<parseFloat(frm.adv.value))
{
alert("Advance EMIs should be between 0 and 10");
frm.adv.focus();
return false;
}
if(!frm.dep.value||parseFloat(frm.dep.value)<0)
{
alert("Deposit should be greater than or equal to 0");
frm.dep.focus();
return false;
}
if(!frm.idep.value||parseFloat(frm.idep.value)<0)
{
alert("Interest on deposit should be greater than or equal to 0");
frm.idep.focus();
return false;
}
return true;
}
/*-------------------------------------------------------------------------*/
/*BondYield*/
function ClearBondYield_bondyield()
{
    document.getElementById("TrBondYield").style.display="none";
    document.getElementById("spnclear").style.display = "none";
}
function cl_calculate_bondyield()           
{
var CL_amount=document.form1.CL_amt.value;
var CL_t2=parseFloat(document.form1.CL_t2.value);
var CL_roi2=parseFloat(document.form1.CL_roi2.value)/100;
var CL_comp=parseFloat(document.form1.CL_comp.options[document.form1.CL_comp.options.selectedIndex].value);
if(CL_comp>0)
{
var CL_rt=Math.pow(1+CL_roi2/CL_comp,CL_comp);
var CL_income=CL_amount*CL_roi2/CL_comp
}
else
{
var CL_rt=Math.pow(1+CL_t2*CL_roi2,1/CL_t2);
var CL_income= CL_amount*CL_t2*CL_roi2
}
var CL_inc;
if(CL_comp<0)CL_inc=  "simple"
if(CL_comp==1)CL_inc=  "annual"
if(CL_comp==2)CL_inc=  "semi annual"
if(CL_comp==4)CL_inc=  "quarterly"
if(CL_comp==12)CL_inc= "monthly"
if (document.layers)
{
document.getElementById("CL_tframe").value = CL_inc;
document.getElementById("CL_inc").value =  Math.round(CL_income);
document.getElementById("CL_irate").value = Math.round((CL_rt-1)*10000)/100;
}
if (document.all)
{
document.getElementById("CL_tframe").value = CL_inc;
document.getElementById("CL_inc").value =  Math.round(CL_income);
document.getElementById("CL_irate").value = Math.round((CL_rt-1)*10000)/100;
}
document.getElementById("CL_tframe").value = CL_inc;
document.getElementById("CL_inc").value =  Math.round(CL_income);
formatNumber('CL_inc');
document.getElementById("CL_irate").value = Math.round((CL_rt-1)*10000)/100;
document.getElementById("TrBondYield").style.display="inline";
document.getElementById("spnclear").style.display = "inline";
}
var CL_viewHide;
if (document.layers) {
visible = 'show';
hidden = 'hide';
} else if (document.all) {
visible = 'visible';
hidden = 'hidden';
}
function cl_check_bondyield(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function CL_display_bondyield(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = visible;
}
function CL_hid_bondyield(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = hidden;
}
function cl_validate_bondyield(frm)
{
if(isNaN(parseFloat(frm.CL_amt.value))||parseFloat(frm.CL_amt.value)<=0)
{
	alert('Invested amount should be greater than 0');
	frm.CL_amt.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_t2.value))||parseFloat(frm.CL_t2.value)<=0)
{
	alert('The period should be greater than 0.');
	frm.CL_t2.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_roi2.value))||parseFloat(frm.CL_roi2.value)<=0)
{
	alert('Rate of interest should be greater than 0.');
	frm.CL_roi2.focus();
	return false;
}
document.getElementById("TrBondYield").style.display="none";
return true;
}
/*-------------------------------------------------------------------------*/
/*CapitalGains*/
function ClearCapitalGain_capgain()
{
document.getElementById("result_capitalgain").style.display="none";
document.getElementById("CapitalExplain").style.display="none";
document.getElementById("spnclear").style.display="none";
}
function ExplainFun_capgain()
{
document.getElementById("CapitalExplain").style.display="inline";
}
function cl_calculate_capgain()
{
var CL_ival;
var CL_byr;            
var CL_sval;
var CL_syr;
var CL_itax=0;
var CL_tax=0;
CL_ival=parseFloat(document.form1.ival.value,10);
CL_byr=parseFloat(document.form1.CL_byr.options[document.form1.CL_byr.selectedIndex].value,10);
CL_sval=parseFloat(document.form1.CL_sval.value,10);
CL_syr=parseFloat(document.form1.CL_syr.options[document.form1.CL_syr.selectedIndex].value,10);
if(CL_byr!=0 && CL_syr!=0)
{
if (CL_syr==CL_byr)
{
alert('As the buying and the selling year are same, the gains will be added to your regular income');
CL_hid_capgain('result');
CL_hid_capgain('explain');
}
if (CL_syr<CL_byr)
{
alert('the sale year should come after the investment year');
return ;
}
}
if(CL_byr==0 || CL_syr==0)
{
   alert("W.e.f 1-10-2004, Securities Transaction Tax (STT) is Applicable...So Long Term Capital Gains tax is NIL ")
  
  if(document.layers)
		{
		document.getElementById("cl_emi").value=0;
		document.getElementById("cl_emi1").value=Math.round(CL_sval-CL_ival);
		}
		else
		{
		document.getElementById("cl_emi").value=0;
		document.getElementById("cl_emi1").value=Math.round(CL_sval-CL_ival);
		}			
}	
else
{	
CL_tax=((CL_sval-CL_ival)*0.1)*1.1;
CL_itax=(CL_sval-(CL_syr/CL_byr)*CL_ival)*0.2*1.1;
CL_tax=Math.min(CL_tax,CL_itax);
CL_tax=Math.max(0,CL_tax);

	if(isNaN(CL_tax))
	{
		alert('One or more of the numeric fields is wrong. Please Check');
	}
	else
	{
		if(document.layers)
		{
		document.getElementById("cl_emi").value = Math.round(CL_tax);
		document.getElementById("cl_emi1").value=Math.round(CL_sval-CL_ival);
		}
		else
		{
		document.getElementById("cl_emi").value=Math.round(CL_tax);
		document.getElementById("cl_emi1").value=Math.round(CL_sval-CL_ival);
		}
		formatNumber('cl_emi');
		formatNumber('cl_emi1');
	}
  }
}
var CL_viewHide;
if (document.layers) {
visible = 'show';
hidden = 'hide';
} else if (document.all) {
visible = 'visible';
hidden = 'hidden';
}
function cl_check_capgain(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function CL_display_capgain(viewShow)
{
document.getElementById("result_capitalgain").style.display="inline";
document.getElementById("spnclear").style.display="inline";
}
function CL_hid_capgain(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = hidden;
}
function cl_validate_capgain(frm)
{
if(!frm.ival.value||frm.ival.value<=0)
{
	alert('Investment value should be greater than 0.');
	frm.ival.focus();
	return false;
}
if(!frm.CL_sval.value||frm.CL_sval.value<=0)
{
	alert('Sale / Maturity value should be greater than 0');
	frm.CL_sval.focus();
	return false;
}
return true;
}
/*-------------------------------------------------------------------------*/
/*ChildeducationEMIinner*/
function calculate_childemu()
{
 var income=document.form1.edu_loan.value;
 var expen=document.form1.loan_pri.value;
 var year = document.getElementById("year");
 var edu_term = document.getElementById("edu_term");
 var edu_value = document.getElementById("edu_value");
 var edu_loan = document.getElementById("edu_loan");
if(year.value == "")
{
    alert("select the education commencement year");
    return false;
    
}
else if(edu_term.value == "")
{
    alert("select the period of education");
    return false;
}
else if(edu_value.value == "")
{
    alert("enter the cost of education");
    edu_value.focus();
    return false;
}
else if(edu_loan.value == "")
{
    alert("Enter the Education loan");
    edu_loan.focus();
    return false;
}
else if ((income == null || income == 0) ||(expen == null || expen == 0))
{ 
  document.form1.emi.value = 0;
}
else
{
  var princ = income;
  var term  = expen;
  var intr  = document.form1.int.value/ 1200;
  document.form1.emi.value = parseInt(princ * intr / (1 - (Math.pow(1/(1 + intr), term))))+1;	
  show_childemu();    
  formatNumber('emi'); 
}
}
function hide_childemu()
{
  document.getElementById("hid").style.display="none";
  document.getElementById("spnclear").style.display = "none";
}
function show_childemu()
{
  document.getElementById("hid").style.display="inline";
  document.getElementById("spnclear").style.display = "inline";
} 
/*-------------------------------------------------------------------------*/
/*ChildWedding*/
function hide_childwed()
{
  document.getElementById("hid").style.display="none";
  document.getElementById("spnclear").style.display = "none";
}
function show_childwed()
{
  document.getElementById("hid").style.display="inline";
  document.getElementById("spnclear").style.display = "inline";
  formatNumber('emi');
} 
function calculate_childwed() 
{
 var income=document.form1.loan.value
 var expen=document.form1.loan_pri.value
 var year = document.getElementById("year");
 var exp = document.getElementById("exp");
 var loan = document.getElementById("loan");
 if(year.value == "")
 {
    alert("select the year");
    year.focus();
    return false;
 }
 else if(exp.value == "")
 {
   alert("enter the cost of wedding");
   exp.focus();
   return false;
 }
 else if(loan.value == "")
 {
   alert("enter the loan amount");
   loan.focus();
   return false;
 }
 else if ((income == null || income == 0) || (expen == null || expen == 0))
  { 
	 document.form1.emi.value = 0;
  }
 else
  {
      var princ = income;
      var term  = expen;
      var intr   =  document.form1.int.value/ 1200;
      document.form1.emi.value = parseInt(princ * intr / (1 - (Math.pow(1/(1 + intr), term))))+1;
      show_childwed();
   }
}
/*-------------------------------------------------------------------------*/
/*CompoundingMagic*/
function ClearCompoundingMagic_compmag()
{
document.getElementById("TrCompoundingMagic").style.display="none";
document.getElementById("spnclear").style.display = "none";
}
function cl_calculate_compmag()
{
var CL_current;
var CL_roi;                        
var CL_tenure;
var CL_vl;

CL_tenure=parseFloat(document.form1.CL_time.value,10);
CL_current=parseFloat(document.form1.CL_current.value,10);
CL_roi=parseFloat(document.form1.CL_roi.value,10)/100;
if (CL_roi==0) CL_roi=0.00000001;
CL_vl=CL_current*Math.pow((1+CL_roi),CL_tenure);
CL_vl+=parseFloat(document.form1.CL_mon.value,10)*((Math.pow((1+CL_roi),CL_tenure)-1)/CL_roi);
if(isNaN(CL_vl))
{
	alert('One or more of the numeric fields are wrong. Please Check');
}
else
{
	document.getElementById("CL_emi").value=Math.round(CL_vl);
	document.getElementById("TrCompoundingMagic").style.display="inline";
	document.getElementById("spnclear").style.display = "inline";
	formatNumber('CL_emi');
}
}
var CL_viewHide;

function cl_check_compmag(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function CL_vlidate_compmag(frm){
if(isNaN(parseFloat(frm.CL_current.value))||parseFloat(frm.CL_current.value)<0)
{
alert('Current savings should be greater than or equal to 0');
frm.CL_current.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_mon.value))||parseFloat(frm.CL_mon.value)<0)
{
alert('Annual savings should be greater than or equal to 0');
frm.CL_mon.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_roi.value))||parseFloat(frm.CL_roi.value)<0)
{
alert('Return on your investments should be greater than or equal to 0');
frm.CL_roi.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_time.value))||parseFloat(frm.CL_time.value)<=0)
{
alert('Investment horizon should be greater than 0');
//frm.age.focus();
frm.CL_time.focus();
return false;
}
return true;
}
/*-------------------------------------------------------------------------*/
/*CostofLivingInner*/
function ClearCostofLiving_costlive()
{
document.getElementById("TrSavingEnough").style.display="none";
document.getElementById("spnclear").style.display = "none";
}
function cl_calculate_costlive()           
{
var CL_infexp= parseFloat(document.form1.CL_infexp.value);
var CL_ninfexp=parseFloat(document.form1.CL_ninfexp.value);
var CL_col=parseFloat(document.form1.CL_col.value);
var CL_incinf=parseFloat(document.form1.CL_incinf.value);
var CL_decinf=parseFloat(document.form1.CL_decinf.value);
var CL_nincinf=parseFloat(document.form1.CL_nincinf.value);
var CL_ndecinf=parseFloat(document.form1.CL_ndecinf.value);
var CL_inf=parseFloat(document.form1.CL_inf.value)/100;
var CL_iexp=CL_infexp;
CL_iexp=CL_iexp*Math.pow(1+	CL_inf,CL_col);
var CL_future=CL_incinf-CL_decinf;
CL_future=CL_future*Math.pow(1+	CL_inf,CL_col);
CL_iexp+=CL_future;
CL_nexp=CL_ninfexp+CL_nincinf-CL_ndecinf;
if(CL_iexp<0)
{
alert('Check inflationary expenses');
return;
}
if(CL_nexp<0)
{
alert('Check Non Inflationaey expenses');
return;
}
if(document.all)
{
document.getElementById("CL_inf_borrow").value=Math.round(CL_iexp);
document.getElementById("CL_ninf_borrow").value=Math.round(CL_nexp);
document.getElementById("CL_exp_borrow").value=Math.round(CL_iexp+CL_nexp);
document.getElementById("TrSavingEnough").style.display="inline";
}
document.getElementById("CL_inf_borrow").value=Math.round(CL_iexp);
document.getElementById("CL_ninf_borrow").value=Math.round(CL_nexp);
document.getElementById("CL_exp_borrow").value=Math.round(CL_iexp+CL_nexp);
formatNumber('CL_inf_borrow');
formatNumber('CL_ninf_borrow');
formatNumber('CL_exp_borrow');
document.getElementById("TrSavingEnough").style.display="inline";
document.getElementById("spnclear").style.display = "inline";
if (document.layers)
{

}
}
var CL_viewHide;
if (document.layers) {

} else if (document.all) {

}

function cl_check_costlive(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}

function CL_display_costlive(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
}
function CL_hid_costlive(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
}
function CL_vlidate_costlive(frm)
{
if(isNaN(parseFloat(frm.CL_infexp.value))||parseFloat(frm.CL_infexp.value)<=0)
{
alert('Expenses should be greater than 0');
frm.CL_infexp.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_ninfexp.value))||parseFloat(frm.CL_ninfexp.value)<0)
{
alert('Expenses should be greater than or equal to 0');
frm.CL_ninfexp.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_col.value))||parseFloat(frm.CL_col.value)<0)
{
alert('Year should be greater than or equal to 0');
frm.CL_col.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_incinf.value))||parseFloat(frm.CL_incinf.value)<0)
{
alert('Increase should be greater than or equal to 0');
frm.CL_incinf.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_decinf.value))||parseFloat(frm.CL_decinf.value)<0)
{
alert('Decrease should be greater than or equal to 0');
frm.CL_decinf.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_nincinf.value))||parseFloat(frm.CL_nincinf.value)<0)
{
alert('Increase should be greater than or equal to 0');
frm.CL_nincinf.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_ndecinf.value))||parseFloat(frm.CL_ndecinf.value)<0)
{
alert('Decrease should be greater than or equal to 0');
frm.CL_ndecinf.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_inf.value))||parseFloat(frm.CL_inf.value)<0)
{
alert('Decrease should be greater than or equal to 0');
frm.CL_inf.focus();
return false;
}
return true;
}
/*-------------------------------------------------------------------------*/
/*CurrentBondYield*/
function ClearCurrentBond_cby()
{
    document.getElementById("TrCurrentBondYield").style.display="none";
    document.getElementById("spnclear").style.display = "none";
}
function cl_calculate_cby()
{
CL_fvb=parseFloat(document.form1.CL_fvb.value)
CL_price=parseFloat(document.form1.CL_price.value)
CL_coupon=parseFloat(document.form1.CL_coupon.value)
var CL_currate=CL_fvb*CL_coupon/CL_price/100;
CL_currate=Math.round(CL_currate*10000)/100;
if (document.all)
{
document.getElementById("CL_yld").value=CL_currate
}
if (document.layers)
{
document.getElementById("CL_yld").value=CL_currate
}
document.getElementById("CL_yld").value=CL_currate
document.getElementById("spnclear").style.display = "inline";
}
var CL_viewHide;
if (document.layers) {
visible = 'show';
hidden = 'hide';
} else if (document.all) {
visible = 'visible';
hidden = 'hidden';
}
function cl_check_cby(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function CL_display_cby(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
}
function CL_hid_cby(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
}
function cl_validate_cby(frm)
{
if (!frm.CL_fvb.value || parseFloat(frm.CL_fvb.value)<=0)
{
alert('The face value of bond should be greater than or equal to 0');
frm.CL_fvb.focus();
return false;
}
if (!frm.CL_price.value || parseFloat(frm.CL_price.value)<=0)
{
alert('The price of bond should be greater than or equal to 0');
frm.CL_price.focus();
return false;
}
document.getElementById("TrCurrentBondYield").style.display="inline";
return true;
}
/*-------------------------------------------------------------------------*/
/*EffectofROI*/
function cl_calculate_effectroi()
 {
    var CL_current;                
    var CL_tenure;
    CL_tenure=(parseFloat(document.form1.ret.value,10)-parseFloat(document.form1.age.value,10));
    CL_current=parseFloat(document.form1.CL_current.value,10);
    CL_val=CL_current*Math.pow((1+CL_roi),CL_tenure*12);
    CL_val+=parseFloat(document.form1.mon.value,10)*((Math.pow((1+CL_roi),CL_tenure*12)-1)/CL_roi);
	if(isNaN(CL_val))
     {
	  alert('One or more of the numeric fields are wrong. Please cl_check');
	}
}
function draw_effectroi()
{
	var ary=Array()
    CL_roi=5/1200;
	cl_calculate_effectroi();
    var CL_val8=CL_val;
    var divide=1;
    divide=CL_val/15;
    CL_roi=21/1200;
    cl_calculate_effectroi();
    var CL_val21=CL_val;
    var ht=400;
    CL_roi=parseFloat(document.form1.CL_roi.value,10)/1200;
    cl_calculate_effectroi();
    var interest=parseFloat(document.form1.CL_roi.value,10);
    ary[0]=CL_val/CL_val21*400;
     for(i=1;i<14;i++)
{
  CL_roi=(8+i)/1200;
  cl_calculate_effectroi();
  ary[i]=400/CL_val21*CL_val;

}
 CL_win=window.open("",'ash1','scrollbars=yes,toolbar=no,menubar=no,resizable=yes,height=600,width=700','replace');
 CL_win.document.open();
 CL_win.focus();
 var bkcolor='ffffff';
 CL_win.document.write('<body bgcolor=#' + bkcolor + '>') ;
 CL_win.document.write('<table><tr><td><table><tr><td height='+ 40 + ' valign=top><font face=verdana size=1>Rs ' + Math.round(CL_val21/1000) + '</font></td><td bgcolor=#000000 width=2><font face=verdana size=1>&nbsp;</font></td></tr>');
 CL_win.document.write('<tr><td height='+ 40 + ' valign=top><font face=verdana size=1>Rs. ' + Math.round((9/10*(CL_val21))/1000) + '</font></td><td bgcolor=#000000 width=2><font face=verdana size=1>&nbsp;</font></td></tr>');
 CL_win.document.write('<tr><td height='+ 40 + ' valign=top><font face=verdana size=1>Rs. ' + Math.round((8/10*(CL_val21))/1000) + '</font></td><td bgcolor=#000000 width=2><font face=verdana size=1>&nbsp;</font></td></tr>');
 CL_win.document.write('<tr><td height='+ 40 + ' valign=top><font face=verdana size=1>Rs. ' + Math.round((7/10*(CL_val21))/1000) + '</font></td><td bgcolor=#000000 width=2><font face=verdana size=1>&nbsp;</font></td></tr>');
 CL_win.document.write('<tr><td height='+ 40 + ' valign=top><font face=verdana size=1>Rs. ' + Math.round((6/10*(CL_val21))/1000) + '</font></td><td bgcolor=#000000 width=2><font face=verdana size=1>&nbsp;</font></td></tr>');
 CL_win.document.write('<tr><td height='+ 40 + ' valign=top><font face=verdana size=1>Rs. ' + Math.round((5/10*(CL_val21))/1000) + '</font></td><td bgcolor=#000000 width=2><font face=verdana size=1>&nbsp;</font></td></tr>');
 CL_win.document.write('<tr><td height='+ 40 + ' valign=top><font face=verdana size=1>Rs. ' + Math.round((4/10*(CL_val21))/1000) + '</font></td><td bgcolor=#000000 width=2><font face=verdana size=1>&nbsp;</font></td></tr>');
CL_win.document.write('<tr><td height='+ 40 + ' valign=top><font face=verdana size=1>Rs. ' + Math.round((3/10*(CL_val21))/1000) + '</font></td><td bgcolor=#000000 width=2><font face=verdana size=1>&nbsp;</font></td></tr>');
CL_win.document.write('<tr><td height='+ 40 + ' valign=top><font face=verdana size=1>Rs. ' + Math.round((2/10*(CL_val21))/1000) + '</font></td><td bgcolor=#000000 width=2><font face=verdana size=1>&nbsp;</font></td></tr>');
CL_win.document.write('<tr><td height=' + 40 + ' valign=top><font face=verdana size=1>Rs. ' + Math.round((1 / 10 * (CL_val21)) / 1000) + '</font></td><td bgcolor=#000000 width=2><font face=verdana size=1>&nbsp;</font></td></tr>');
CL_win.document.write('<tr><td height=' + 15 + ' valign=top><font face=verdana size=1>Interest Earned</font></td><td bgcolor=#000000 width=2><font face=verdana size=1>&nbsp;</font></td></tr>');
CL_win.document.write('<tr><td height=' + 10 + ' valign=top><font face=verdana size=1>Rs.(&#39;000)</font></td><td bgcolor=#000000 width=2><font face=verdana size=1>&nbsp;</font></td></tr>');
CL_win.document.write('</table></td>');
CL_win.document.writeln('<td><font size=1>&nbsp;</font></td><td valign=bottom><table><tr><td valign=bottom bgcolor=#00aa00 width=4 height=' + Math.round(ary[0]) + '>&nbsp;</td></tr></table></td>');
for(i=1;i<14;i++)
{
CL_win.document.writeln('<td><font size=1>&nbsp;</font></td><td valign=bottom><table><tr><td valign=bottom bgcolor=#aaaaaa width=2 height=' + Math.round(ary[i]) + '>&nbsp;</td></tr></table></td>');
}
CL_win.document.writeln('</tr><tr><td></td><td bgcolor=#000000 height=1 colspan=28></td>');
CL_win.document.writeln('</tr><tr><td></td><td></td><td><font face=verdana size=1><b>' + interest + '%</b></font></td>');
for(i=9;i<22;+i++)
{
CL_win.document.write('<td></td><td><font face=verdana size=1>' + i + '%</font></td>');
}
CL_win.document.write('</tr></table>');
CL_win.document.writeln('<table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td align=middle width=100% align=center><font face=arial size=1><b>ROI in %</b></font></td></tr></table>');
CL_win.document.writeln('<table><tr><td><a href="#" onClick="javascript:top.window.close()"><font face=arial size=2>Back</font></a></td></tr></table>');
CL_win.document.write('<table><tr><td><font face=verdana size=2>With your current savings rate of <b>' + interest + '%</b> you should be able to save <b>Rs.&nbsp;' + Math.round(ary[0]*CL_val21/400) + '</b><br></td></tr></table>');
}
var CL_viewHide;
if (document.layers) {

} else if (document.all) {

}
function cl_check_effectroi(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function CL_display_effectroi(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = visible;
}
function CL_hid_effectroi(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = hidden;
}
var CL_val;
var CL_roi;
function cl_validate_effectroi(frm)
{
if(isNaN(parseFloat(frm.age.value))||parseFloat(frm.age.value)<=0)
{
alert('Age should be greater than 0');
frm.age.focus();
return false;
}
if(isNaN(parseFloat(frm.ret.value))||parseFloat(frm.ret.value)<=parseFloat(frm.age.value))
{
alert('Retirement age should be greater than your age');
frm.ret.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_current.value))||parseFloat(frm.CL_current.value)<0)
{
alert('Your current savings should be greater than or equal to 0');
frm.CL_current.focus();
return false;
}
if(isNaN(parseFloat(frm.mon.value))||parseFloat(frm.mon.value)<0)
{
alert('Monthly savings should be greater than or equal to 0');
frm.mon.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_roi.value))||parseFloat(frm.CL_roi.value)<=0)
{
alert('Return on your investment should be greater than 0');
frm.CL_roi.focus();
return false;
}
return true;
}
/*-------------------------------------------------------------------------*/
/*FDCalculator*/
function ClearFdCalculator_fdcalc()
{
document.getElementById("TrFdCalcultor").style.display="none"
document.getElementById("spnclear").style.display = "none";
}
function getfdMatVal_fdcalc(fdMatValForm){
var principalVal = fdMatValForm.principal.value;
if(isNaN(principalVal) || (parseFloat(principalVal) <= 0)){
	alert("Principal value invalid!!!");
	fdMatValForm.principal.focus();
	return(false);
}                                      
var interestVal  = fdMatValForm.interest.value;
if(isNaN(interestVal) || (parseFloat(interestVal) <= 0) || (parseFloat(interestVal) > 100) ){
	alert("Rate of Interest value invalid!!!");
	fdMatValForm.interest.focus();
	return(false);
}
var tenureVal  =   fdMatValForm.tenure.value;
if(isNaN(tenureVal) || (parseFloat(tenureVal) <= 0)){
    alert("Tenure value invalid!!!");
    fdMatValForm.tenure.focus();
    return(false);
}
var tenurePeriodVal = getSelectedValue_fdcalc(fdMatValForm.tenurePeriod);
if(isNaN(tenurePeriodVal)){
    alert("Tenure Period value invalid!!!");
    fdMatValForm.tenurePeriod.focus();
    return(false);
}
var frequencyVal = getSelectedValue_fdcalc(fdMatValForm.frequency);
if(isNaN(frequencyVal)){
    alert("Frequency value invalid!!!");
    fdMatValForm.frequency.focus();
    return(false);
}
//Get computable values
principalVal = parseFloat(principalVal);
interestVal  = parseFloat(interestVal);
tenureVal  =   parseFloat(tenureVal);
tenurePeriodVal = parseFloat(tenurePeriodVal);
frequencyVal = parseFloat(frequencyVal);

var retStr  =
	calMatVal_fdcalc(principalVal, interestVal, tenureVal, tenurePeriodVal, frequencyVal)

fdMatValForm.fdMatValResult.value = retStr;
document.getElementById("TrFdCalcultor").style.display="inline";
document.getElementById("spnclear").style.display = "inline";
formatNumber_pva('fdMatValResult');
return(false);
}
function getSelectedValue_fdcalc(formElement) {
var pointer = formElement.selectedIndex;
var selectedValue = formElement.options[pointer].value;

return (selectedValue);
}

function calMatVal_fdcalc(principalVal, interestVal, tenureVal, tenurePeriodVal, frequencyVal){
var fdMatVal=0;
var retStr="";
//If Simple interest
if(frequencyVal == 0){
    fdMatVal =
        principalVal * (1 + ((interestVal * tenureVal) / (tenurePeriodVal*100)));
}//if simple interest ends
else {
    //Cal Compound interest
        var val1 = 1 + interestVal/(100 * frequencyVal);
        var val2 = tenureVal * frequencyVal / tenurePeriodVal;
        var val3 = 0;
        val3 = Math.pow(val1, val2);
        fdMatVal = principalVal * val3;
}//if compound interest ends
retStr = retStr + Math.round(fdMatVal);
return(retStr);
}//function calMatVal() ends
/*-------------------------------------------------------------------------*/
/*FlateRateCost*/
function validate_flatrate()
{	
if(!document.form1.tenure.value||parseFloat(document.form1.tenure.value)<=0)
{
alert('Tenure should be greater than 0');
document.form1.tenure.focus();
return false;
}
if(!document.form1.interest.value||parseFloat(document.form1.interest.value)<0)
{
alert('Interest should be greater than or equal to 0%');
document.form1.tenure.focus();
return false;
}
if(!document.form1.charge.value||parseFloat(document.form1.charge.value)<0)
{
alert('Charges should be greater than or equal to 0%');
document.form1.charge.focus();
return false;
}
return true;
}
function calculate_flatrate()
{
var amount=100000;
var tenure =document.form1.tenure.value*12;
var interest=document.form1.interest.value/100;
var charge=parseFloat(document.form1.charge.value/100);
var amount=100000
var pay=amount*(1+tenure/12*interest);
var strt=(pay-amount)/amount/tenure;
var emi =pay/tenure;
amount=100000*(1-charge)
var r=1/(1+strt);
var res= emi*((Math.pow(r,tenure)-1)/(r-1))*r-amount;
if(res>0)
{
do 
{
strt=strt+0.00001;
r=1/(1+strt);
res=emi*((Math.pow(r,tenure)-1)/(r-1))*r-amount;
} while( res > 0 )
}
else
{
alert('Please check the input numbers');
}
var eirr1=(Math.pow(1+strt,12)-1)*10000;
var eirr=((strt)*12)*10000;
eirr=Math.round(eirr);
eirr1=Math.round(eirr1);
eirr/=100;
eirr1/=100;
document.form1.emi.value=eirr;
document.form1.irr.value=eirr1;
}
var str=window.location.href;
var viewHide;
if (document.layers) {
visible = 'show';
hidden = 'hide';
} else if (document.all) {
visible = 'visible';
hidden = 'hidden';
}
function check_flatrate(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function display_flatrate(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = visible;
viewHide = content;
}
function hide_flatrate()
{
  document.getElementById("TrFlatRateCost").style.display="none";
  document.getElementById("spnclear").style.display = "none";
}
function show_flatrate()
{
  document.getElementById("TrFlatRateCost").style.display="inline";
  document.getElementById("spnclear").style.display = "inline";
} 
/*-------------------------------------------------------------------------*/
/*HousingEMIInner*/
function calculate_houseemi()
{
var pamount = parseInt(document.form1.pamount.value);
var intrate = parseFloat(document.form1.intrate.value,2);
var tenure = parseInt(document.form1.tenure.value);
if (isNaN(parseInt(pamount)) == true)
{
	alert("Please enter a valid Principal Amount !");
	document.form1.pamount.focus();
	return false;
}
if (isNaN(parseFloat(intrate),2) == true)
{
	alert("Please enter a valid Interest Rate !");
	document.form1.intrate.focus();
	return false;
}
if (isNaN(parseInt(tenure)) == true)
{
	alert("Please enter a Valid Tenure !");
	document.form1.tenure.focus();
	return false;
}
var tmonths = parseInt((document.form1.tenure.value) * 12)
var i = document.form1.intrate.value;
if (i > 1.0) {
	i = i / 100;
}
i /= 12;
var pow = 1;
for (var j = 0; j < tmonths; j++)
	pow = pow * (1 + i);
	money = "" + .01* Math.round(100*(document.form1.pamount.value * pow * i) / (pow - 1));
	dec = money.indexOf(".");
	if(dec!=-1){
		dollars = money.substring(0,dec); 
		cents = money.substring(dec+1,dec+3);
		cents = (cents.length < 2) ? cents + "0" : cents;
		money = dollars + "." + cents;
	}
	else{
}
document.form1.emiamt.value = money;
}
function hide_houseemi()
{
  document.getElementById("hid").style.display="none";
  document.getElementById("spnclear").style.display = "none";
}
function show_houseemi()
{
  document.getElementById("hid").style.display="inline";
  document.getElementById("spnclear").style.display = "inline";
} 
function check_houseemi(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
/*-------------------------------------------------------------------------*/
/*HRAExemptionInner*/
function HraClear_hraexeinn()
{
document.getElementById("showresult").style.display="none";
document.getElementById("spnclear").style.display="none";
}
function cl_calculate1_hraexeinn()
{
//alert("eee");
var CL_hra=parseFloat(document.form1.CL_hra.value);
var CL_rent=parseFloat(document.form1.CL_rent.value);
var CL_basic=parseFloat(document.form1.CL_basic.value);
var CL_da=parseFloat(document.form1.CL_da.value);
var CL_metro=0.5;
var CL_sav=0;                          
if(document.form1.CL_city[1].checked) CL_metro=0.4;
CL_sav=Math.min((CL_basic+CL_da)*CL_metro,CL_hra);
CL_sav=Math.min(CL_sav,CL_rent-0.1*(CL_basic+CL_da));
CL_sav=Math.max(CL_sav,0);
document.getElementById("showresult").style.display="inline";
document.getElementById("spnclear").style.display="inline";
document.form1.hra.value=CL_sav;
formatNumber('hra');
}
var CL_viewHide;
if (document.layers) {
visible = 'show';
hidden = 'hide';
} else if (document.all) {
visible = 'visible';
hidden = 'hidden';
}
function cl_check_hraexeinn(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function CL_display_hraexeinn(viewShow) {

}
function CL_hid_hraexeinn(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = hidden;
}
function cl_validateHRA_hraexeinn(frm)
{
if(isNaN(parseFloat(frm.CL_rent.value))||parseFloat(frm.CL_rent.value)<0)
{
	alert('Rent should be greater than or equal to 0.');
	frm.CL_rent.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_basic.value))||parseFloat(frm.CL_basic.value)<=0)
{
	alert('Basic salary should be greater than or equal to 0');
	frm.CL_basic.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_da.value))||parseFloat(frm.CL_da.value)<0)
{
	alert('DA should be greater than or equal to 0.');
	frm.CL_da.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_hra.value))||parseFloat(frm.CL_hra.value)<0)
{
	alert('HRA should be greater than or equal to 0.');
	frm.CL_hra.focus();
	return false;
}
return true;
}
/*-------------------------------------------------------------------------*/
/*ImpliedBondYield*/
function ClearImplied_impbond()
{
document.getElementById("TrImplied").style.display="none"
document.getElementById("spnclear").style.display = "none";
}
function cl_calculate_impbond()             
{
CL_fvb=parseFloat(document.form1.CL_fvb.value)
CL_price=parseFloat(document.form1.CL_price.value)
CL_rday1=parseFloat(document.form1.CL_rdy1.options[document.form1.CL_rdy1.selectedIndex].value)
CL_rday=parseFloat(document.form1.CL_rdy.options[document.form1.CL_rdy.selectedIndex].value)
CL_rmon1=parseFloat(document.form1.CL_rmon1.options[document.form1.CL_rmon1.selectedIndex].value)
CL_rmon=parseFloat(document.form1.CL_rmon.options[document.form1.CL_rmon.selectedIndex].value)
CL_ryr1=parseFloat(document.form1.CL_ryr1.value)
CL_ryr=parseFloat(document.form1.CL_ryr.value)
var CL_pdt=new Date(CL_ryr1,CL_rmon1,CL_rday1)
var CL_mdt=new Date(CL_ryr,CL_rmon,CL_rday)
frm=document.form1;
if(frm.CL_rdy1.selectedIndex==0)
{
alert('Choose a Day' );
frm.CL_rdy1.focus();
return ;
}
if(frm.CL_rmon1.selectedIndex==0)
{
alert('Choose a Month' );
frm.CL_rmon1.focus();
return ;
}
if(frm.CL_rdy.selectedIndex==0)
{
alert('Choose a Day' );
frm.CL_rdy.focus();
return ;
}
if(frm.CL_rmon.selectedIndex==0)
{
alert('Choose a Month' );
frm.CL_rmon.focus();
return ;
}
if(CL_pdt-CL_mdt>0)
{
alert('Purchase Date should be before Maturity Date');
frm.CL_ryr.focus();
return ;
}
var CL_timediff=(CL_mdt-CL_pdt)/365/24/60/60/1000;
var CL_pergain=(CL_fvb-CL_price)/CL_price;
var CL_anngain=Math.pow((1+CL_pergain),(1/CL_timediff))-1;
CL_anngain=Math.round(CL_anngain*10000)/100;
if (document.all)
{
document.getElementById("yld").value=CL_anngain
}
if (document.layers)
{
document.getElementById("yld").value=CL_anngain
document.getElementById("spnclear").style.display = "inline";
}
document.getElementById("yld").value=CL_anngain;
document.getElementById("TrImplied").style.display="inline";
document.getElementById("spnclear").style.display = "inline";
}
var CL_viewHide;
if (document.layers) {
visible = 'show';
hidden = 'hide';
} else if (document.all) {
visible = 'visible';
hidden = 'hidden';
}
function cl_check_impbond(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function CL_display_impbond(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
}
function CL_hid_impbond(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
}
function cl_validate_impbond(frm)
{
if (!frm.CL_fvb.value || parseFloat(frm.CL_fvb.value)<=0)
{
alert('The face value of bond should be greater than or equal to 0');
frm.CL_fvb.focus();
return false;
}
if (!frm.CL_ryr1.value || parseFloat(frm.CL_ryr1.value)<1900 ||parseFloat(frm.CL_ryr1.value)>=2100)
{
alert('The format for year is yyyy');
frm.CL_ryr1.focus();
return false;
}
if (!frm.CL_ryr.value || parseFloat(frm.CL_ryr.value)<1900 ||parseFloat(frm.CL_ryr.value)>=2100)
{
alert('The format for year is yyyy');
frm.CL_ryr.focus();
return false;
}
if (!frm.CL_price.value || parseFloat(frm.CL_price.value)<=0)
{
alert('The price of bond should be greater than or equal to 0');
frm.CL_price.focus();
return false;
}
return true;
}
/*-------------------------------------------------------------------------*/
/*MakingCrore*/
function ClearMakingCrore_makecrore()
  {
    document.getElementById("MakingCroreResult").style.display = "none";
    document.getElementById("spnclear").style.display = "none";
  } 	
function cl_calculate_makecrore()     
{
CL_age=parseFloat(document.form1.CL_age.value);
CL_cursav1=parseFloat(document.form1.CL_cursav.value);
CL_inc=parseFloat(document.form1.CL_inc.value);
CL_incgrow25=parseFloat(document.form1.CL_incgrow25.value);
CL_incgrow35=parseFloat(document.form1.CL_incgrow35.value);
CL_incgrow50=parseFloat(document.form1.CL_incgrow50.value);
CL_roi25=parseFloat(document.form1.CL_roi25.value);
CL_roi35=parseFloat(document.form1.CL_roi35.value);
CL_roi50=parseFloat(document.form1.CL_roi50.value);
CL_savinc25=parseFloat(document.form1.CL_savinc25.value);
CL_savinc35=parseFloat(document.form1.CL_savinc35.value);
CL_savinc50=parseFloat(document.form1.CL_savinc50.value);
CL_diff=1;
CL_ret=CL_age+1;
CL_crore=0;
if(CL_roi25!="" && CL_roi35!="" && CL_roi50!="")
{
CL_r25=1+(CL_roi25/100)
CL_r35=1+(CL_roi35/100)
CL_r50=1+(CL_roi50/100)
CL_igrow25=1+(CL_incgrow25/100)
CL_igrow35=1+(CL_incgrow35/100)
CL_igrow50=1+(CL_incgrow50/100)
CL_savinc25=CL_savinc25/100/12
CL_savinc35=CL_savinc35/100/12
CL_savinc50=CL_savinc50/100/12
CL_monrate25=Math.pow(CL_r25,1/12)
CL_monrate35=Math.pow(CL_r35,1/12)
CL_monrate50=Math.pow(CL_r50,1/12)
if(CL_monrate25!=1)  CL_savinc25=CL_savinc25*((Math.pow(CL_monrate25,12)-1)/(CL_monrate25-1));
if(CL_monrate35!=1)  CL_savinc35=CL_savinc35*((Math.pow(CL_monrate35,12)-1)/(CL_monrate35-1));
if(CL_monrate50!=1)  CL_savinc50=CL_savinc50*((Math.pow(CL_monrate50,12)-1)/(CL_monrate50-1));
CL_cursav=CL_cursav1;
do
{
CL_Ncursav=CL_cursav1;
CL_k= CL_igrow25/CL_r25;
CL_income=CL_inc;
if(CL_age<35)
{
CL_Ninc=CL_income*(Math.pow(CL_r25,Math.min(CL_diff-1,35-CL_age-1)));
CL_Ncursav=CL_Ncursav*(Math.pow(CL_r25,Math.min(CL_diff,35-CL_age)));
if(CL_k!=1)
{
CL_Ninc=CL_Ninc*((Math.pow(CL_k,Math.min(CL_diff,35-CL_age))-1)/(CL_k-1));
}
else
{
CL_Ninc=CL_Ninc*Math.min(CL_diff,35-CL_age)
}
CL_Ninc=CL_Ninc*CL_savinc25
CL_Ncursav=CL_Ninc + CL_Ncursav
CL_income=CL_income*(Math.pow(CL_igrow25,Math.min(CL_diff-1,35-CL_age-1)))
CL_income=CL_income*CL_igrow35
}
CL_k= CL_igrow35/CL_r35
if(CL_age<50)
{
if(CL_ret>35)
{
CL_Ncursav=CL_Ncursav*Math.pow(CL_r35,Math.min(CL_ret-Math.max(CL_age,35),50-Math.max(CL_age,35)));
CL_Ninc=CL_income*Math.pow(CL_r35,Math.min(CL_ret-Math.max(CL_age,35)-1,50-Math.max(CL_age,35)-1));
if(CL_k!=1)
{
CL_Ninc=CL_Ninc*((Math.pow(CL_k,Math.min(CL_ret-Math.max(CL_age,35),50-Math.max(CL_age,35)))-1)/(CL_k-1));
}
else
{
CL_Ninc=CL_Ninc*Math.min(CL_ret-Math.max(CL_age,35),50-Math.max(CL_age,35));
}
CL_Ninc=CL_Ninc*CL_savinc35 ;
CL_Ncursav=CL_Ninc + CL_Ncursav;
CL_income=CL_income*Math.pow(CL_igrow35,Math.min(CL_ret-Math.max(CL_age,35)-1,50-Math.max(CL_age,35))-1);
CL_income=CL_income*CL_igrow50;
}
}
CL_k= CL_igrow50/CL_r50
CL_Ninc=CL_income*Math.pow(CL_r50,Math.max(0,CL_ret-Math.max(CL_age,50)-1));
CL_Ncursav=CL_Ncursav*(Math.pow(CL_r50,Math.max(0,CL_ret-Math.max(CL_age,50))));
if(CL_k!=1)
{
CL_Ninc=CL_Ninc*(Math.pow(CL_k,Math.max(0,CL_ret-Math.max(CL_age,50)))-1)/(CL_k-1);
}
else
{
CL_Ninc=CL_Ninc*Math.max(0,CL_ret-Math.max(CL_age,50))
}
CL_Ninc=CL_Ninc*CL_savinc50;
CL_Ncursav=CL_Ninc + CL_Ncursav ;
CL_ret=CL_ret+1
CL_diff=CL_diff+1
CL_crore=CL_Ncursav
} while (CL_crore<10000000)
}
if(document.all)
{
document.getElementById("cl_emi").value=CL_diff-1;
}
if(document.layers)
{
document.getElementById("cl_emi").value=CL_diff-1;
}
document.getElementById("cl_emi").value=CL_diff-1;
}
var CL_viewHide;
if (document.layers) {
visible = 'show';
hidden = 'hide';
} else if (document.all) {
visible = 'visible';
hidden = 'hidden';
}
function cl_check_makecrore(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function CL_display_makecrore(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = visible;
}
function CL_hid_makecrore(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = hidden;
}
function cl_validate_makecrore(frm)
{
var CL_age,CL_cursav,CL_inc,CL_inf,CL_leave,CL_live,CL_savinc;
var CL_incgrow25,CL_incgrow35,CL_incgrow50;
var CL_roi25,CL_roi35,CL_roi50;
var CL_savinc25,CL_savinc35,CL_savinc50;
CL_age=parseInt(document.form1.CL_age.value);
CL_cursav=parseInt(document.form1.CL_cursav.value);
CL_inc=parseInt(document.form1.CL_inc.value);
CL_incgrow25=parseInt(document.form1.CL_incgrow25.value);
CL_incgrow35=parseInt(document.form1.CL_incgrow35.value);
CL_incgrow50=parseInt(document.form1.CL_incgrow50.value);
CL_roi25=parseInt(document.form1.CL_roi25.value);
CL_roi35=parseInt(document.form1.CL_roi35.value);
CL_roi50=parseInt(document.form1.CL_roi50.value);
CL_savinc25=parseInt(document.form1.CL_savinc25.value);
CL_savinc35=parseInt(document.form1.CL_savinc35.value);
CL_savinc50=parseInt(document.form1.CL_savinc50.value);
if(isNaN(CL_age) || isNaN(CL_inc) ||
	isNaN(CL_roi25)||isNaN(CL_roi35)||isNaN(CL_roi50))
{
alert('Please fill all the fields');
return false;
}
for(i=0;i<document.form1.length-2;i++)
{
	if(isNaN(parseInt(document.form1.elements[i].value))&& !document.form1.elements[i].value)
	{
		document.form1.elements[i].value=0;
	}
}
if(100 < CL_savinc25 ||100 < CL_savinc35||100 < CL_savinc50)
{
	alert('You cannot save more than you earn.');
	if(100 < CL_savinc25) document.form1.CL_savinc25.focus();
	if(100 < CL_savinc35) document.form1.CL_savinc35.focus();
	if(100 < CL_savinc50) document.form1.CL_savinc50.focus();
	return false;
}
document.getElementById("MakingCroreResult").style.display="inline";
document.getElementById("spnclear").style.display = "inline";
return true;
}
/*-------------------------------------------------------------------------*/
/*MakingMillion*/
function ClearMakingMillion_makemill()
{
document.getElementById("MakingMillionResult").style.display="none";
document.getElementById("spnclear").style.display="none";
} 	
function cl_calculate_makemill()
{
var CL_current;
var CL_amt;
var CL_roi;                            
var CL_sav;
var CL_tim;
CL_sav=parseFloat(document.form1.CL_sav.value,10);
CL_current=parseFloat(document.form1.CL_current.value,10);
CL_roi=parseFloat(document.form1.CL_roi.value,10)/100;
CL_roi=Math.pow(1+CL_roi,1/12)-1;
CL_roi=CL_roi+1;
CL_tim=0;
if(CL_roi<0 ||CL_sav<0)
{
alert('You can not give negetive figures in your Monthly Savings Interest on your savings');
return false;
}
if(CL_current>=1000000)
{
alert('Congratulations you are already a millionaire');
CL_hid('result');CL_hid('explain');
return
}
CL_amt=CL_sav*(Math.pow(CL_roi,CL_tim)-1)/(CL_roi-1);

do
{
CL_tim+=1;
CL_amt=CL_sav*(Math.pow(CL_roi,CL_tim)-1)/(CL_roi-1)+CL_current*(Math.pow(CL_roi,CL_tim));
}
while(CL_amt<1000000)
	if(CL_tim/12<1)
	{
	CL_tim= CL_tim + ' months';
	}
	else
	{
	CL_tim=Math.round(CL_tim/12) + ' years';
	}

	if(document.layers)
	{
	    document.getElementById("emi").value=CL_tim;
	}
	else
	{
	    document.getElementById("emi").value=CL_tim;
	}
}
function cl_check_makemill(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function cl_validate_makemill(frm)
{
if(isNaN(parseFloat(frm.CL_current.value))||parseFloat(frm.CL_current.value)<0)
{
	alert('Savings should be greater tah or equal to 0.');
	frm.CL_current.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_sav.value))||parseFloat(frm.CL_sav.value)<=0)
{
	alert('Your savings should be greater than 0');
	frm.CL_sav.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_roi.value))||parseFloat(frm.CL_roi.value)<=0)
{
	alert('Return on you savings should be greater than 0');
	frm.CL_roi.focus();
	return false;
}
document.getElementById("MakingMillionResult").style.display="inline";
document.getElementById("spnclear").style.display="inline";
return true;
}
/*-------------------------------------------------------------------------*/
/*PPFLoanCalculator*/
function PPFLoanClear_ppfloancalc()
{
document.getElementById("TrResult").style.display="none";
document.getElementById("spnclear").style.display = "none";
}
function dateDiff_ppfloancalc(dob,dob1)
{
date1 = new Date(dob);
date2 = new Date(dob1);
diff  = new Date();
diff.setTime((date1.getTime() - date2.getTime()));
timediff = diff.getTime();
weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7));
timediff = weeks  * ( 1000 * 60 * 60 * 24 * 7);
days  = Math.floor(timediff / (1000 * 60 * 60 * 24));
timediff -= days * (1000 * 60 * 60 * 24);
hours = Math.floor(timediff / (1000 * 60 * 60));
timediff -= hours * (1000 * 60 * 60);
mins = Math.floor(timediff / (1000 * 60));
timediff -= mins * (1000 * 60);
secs = Math.floor(timediff / 1000);
timediff -= secs * 1000;
difference = (weeks*7 + days)/365
return difference; // form should never submit, returns false
}
function checkday_ppfloancalc()
{
var d = document.form1.day.options[document.form1.day.selectedIndex].value;
var m = document.form1.mon.options[document.form1.mon.selectedIndex].value;
var y = document.form1.year.value;
var mnd;
if (parseInt(d) < 10) {
    d = "0" + d;
    }
if(parseInt(m) < 10) {
    m = "0" + m ;
}
concDate = m  +"/"+ d +"/"+ y;
if(y < 1980 || y > 2050)
 {
 window.alert( "The date should be after 1980 and before 2050");
 document.form1.year.focus();
 document.form1.year.select();
 gl_flag="FALSE";
 return false;
 }
if ((m == 4 || m == 6 || m == 9 || m == 11) && d == 31)
{
if (m==4) {mnd="April"}
if (m==6) {mnd="June"}
if (m==9) {mnd="September"}
if (m==11) {mnd="November"}
window.alert("Month "+ mnd +" doesn't have 31 days!")
document.form1.start.value="";
document.form1.end.value="";
document.form1.day.focus();
return false;
}
if (m == 2)
{ // check for february 29th
var isleap = (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));
    if (d > 29 || (d == 29 && !isleap))
    {
    window.alert("February " + y + " doesn't have " + d + " days!");
    document.form1.start.value="";
    document.form1.end.value="";
    document.form1.day.focus();
    return false;
    }
}
valid(y, m, d);
}
//Function to validate first date entered
function checkdate()
{
var d = document.form1.day.options[document.form1.day.selectedIndex].value;
var m = document.form1.mon.options[document.form1.mon.selectedIndex].value;
var y = document.form1.year.value;
if (parseInt(d) < 10) {
    d = "0" + d;
    }
if(parseInt(m) < 10) {
    m = "0" + m ;
}
concDate = m  +"/"+ d +"/"+ y;
if(y < 1980 || y > 2050)
 {
 window.alert( "The date should be after 1980 and before 2050");
 document.form1.year.focus();
 document.form1.year.select();
 gl_flag="FALSE";
 return false;
 }
 if((!nullvalue(document.form1.year) || ((document.form1.year.value).length !=4) || (document.form1.year.value<=
0) || isNaN(document.form1.year.value)))
            {
                    alert("Please enter the year of opening of your PPF account properly");
                    document.form1.year.focus();
                    return false;
            }
if (m == "None")
{
window.alert("Month needs to have a value");
return false;
}
if (isNaN(y))
{
window.alert("Year can only be numeric");
return false;
}
if (y == "")
{
window.alert("Year cannot be left blank");
return false;
}
if ((m == 4 || m == 6 || m == 9 || m == 11) && d == 31)
{
window.alert("Month "+ m +" doesn't have 31 days!")
return false;
}
{
if (m == 2)
{ // check for february 29th
var isleap = (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));
	if (d > 29 || (d == 29 && !isleap))
	{
	window.alert("February " + y + " doesn't have " + d + " days!");
	return false;
	}
}
}
valid(y, m, d);
}
function valid(y, m, d)
{
if(m > 3)
{
	year = parseInt(y) + 2;
}
else
{
	year = parseInt(y) + 1;
}
    newDate = "01" + "-Apr-" + year;
    document.form1.start.value = newDate;
    edDate = "31" + "-Mar-" + (year + 4);
    document.form1.end.value = edDate;
	x1 = "04/01/"+year
	y1 = "03/31/"+parseInt(year+4)
	nardate1 = x1;
	nardate2= y1;
	nardiff1 = dateDiff_ppfloancalc(nardate2,nardate1);
}
function checkmonth()
{
var d = document.form1.day.options[document.form1.day.selectedIndex].value;
var m = document.form1.mon.options[document.form1.mon.selectedIndex].value;
var y = document.form1.year.value;
var mnm;
if (parseInt(d) < 10) {
    d = "0" + d;
    }
if(parseInt(m) < 10) {
    m = "0" + m ;
}
concDate = m  +"/"+ d +"/"+ y;
if (m == "None")
{
window.alert("Month needs to have a value");
return false;
}
if (y == "")
{
document.form1.year.focus();
return false;
}
if ((m == 4 || m == 6 || m == 9 || m == 11) && d == 31)
{
if (m==4) {mnm="April"}
if (m==6) {mnm="June"}
if (m==9) {mnm="September"}
if (m==11) {mnm="November"}
window.alert("Month "+ mnm +" doesn't have 31 days!")
document.form1.start.value="";
document.form1.end.value="";
document.form1.day.focus();
return false;
}
if (m == 2)
{ // check for february 29th
var isleap = (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));
    if (d > 29 || (d == 29 && !isleap))
    {
    window.alert("February " + y + " doesn't have " + d + " days!");
    document.form1.start.value="";
	document.form1.end.value="";
	document.form1.day.focus();
	return false;
    }
}
valid2(y, m, d);
}
function valid2(y, m, d)
{
if (isNaN(y))
{
window.alert("Year can only be numeric");
return false;
}
if(m > 3)
{
    year = parseInt(y) + 2;
}
else
{
    year = parseInt(y) + 1;
}
    newDate = "01" + "-" + "Apr" + "-" + year;
    newDate2 = "04" + "/" + "01" + "/" + year;
    document.form1.start.value = newDate;
    edDate = "31" + "-" + "Mar" +"-" + (year + 4);
    edDate2 = "03" + "/" + "31" + "/" + parseInt(year + 4);
    document.form1.end.value = edDate;
}
//Function for validating mon1
function checkmonth2()
{
var d1 = document.form1.day1.options[document.form1.day1.selectedIndex].value;
var m1 = document.form1.mon1.options[document.form1.mon1.selectedIndex].value;
var y1 = document.form1.year1.value;
var mnm1;
if (parseInt(d1) < 10) {
    d1 = "0" + d1;
    }
if(parseInt(m1) < 10) {
    m1 = "0" + m1 ;
}
if (m1 == "None")
{
window.alert("Month needs to have a value");
document.form1.mon1.focus();
return false;
}
 if ((m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11) && d1 == 31)
{
if (m1==4) {mnm1="April"}
if (m1==6) {mnm1="June"}
if (m1==9) {mnm1="September"}
if (m1==11) {mnm1="November"}
window.alert("Month "+ mnm1 +" doesn't have 31 days!")
document.form1.fixdate.value="";
document.form1.day1.focus();
return false;
}
{
if (m1 == 2) { // check for february 29th
var isleap = (y1 % 4 == 0 && (y1 % 100 != 0 || y1 % 400 == 0));

if (d1 > 29 || (d1 == 29 && !isleap))
{
window.alert("February " + y1 + " doesn't have " + d1 + " days!");
document.form1.fixdate.value="";
document.form1.day1.focus();
return false;
}
}
}
}
function checkday1_ppfloancalc()
{
var d = document.form1.day.options[document.form1.day.selectedIndex].value;
var m = document.form1.mon.options[document.form1.mon.selectedIndex].value;
var y = document.form1.year.value;
if (parseInt(d) < 10) {
    d = "0" + d;
    }
if(parseInt(m) < 10) {
    m = "0" + m ;
}
concDate = m  +"/"+ d +"/"+ y;
var d1 = document.form1.day1.options[document.form1.day1.selectedIndex].value;
var m1 = document.form1.mon1.options[document.form1.mon1.selectedIndex].value;
var y1 = document.form1.year1.value;
var mnd1;
 if (parseInt(d1) < 10) {
    d1 = "0" + d1;
	 }
if(parseInt(m1) < 10) {
    m1 = "0" + m1 ;
}
concDate1 = m1 +"/"+ d1 +"/" + y1;
 if ((m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11) && d1 == 31)
{
if (m1==4) {mnd1="April"}
if (m1==6) {mnd1="June"}
if (m1==9) {mnd1="September"}
if (m1==11) {mnd1="November"}
window.alert("Month "+ mnd1 +" doesn't have 31 days!")
document.form1.fixdate.value="";
document.form1.day1.focus();
return false;
}
 {
if (m1 == 2) { // check for february 29th
var isleap = (y1 % 4 == 0 && (y1 % 100 != 0 || y1 % 400 == 0));
if (d1 > 29 || (d1 == 29 && !isleap))
{
window.alert("February " + y1 + " doesn't have " + d1 + " days!");
document.form1.fixdate.value="";
document.form1.day1.focus();
return false;
}
}
}
nardiff2 = dateDiff_ppfloancalc(concDate1,nardate1)
if((nardiff2>nardiff1)||(nardiff2<0)) {
alert("The date entered should be in the range " + document.form1.start.value + " and " + document.form1.end.value);
   return false;
   document.form1.year1.focus();
	document.form1.year1.select();
    }
x11 = dateDiff_ppfloancalc(concDate1, concDate)
 if (x11 <= 0)
{
 window.alert(" Date should be after account opening date");
 gl_flagi = "FALSE";
 return false;
}
//Check for date entered within range
newDte = document.form1.start.value;
edDte = document.form1.end.value;
   if (isNaN(y1))
   {
   window.alert("Year can only be numeric");
   document.form1.year1.value="";
   document.form1.year1.focus();
	 return false;
   }
if (m1 == "None")
{
window.alert("Month needs to have a value");
document.form1.mon1.focus();
return false;
}
valid1_ppfloancalc(y1, m1, d1);
}
//Function to validate second date
function checkdate1_ppfloancalc()
{
var d = document.form1.day.options[document.form1.day.selectedIndex].value;
var m = document.form1.mon.options[document.form1.mon.selectedIndex].value;
var y = document.form1.year.value;
if (parseInt(d) < 10) {
    d = "0" + d;
    }
if(parseInt(m) < 10) {
    m = "0" + m ;
}
concDate = m  +"/"+ d +"/"+ y;
var d1 = document.form1.day1.options[document.form1.day1.selectedIndex].value;
var m1 = document.form1.mon1.options[document.form1.mon1.selectedIndex].value;
var y1 = document.form1.year1.value;
 if (parseInt(d1) < 10) {
    d1 = "0" + d1;
    }
if(parseInt(m1) < 10) {
    m1 = "0" + m1 ;
}
concDate1 = m1 +"/"+ d1 +"/" + y1;
nardiff2 = dateDiff_ppfloancalc(concDate1,nardate1)
if((nardiff2>nardiff1)||(nardiff2<0)) {
	alert("The date entered should be in the range " + document.form1.start.value + " and " + document.form1.end.value);
   return false;
   document.form1.year1.focus();
  document.form1.year1.select();
	}
x11 = dateDiff_ppfloancalc(concDate1, concDate)
 if (x11 <= 0)
{
 window.alert(" Date should be after account opening date");
 gl_flagi = "FALSE";
 return false;
}
//Check for date entered within range
newDte = document.form1.start.value;
edDte = document.form1.end.value;
   if (isNaN(y1))
   {
   window.alert("Year can only be numeric");
   document.form1.year1.value="";
	document.form1.year1.focus();
	return false;
   }
if (m1 == "None")
{
window.alert("Month needs to have a value");
document.form1.mon1.focus();
return false;
}
if ((m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11) && d1 == 31)
{
window.alert("Month "+ m1 +" doesn't have 31 days!")
document.form1.fixdate.value="";
document.form1.day1.focus();
return false;
}
{
if (m1 == 2) { // check for february 29th
var isleap = (y1 % 4 == 0 && (y1 % 100 != 0 || y1 % 400 == 0));
if (d1 > 29 || (d1 == 29 && !isleap))
{
window.alert("February " + y1 + " doesn't have " + d1 + " days!");
document.form1.fixdate.value="";
document.form1.day1.focus();
return false;
}
}
}
valid1_ppfloancalc(y1, m1, d1);
}
function valid1_ppfloancalc(y1, m1, d1)
{
if(m1 > 3)
{
	year1 = parseInt(y1) - 1;
	newDate2 = "31" + "-" + "Mar" + "-" + year1;
	document.form1.fixdate.value = newDate2;
}
else
{
	year1 = parseInt(y1) - 2;
	newDate2 = "31" + "-" + "Mar" + "-" + year1;
	document.form1.fixdate.value = newDate2;
}
}
//function to validate amount
function valAmt_ppfloancalc()
{
   var fd1 = document.form1.amount.value;
    if (isNaN(fd1)|| fd1<="0")
    {
    window.alert("Amount can only be positive and numeric");
    document.form1.amount.value="";
	document.form1.amount.focus();
    return false;
    }
}
function nullvalue(nv)
{
    var lencalc=0;
for(i=0 ;i<nv.value.length ; i++)
{
  if(nv.value.charAt(i)==" ")
  {
  lencalc=parseInt(lencalc)+1;
  }
}
  if (lencalc==nv.value.length)
  {
   return false;
  }
 else
 {
    return true;
 }
}
//function to calculate loan percentage and date
function loanperc_ppfloancalc()
{
formatNumber('LOAN');
var d = document.form1.day.options[document.form1.day.selectedIndex].value;
var m = document.form1.mon.options[document.form1.mon.selectedIndex].value;
var y = document.form1.year.value;
var d1 = document.form1.day1.options[document.form1.day1.selectedIndex].value;
var m1 = document.form1.mon1.options[document.form1.mon1.selectedIndex].value;
var y1 = document.form1.year1.value;
var fd1 = parseInt(document.form1.amount.value);
if(document.form1.day.options[document.form1.day.selectedIndex].value==0)
{
    alert("Date Field cannot be empty");
    document.form1.day.focus();
    return false;
}
if(document.form1.mon.options[document.form1.mon.selectedIndex].value==0)
{
    alert("Month Field cannot be empty ");
    document.form1.mon.focus();
    return false;
}
if ((m == 4 || m == 6 || m == 9 || m == 11) && d == 31)
{
window.alert("Month "+ m +" doesn't have 31 days!")
document.form1.start.value="";
document.form1.end.value="";
document.form1.day.focus();
return false;
}
if (m == 2)
{ // check for february 29th
var isleap = (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));
    if (d > 29 || (d == 29 && !isleap))
    {
    window.alert("February " + y + " doesn't have " + d + " days!");
    document.form1.start.value="";
    document.form1.end.value="";
    document.form1.day.focus();
    return false;
    }
}
if ((m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11) && d1 == 31)
{
window.alert("Month "+ m1 +" doesn't have 31 days!")
document.form1.fixdate.value="";
document.form1.day1.focus();
return false;
}
{
if (m1 == 2) { // check for february 29th
var isleap = (y1 % 4 == 0 && (y1 % 100 != 0 || y1 % 400 == 0));

if (d1 > 29 || (d1 == 29 && !isleap))
{
window.alert("February " + y1 + " doesn't have " + d1 + " days!");
document.form1.fixdate.value="";
document.form1.day1.focus();
return false;
}
}
}
if((!nullvalue(document.form1.year) || ((document.form1.year.value).length !=4) || (document.form1.year.value<=0) || isNaN(document.form1.year.value)))
{
    alert("Please enter the year of opening of your PPF account");
    document.form1.year.focus();
    return false;
}
if(parseInt(document.form1.year.value)<1980 || parseInt(document.form1.year.value)>2050)
{
    alert("Year Field should be between 1980-2050");
    document.form1.year.focus();
    return false;
}

if((!nullvalue(document.form1.year1) || ((document.form1.year1.value).length !=4) || (document.form1.year1.value<=0) || isNaN(document.form1.year1.value)))
{
    alert("Please enter the date on which you wish to avail of a loan");
    document.form1.year1.focus();
    return false;
}
if (isNaN(fd1))
    {
    alert("Please enter the balance in your PPF account");
    document.form1.amount.focus();
    document.form1.amount.select();
    return false;
    }
m1 = parseInt(m1);
var monVal = "";
switch(m1){
case 1:
	monVal = "Jan";
	break;
case 2:
	monVal = "Feb";
	break;
case 3:
	monVal = "Mar";
	break;
case 4:
	monVal = "Apr";
	break;
case 5:
	monVal = "May";
	break;
case 6:
	monVal = "Jun";
	break;
case 7:
	monVal = "Jul";
	break;
case 8:
	monVal = "Aug";
	break;
case 9:
	monVal = "Sep";
	break;
case 10:
	monVal = "Oct";
	break;
case 11:
	monVal = "Nov";
	break;
case 12:
	monVal = "Dec";
	break
default:
}
concDate1 = d1 +"-"+ monVal +"-" + y1;
document.form1.fixdate1.value = concDate1;
document.form1.LOAN.value = (0.25 * parseInt(document.form1.amount.value));
document.getElementById("TrResult").style.display="inline";
document.getElementById("spnclear").style.display = "inline";
formatNumber('LOAN');
}

/*-------------------------------------------------------------------------*/
/*PPFWithdrawal*/
function PPFWithDrawClear_ppfwd()
{
document.getElementById("TrResult").style.display="none";
document.getElementById("spnclear").style.display = "none";
}
function dateDiff_ppfwd(dob,dob1)
{
date1 = new Date(dob);                    
date2 = new Date(dob1);
diff  = new Date();
diff.setTime((date1.getTime() - date2.getTime()));
timediff = diff.getTime();
weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7));
timediff -= weeks * (1000 * 60 * 60 * 24 * 7);
days = Math.floor(timediff / (1000 * 60 * 60 * 24));
timediff -= days * (1000 * 60 * 60 * 24);
hours = Math.floor(timediff / (1000 * 60 * 60));
timediff -= hours * (1000 * 60 * 60);
mins = Math.floor(timediff / (1000 * 60));
timediff -= mins * (1000 * 60);
secs = Math.floor(timediff / 1000);
timediff -= secs * 1000;
difference = (weeks*7 + days)/365
return difference; // form should never submit, returns false
}
function chkday_ppfwd()
{
var d = document.form1.day.options[document.form1.day.selectedIndex].value;
var m = document.form1.mon.options[document.form1.mon.selectedIndex].value;
var y = document.form1.year.value;
var mnd;
if (parseInt(d) < 10) {
    d = "0" + d;
}
if(parseInt(m) < 10) {
    m = "0" + m;
}
var concdate = m +"/"+ d +"/"+  y;
if (m == "None")
{
document.form1.mon.focus();
return false;
}
if ((m == 4 || m == 6 || m == 9 || m == 11) && d == 31)
{
if (m== 4) {mnd="April"}
if (m== 6) {mnd="June" }
if (m==9) {mnd="September"}
if (m==11) {mnd="November"}
window.alert("Month " + mnd +" doesn't have 31 days!")
document.form1.withdate.value="";
document.form1.year.value="";
document.form1.year.focus();
return false;
}
{
if (m == 2)
{ // check for february 29th
var isleap = (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));
    if (d > 29 || (d == 29 && !isleap))
    {
    window.alert("February " + y + " doesn't have " + d + " days!");
   document.form1.withdate.value="";
   document.form1.day.focus();
	return false;
    }
}
}
 if (isNaN(y))
{
window.alert("Year can only be numeric");
document.form1.year.value="";
document.form1.year.focus();
return false;
}
if (y == "0")
{
window.alert("Year cannot be Zero");
document.form1.year.value="";
document.form1.year.focus();
return false;
}
if (y == "")
{
document.form1.year.value="";
document.form1.year.focus();
return false;
}
valid_ppfwd(y, m, d);
}
//validations for the first date entered using the drop down boxes
function checkdate_ppfwd()
{
var d = document.form1.day.options[document.form1.day.selectedIndex].value;
var m = document.form1.mon.options[document.form1.mon.selectedIndex].value;
var y = document.form1.year.value;
if (parseInt(d) < 10) {
	d = "0" + d;
}
if(parseInt(m) < 10) {
	m = "0" + m;
}
var concdate = m +"/"+ d +"/"+  y;
   if(y <  1980 || y > 2050)
   {
   window.alert( "The date should be after 1980 and before 2050");
	document.form1.year.value="";
  document.form1.year.focus();
   return false;
   }
date3 = new Date(concdate)
if (m == "None")
{
window.alert("Month needs to have a value");
document.form1.mon.focus();
return false;
}
if (isNaN(y))
{
window.alert("Year can only be numeric");
document.form1.year.value="";
document.form1.year.focus();
return false;
}
if (y == "0")
{
window.alert("Year cannot be Zero");
document.form1.year.value="";
document.form1.year.focus();
return false;
}
if (y == "")
{
window.alert("Year cannot be left blank");
document.form1.year.value="";
document.form1.year.focus();
return false;
}
if ((m == 4 || m == 6 || m == 9 || m == 11) && d == 31)
{
window.alert("Month "+ m +" doesn't have 31 days!")
document.form1.year.value="";
document.form1.year.focus();
return false;
}
{
if (m == 2)
{ // check for february 29th
var isleap = (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));
	if (d > 29 || (d == 29 && !isleap))
	{
	window.alert("February " + y + " doesn't have " + d + " days!");
	return false;
	}
}
}
	valid_ppfwd(y, m, d);
}
//This function calculates the valid PPF withdrawal dates
function valid_ppfwd(y, m, d)
{
if(m > 3)
{
	year = parseInt(y) + 6;
	newDate = "01" + "-Apr-" + year;
	document.form1.withdate.value = newDate;
}
else
{
	year = parseInt(y) + 5;
	newDate = "01" + "-Apr-" + year;
	document.form1.withdate.value = newDate;
}
chkdate = "04/01/"+year;
}
function ckmonth_ppfwd()
{
var d = document.form1.day.options[document.form1.day.selectedIndex].value;
var m = document.form1.mon.options[document.form1.mon.selectedIndex].value;
var y = document.form1.year.value;
var mnm;
  if (parseInt(d) < 10) {
      d = "0" + d;
  }
  if(parseInt(m) < 10) {
     m = "0" + m;
 }
var concdate = m +"/"+ d +"/"+  y;

if (m == 2)
{ // check for february 29th
var isleap = (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));
    if (d > 29 || (d == 29 && !isleap))
    {
    window.alert("February " + y + " doesn't have " + d + " days!");
    document.form1.withdate.value="";
	 document.form1.mon.focus();
	return false;
    }
 }
if (m == "None")
{
window.alert("Month needs to have a value");
document.form1.mon.focus();
return false;
}
if (y == "")
{
document.form1.year.focus();
return false;
}

if ((m == 4 || m == 6 || m == 9 || m == 11) && d == 31)
{
if (m==4) {mnm="April"}
if (m==6) {mnm="June"}
if (m==9) {mnm="September"}
if (m==11) {mnm="November"}
window.alert("Month "+ mnm +" doesn't have 31 days!")
document.form1.withdate.value="";
document.form1.mon.focus();
return false;
}
 {
if (m == 2)
{ // check for february 29th
var isleap = (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));
    if (d > 29 || (d == 29 && !isleap))
    {
    window.alert("February " + y + " doesn't have " + d + " days!");
    document.form1.withdate.value="";
	return false;
    }
}
}
if (isNaN(y))
{
window.alert("Year can only be numeric");
document.form1.year.focus();
return false;
}
  if(y <  1980 || y > 2050)
   {
   window.alert( "The date should be after 1980 and before 2050");
   document.form1.year.focus();
   document.form1.year.select();
   gl_flag="FALSE";
   return false;
   }
if(m > 3)
  {
      year = parseInt(y) + 6;
  }
  else
  {
      year = parseInt(y) + 5;
  }
 newDate = "01" + "-Apr-" + year;
 document.form1.withdate.value = newDate;
}
//This performs the validations for the second date fields entered by user
function checkdate1_ppfwd()
{
var d = document.form1.day.options[document.form1.day.selectedIndex].value;
var m = document.form1.mon.options[document.form1.mon.selectedIndex].value;
var y = document.form1.year.value;

if (parseInt(d) < 10) {
	d = "0" + d;
	}
if(parseInt(m) < 10) {
	m = "0" + m ;
}
var concdate = m +"/"+ d +"/"+  y;

var d1 = document.form1.day1.options[document.form1.day1.selectedIndex].value;
var m1 = document.form1.mon1.options[document.form1.mon1.selectedIndex].value;
var y1 = document.form1.year1.value;

if (parseInt(d1) < 10) {
      d1 = "0" + d1;
      }
  if(parseInt(m1) < 10) {
      m1 = "0" + m1 ;
  }
var conc1 = m1 +"/"+ d1 +"/" + y1;
var dt2 = dateDiff_ppfwd(conc1,chkdate);

if(m1=="None"){
window.alert("Please enter the month");
document.form1.mon1.focus();
return false;
}

if(dt2 <=0)
{
alert("Date needs to be after  " + document.form1.withdate.value);
    document.form1.startdate.value="";
	document.form1.balstart.value="";
	document.form1.enddate.value="";
	document.form1.endbal.value="";
	document.form1.year1.value="";
	document.form1.year1.focus();
    return false;
}
//calculation for date validation
x = dateDiff_ppfwd(conc1,concdate);
if (isNaN(y1))
{
window.alert("Year can only be numeric");
document.form1.year1.focus();
return false;
}
 if (y1 == "0")
{
window.alert("Year cannot be Zero");
document.form1.year1.focus();
return false;
}
if (y1 == "")
{
window.alert("Year cannot be left blank");
document.form1.year1.focus();
return false;
}
if ((m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11) && d1 == 31)
{
window.alert("Month "+ m1 +" doesn't have 31 days!")
document.form1.startdate.value="";
document.form1.balstart.value="";
document.form1.enddate.value="";
document.form1.endbal.value="";
document.form1.mon1.focus();
return false;
}
if (m1 == 2)
{ // check for february 29th
var isleap = (y1 % 4 == 0 && (y1 % 100 != 0 || y1 % 400 == 0));
	if (d1 > 29 || (d1 == 29 && !isleap))
	window.alert("February " + y1 + " doesn't have " + d1 + " days!");
	document.form1.startdate.value="";
    document.form1.balstart.value="";
	document.form1.enddate.value="";
	document.form1.endbal.value="";
	document.form1.mon1.focus();
	return false;
}
if (x <= 0.0)
{
	window.alert("The date should be after account opening date");
	document.form1.year1.focus();
	gl_flagi = "FALSE";
	valid1_ppfwd(y1, m1, d1);
	return false;
}
else
{
	if(x >= 16.0)
     {
   chkdt_gl_flag = "FALSE";
	document.form1.submit();
    return false;
	}
//on clicking of 1 href
}
valid1_ppfwd(y1, m1, d1);
}
//calculates the
function valid1_ppfwd(y1, m1, d1)
{
if(m1 > 3)
{
	year1 = parseInt(y1);
	newDate2 = "31" + "-Mar-" + year1;
	document.form1.startdate.value = newDate2;
}
else if(m1==1 || m1 ==2 || m1==3)
{
	year1 = parseInt(y1) - 1;
	newDate2 = "31" + "-Mar-" + year1;
	document.form1.startdate.value = newDate2;
}
	newdate3 = document.form1.startdate.value;
	newdate4 = newdate3.substring(6);
	newdate5 = parseInt(newdate4) + 3;
	newdate6 = "31" + "-Mar-" + newdate5;
	document.form1.enddate.value = newdate6;
}
function chkday1_ppfwd()
{
var d = document.form1.day.options[document.form1.day.selectedIndex].value;
var m = document.form1.mon.options[document.form1.mon.selectedIndex].value;
var y = document.form1.year.value;
var mnd1;
if (parseInt(d) < 10) {
    d = "0" + d;
    }
if(parseInt(m) < 10) {
    m = "0" + m ;
}
var concdate = m +"/"+ d +"/"+  y;
var d1 = document.form1.day1.options[document.form1.day1.selectedIndex].value;
var m1 = document.form1.mon1.options[document.form1.mon1.selectedIndex].value;
var y1 = document.form1.year1.value;
 if (parseInt(d1) < 10) {
      d1 = "0" + d1;
      }
  if(parseInt(m1) < 10) {
      m1 = "0" + m1 ;
  }
var conc1 = m1 +"/"+ d1 +"/" + y1;
 var dt2 = dateDiff_ppfwd(conc1,chkdate);

 if(m1=="None"){
document.form1.mon1.focus();
return false;
}
  if(dt2 <= 0)
{
   alert("Date needs to be after  " + document.form1.withdate.value);
    document.form1.startdate.value="";
    document.form1.balstart.value="";
    document.form1.enddate.value="";
    document.form1.endbal.value="";
    document.form1.year1.focus();
      return false;
}
 if ((m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11) && d1 == 31)
  {
	if (m1==4) {mnd1="April"}
	if (m1==6) {mnd1="June"}
	if (m1==9) {mnd1="September"}
	if (m1==11) {mnd1="November"}
	window.alert("Month "+ mnd1 +" doesn't have 31 days!")
    document.form1.startdate.value="";
    document.form1.balstart.value="";
    document.form1.enddate.value="";
    document.form1.endbal.value="";
    document.form1.mon1.focus();
    return false;
  }
  if (m1 == 2)
  { // check for february 29th
  var isleap = (y1 % 4 == 0 && (y1 % 100 != 0 || y1 % 400 == 0));
      if (d1 > 29 || (d1 == 29 && !isleap))
      {
      window.alert("February " + y1 + " doesn't have " + d1 + " days!");
    document.form1.startdate.value="";
    document.form1.balstart.value="";
    document.form1.enddate.value="";
    document.form1.endbal.value="";
    document.form1.mon1.focus();
     return false;
      }
  }
chkval_ppfwd(y1,m1,d1);
}
function chkmth_ppfwd()
{
var d = document.form1.day.options[document.form1.day.selectedIndex].value;
var m = document.form1.mon.options[document.form1.mon.selectedIndex].value;
var y = document.form1.year.value;

if (parseInt(d) < 10) {
	d = "0" + d;
	}
if(parseInt(m) < 10) {
	m = "0" + m ;
}
var concdate = m +"/"+ d +"/"+  y;

var d1 = document.form1.day1.options[document.form1.day1.selectedIndex].value;
var m1 = document.form1.mon1.options[document.form1.mon1.selectedIndex].value;
var y1 = document.form1.year1.value;
var mnm1;
if (parseInt(d1) < 10) {
      d1 = "0" + d1;
      }
  if(parseInt(m1) < 10) {
      m1 = "0" + m1 ;
  }
var conc1 = m1 +"/"+ d1 +"/" + y1;
 var dt2 = dateDiff_ppfwd(conc1,chkdate);

 if(m1=="None"){
window.alert("Please enter the month");
document.form1.mon1.focus();
return false;
}
  if(dt2 <= 0)
{
alert("Date needs to be after  " + document.form1.withdate.value);
    document.form1.startdate.value="";
	document.form1.balstart.value="";
	document.form1.enddate.value="";
	document.form1.endbal.value="";
	document.form1.year1.focus();
      return false;
}
  if ((m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11) && d1 == 31)
  {
if (m1==4) {mnm1="April"}
if (m1==6) {mnm1="June"}
if (m1==9) {mnm1="September"}
if (m1==4) {mnm1="November"}
  window.alert("Month "+ mnm1 +" doesn't have 31 days!")
 	document.form1.startdate.value="";
    document.form1.balstart.value="";
	document.form1.enddate.value="";
	document.form1.endbal.value="";
	document.form1.mon1.focus();
	return false;
  }
  if (m1 == 2)
  { // check for february 29th
  var isleap = (y1 % 4 == 0 && (y1 % 100 != 0 || y1 % 400 == 0));
      if (d1 > 29 || (d1 == 29 && !isleap))
      {
      window.alert("February " + y1 + " doesn't have " + d1 + " days!");
   	document.form1.startdate.value="";
    document.form1.balstart.value="";
	document.form1.enddate.value="";
	document.form1.endbal.value="";
	document.form1.mon1.focus();
	return false;
      }
  }
chkval_ppfwd(y1,m1,d1);
}
function chkval_ppfwd(y1,m1,d1)
{
if (isNaN(y1))
    {
    window.alert("Year can only be numeric");
    document.form1.year1.focus();
	return false;
    }

if (y1 == "")
    {
	document.form1.year1.focus();
    return false;
   }
if(m1 > 3)
  {
      year1 = parseInt(y1);
      newDate2 = "31" + "-Mar-" + year1;
      document.form1.startdate.value = newDate2;
  }
  else if(m1==1 || m1==2)
  {
      year1 = parseInt(y1) - 1;
      newDate2 = "31" + "-Mar-" + year1;
      document.form1.startdate.value = newDate2;
  }
      newdate3 = document.form1.startdate.value;
      newdate4 = newdate3.substring(6);
      newdate5 = parseInt(newdate4) + 3;
      newdate6 = "31" + "-Mar-" + newdate5;
      document.form1.enddate.value = newdate6;
}
//function to calculate the amount eligible to be withdrawn
function withamt_ppfwd()
{
var d = document.form1.day.options[document.form1.day.selectedIndex].value;
var m = document.form1.mon.options[document.form1.mon.selectedIndex].value;
var y = document.form1.year.value;
var d1 = document.form1.day1.options[document.form1.day1.selectedIndex].value;
var m1 = document.form1.mon1.options[document.form1.mon1.selectedIndex].value;
var y1 = document.form1.year1.value;
 //ALERTS
 if(document.form1.day.options[document.form1.day.selectedIndex].value==0)
            {
                    alert("Date Field cannot be empty");
                    document.form1.day.focus();
                    return false;
            }

 if(document.form1.mon.options[document.form1.mon.selectedIndex].value=="None")
            {
                    alert("Please enter the Month Field for opening your PPF Account");
                    document.form1.mon.focus();
                    return false;
            }
balstart1 = document.form1.balstart.value;
	endbal1 = document.form1.endbal.value;
if(y == "" &&( balstart1 == "" || endbal1 == ""))
{
window.alert("Please enter the date of opening your PPF Account");
document.form1.year.focus();
return false;
}
if(document.form1.day1.options[document.form1.day1.selectedIndex].value==0)
{
        alert("Date Field cannot be empty");
        document.form1.day1.focus();
        return false;
}

if(document.form1.mon1.options[document.form1.mon1.selectedIndex].value=="None")
{
        alert("Please enter the Month of withdrawal");
        document.form1.mon1.focus();
        return false;
}
if(endbal1==""&&isNaN(balstart1)){
alert("Please enter a positive numerical value and do not leave any field blank") ;
document.form1.balstart.value = "";
document.form1.balstart.focus();
return false;
}
if(balstart1==""&&isNaN(endbal1)){
alert("Please enter a positive numerical value and do not leave any field blank") ;
document.form1.balstart.value="";
document.form1.balstart.focus();
return false;
}
if(y1==""&&(balstart1 == "" || endbal1 == ""))
{
window.alert("Please enter the date of withdrawal");
document.form1.year1.focus();
return false;
}
if(balstart1 == "" ) {
window.alert("Please enter PPF balance amount");
document.form1.balstart.focus();
return false;
}
if(endbal1 == ""){
window.alert("Please enter PPF balance amount");
document.form1.endbal.focus();
return false;
}
if(isNaN(balstart1) || balstart1<="0")
    {
    window.alert("PPF Amount can only be positive and numeric");
    document.form1.balstart.value="";
	document.form1.balstart.focus();
    return false;
    }
if(isNaN(endbal1) || endbal1<="0")
    {
    window.alert("PPF Amount can only be positive and numeric");
    document.form1.endbal.value="";
	document.form1.endbal.focus();
    return false;
    }
m1 = parseInt(m1);
var monVal = "";
switch(m1){
case 1:
    monVal = "Jan";
    break;
case 2:
    monVal = "Feb";
    break;
case 3:
    monVal = "Mar";
    break;
case 4:
    monVal = "Apr";
    break;
case 5:
    monVal = "May";
    break;
case 6:
    monVal = "Jun";
    break;
case 7:
    monVal = "Jul";
    break;
case 8:
    monVal = "Aug";
    break;
case 9:
    monVal = "Sep";
    break;
case 10:
    monVal = "Oct";
    break;
case 11:
    monVal = "Nov";
    break;
case 12:
    monVal = "Dec";
    break
default:
}

var conc1 = d1 +"-"+ monVal +"-" + y1;
if( balstart1 > endbal1)
{
newamt = endbal1 * 0.5;
document.form1.amount.value = newamt;
dtwith1 = conc1;
document.form1.dtwith.value = dtwith1;
}
else
{
newamt = balstart1 * 0.5;
document.form1.amount.value = newamt;
dtwith2 = conc1;
document.form1.dtwith.value = dtwith2;
}
document.getElementById("TrResult").style.display="inline";
document.getElementById("spnclear").style.display = "inline";
formatNumber('amount');
}
/*-------------------------------------------------------------------------*/
/*PresentValueAnnuity*/
function formatNumber_pva(id)
{
var obj = document.getElementById(id);
var num = new NumberFormat();
num.setInputDecimal('.');
num.setNumber(obj.value); // obj.value is '100000'
num.setPlaces('2', false);
num.setCurrencyValue('');
num.setCurrency(true);                                 
num.setCurrencyPosition(num.LEFT_OUTSIDE);
num.setNegativeFormat(num.LEFT_DASH);
num.setNegativeRed(false);
num.setSeparators(true, ',', ',');
obj.value = num.toFormatted();     
}
 function calculate_pva()
 {
   var A =  document.form1.annuityamt.value;
   A = A.replace(/,/,"");
   var B =  document.form1.Frequency.value; 
   B = B.replace(/,/,"");
   var C =  document.form1.annruns.value;
   document.form1.totalamt.value= A*B*C;                                
   var D =  futurevalue_pva(document.form1.discounting.value/100,1/ document.form1.Frequency.value,0,-100,1)-100;
   var E =  (document.form1.Frequency.value)* (document.form1.annruns.value);
   var F = Math.pow(1+D,-E);
   var G = 1-F;	   
   var H = (G/D)*A
   document.form1.presentval.value = Math.round(H/Math.pow(1+document.form1.discounting.value/100, document.form1.annstart.value )) 
   formatNumber_pva('totalamt');	  
   formatNumber_pva('annuityamt');
   formatNumber_pva('Frequency');
   formatNumber_pva('discounting');
   formatNumber_pva('annuityamt');
   formatNumber_pva('presentval');	 
 }
 function hide_pva()
   {
      document.getElementById("hid").style.display="none";
      document.getElementById("spnclear").style.display = "none";
   }
 function show_pva()
   {
      document.getElementById("hid").style.display="inline";
      document.getElementById("spnclear").style.display = "inline";
   }
 function futurevalue_pva(returnspercent,nper,PMT,pv,type)
   {
   var rate = returnspercent/100;
   var fv;
   fv =(PMT*(1+rate*type)*(1- Math.pow(1+ rate,nper))/rate)-pv*Math.pow(1+rate,nper);
   return (fv);
   } 
/*-------------------------------------------------------------------------*/
/*PresentValueSingleAmt*/
function formatNumber_pvsamt(id)
{
var obj = document.getElementById(id);
var num = new NumberFormat();
num.setInputDecimal('.');
num.setNumber(obj.value); // obj.value is '100000'
num.setPlaces('2', false);                            
num.setCurrencyValue('');
num.setCurrency(true);
num.setCurrencyPosition(num.LEFT_OUTSIDE);
num.setNegativeFormat(num.LEFT_DASH);
num.setNegativeRed(false);
num.setSeparators(true, ',', ',');
obj.value = num.toFormatted();     
}
 function calculate_pvsamt()
 {
   var cl_futureval =  document.form1.fvvalue.value;
   cl_futureval = cl_futureval.replace(/,/,"");
   var cl_tenure = document.form1.tenure.value;
   var cl_discounting = document.form1.rate.value;
   cl_discounting = cl_discounting.replace(/,/,"");
   document.form1.PresentValue.value = Math.round(cl_futureval/Math.pow(1+cl_discounting/100,cl_tenure)); 
   formatNumber_pvsamt('fvvalue');
   formatNumber_pvsamt('rate');
   formatNumber_pvsamt('PresentValue');
 }
  function hide_pvsamt()
{
  document.getElementById("hid").style.display="none";
  document.getElementById("spnclear").style.display = "none";
}
function show_pvsamt()
{
  document.getElementById("hid").style.display="inline";
  document.getElementById("spnclear").style.display = "inline";
}
/*-------------------------------------------------------------------------*/
/*PVIrregularCashFlow*/
    function formatNumber_pvirr(id)
{
var obj = document.getElementById(id);
var num = new NumberFormat();
num.setInputDecimal('.');
num.setNumber(obj.value); // obj.value is '100000'
num.setPlaces('2', false);
num.setCurrencyValue('');                                
num.setCurrency(true);
num.setCurrencyPosition(num.LEFT_OUTSIDE);
num.setNegativeFormat(num.LEFT_DASH);
num.setNegativeRed(false);
num.setSeparators(true, ',', ',');
obj.value = num.toFormatted();     
}
function replaceAll_pvirr( str, replacements ) 
{
  for ( i = 0; i < replacements.length; i++ ) 
   {
    var idx = str.indexOf( replacements[i][0] );
    while ( idx > -1 ) 
	{
        str = str.replace( replacements[i][0], replacements[i][1] ); 
        idx = str.indexOf( replacements[i][0] );
    }
  }
 return str;
}
function hide_pvirr()
{
  document.getElementById("hid").style.display="none";
  document.getElementById("spnclear").style.display = "none";
}
function show_pvirr()
{
  document.getElementById("hid").style.display="inline";
  document.getElementById("spnclear").style.display = "inline";
}
function calculate_pvirr()
{

var texttype
if (navigator.appName == "Microsoft Internet Explorer")
{
texttype="innerText";
}
else
{
texttype="textContent";
} 

if (document.form1.firstyear.value == '')
{
document.form1.firstyear.value = 0.00;
}
if (document.form1.secondyear.value == '')
{
document.form1.secondyear.value = 0.00;
}
if (document.form1.thirdyear.value == '')
{
document.form1.thirdyear.value = 0.00;
}
if (document.form1.fourthyear.value == '')
{
document.form1.fourthyear.value = 0.00;
}
if (document.form1.fifthyear.value == '')
{
document.form1.fifthyear.value = 0.00;
}
if (document.form1.sixthyear.value == '')
{
document.form1.sixthyear.value = 0.00;
}
if (document.form1.seventhyear.value == '')
{
document.form1.seventhyear.value = 0.00;
}
if (document.form1.eigthyear.value == '')
{
document.form1.eigthyear.value = 0.00;
}
if (document.form1.ninthyear.value == '')
{
document.form1.ninthyear.value = 0.00;
}
if (document.form1.tenthyear.value == '')
{
document.form1.tenthyear.value = 0.00;
}
if (document.form1.eleventhyear.value == '')
{
document.form1.eleventhyear.value = 0.00;
}
if (document.form1.twelthyear.value == '')
{
document.form1.twelthyear.value = 0.00;
}
if (document.form1.thirteenthyear.value == '')
{
document.form1.thirteenthyear.value = 0.00;
}
if (document.form1.fourteenthyear.value == '')
{
document.form1.fourteenthyear.value = 0.00;
}
if (document.form1.fifteenthyear.value == '')
{
document.form1.fifteenthyear.value = 0.00;
}
  
 var t1 = document.form1.firstyear.value ;
 t1 = replaceAll_pvirr(t1,[[",",""]]);
 var t2 = document.form1.secondyear.value; 
 t2 = replaceAll_pvirr(t2,[[",",""]]);
 var t3 = document.form1.thirdyear.value; 
 t3 = replaceAll_pvirr(t3,[[",",""]]);
 var t4 = document.form1.fourthyear.value;
 t4 = replaceAll_pvirr(t4,[[",",""]]);
 var t5 = document.form1.fifthyear.value; 
 t5 = replaceAll_pvirr(t5,[[",",""]]);
 var t6 = document.form1.sixthyear.value; 
 t6 = replaceAll_pvirr(t6,[[",",""]]);
 var t7 = document.form1.seventhyear.value;
 t7 = replaceAll_pvirr(t7,[[",",""]]);
 var t8 = document.form1.eigthyear.value; 
 t8 = replaceAll_pvirr(t8,[[",",""]]);
 var t9 = document.form1.ninthyear.value; 
 t9 = replaceAll_pvirr(t9,[[",",""]]);
 var t10 = document.form1.tenthyear.value;
 t10 = replaceAll_pvirr(t10,[[",",""]]);
 var t11 = document.form1.eleventhyear.value ;
 t11 = replaceAll_pvirr(t11,[[",",""]]);
 var t12 = document.form1.twelthyear.value ;
 t12 = replaceAll_pvirr(t12,[[",",""]]);
 var t13 = document.form1.thirteenthyear.value ;
 t13 = replaceAll_pvirr(t13,[[",",""]]);
 var t14 = document.form1.fourteenthyear.value ;
 t14 = replaceAll_pvirr(t14,[[",",""]]);
 var t15 = document.form1.fifteenthyear.value ;
 t15 = replaceAll_pvirr(t15,[[",",""]]);
  
 document.form1.Total.value =  parseFloat(t1)+parseFloat(t2)+parseFloat(t3)+parseFloat(t4)+parseFloat(t5)+parseFloat(t6)+
								  parseFloat(t7)+parseFloat(t8)+parseFloat(t9)+parseFloat(t10)+parseFloat(t11)+
								  parseFloat(t12)+parseFloat(t13)+parseFloat(t14)+parseFloat(t15); 

   
  var value1 = t1/Math.pow(1+document.form1.Discounting.value/100,eval('document.getElementById("one").'+texttype)) 
  var value2 = t2/Math.pow(1+document.form1.Discounting.value/100,eval('document.getElementById("two").'+texttype)) 
  var value3 = t3/Math.pow(1+document.form1.Discounting.value/100,eval('document.getElementById("three").'+texttype)) 
  var value4 = t4/Math.pow(1+document.form1.Discounting.value/100,eval('document.getElementById("four").'+texttype)) 
  var value5 = t5/Math.pow(1+document.form1.Discounting.value/100,eval('document.getElementById("five").'+texttype)) 
  var value6 = t6/Math.pow(1+document.form1.Discounting.value/100,eval('document.getElementById("six").'+texttype)) 
  var value7 = t7/Math.pow(1+document.form1.Discounting.value/100,eval('document.getElementById("seven").'+texttype)) 
  var value8 = t8/Math.pow(1+document.form1.Discounting.value/100,eval('document.getElementById("eight").'+texttype)) 
  var value9 = t9/Math.pow(1+document.form1.Discounting.value/100,eval('document.getElementById("nine").'+texttype)) 
  var value10 = t10/Math.pow(1+document.form1.Discounting.value/100,eval('document.getElementById("ten").'+texttype)) 
  var value11 = t11/Math.pow(1+document.form1.Discounting.value/100,eval('document.getElementById("eleven").'+texttype)) 
  var value12 = t12/Math.pow(1+document.form1.Discounting.value/100,eval('document.getElementById("twelve").'+texttype)) 
  var value13 = t13/Math.pow(1+document.form1.Discounting.value/100,eval('document.getElementById("thirteen").'+texttype)) 
  var value14 = t14/Math.pow(1+document.form1.Discounting.value/100,eval('document.getElementById("fourteen").'+texttype)) 
  var value15 = t15/Math.pow(1+document.form1.Discounting.value/100,eval('document.getElementById("fifteen").'+texttype)) 
  
  document.form1.Present.value = Math.round(
                                              parseFloat(value1)+parseFloat(value2)+parseFloat(value3)+parseFloat(value4)+
											  parseFloat(value5)+parseFloat(value6)+parseFloat(value7)+parseFloat(value8)+
											  parseFloat(value9)+parseFloat(value10)+parseFloat(value11)+parseFloat(value12)+
											  parseFloat(value13)+parseFloat(value14)+parseFloat(value15)
											 );    

  formatNumber_pvirr('firstyear');
  formatNumber_pvirr('secondyear');
  formatNumber_pvirr('thirdyear');
  formatNumber_pvirr('fourthyear');
  formatNumber_pvirr('fifthyear');
  formatNumber_pvirr('sixthyear');
  formatNumber_pvirr('seventhyear');
  formatNumber_pvirr('eigthyear');
  formatNumber_pvirr('ninthyear');
  formatNumber_pvirr('tenthyear');
  formatNumber_pvirr('eleventhyear');
  formatNumber_pvirr('twelthyear');
  formatNumber_pvirr('thirteenthyear');
  formatNumber_pvirr('fourteenthyear');
  formatNumber_pvirr('fifteenthyear');
  formatNumber_pvirr('Discounting');
  formatNumber_pvirr('Total');
  formatNumber_pvirr('Present');
  }
/*-------------------------------------------------------------------------*/
/*ReturnOnSavings*/
function ClearReturnOnSavings_retsave()
{
document.getElementById("TrTaxInflation").style.display="none";
document.getElementById("spnclear").style.display = "none";
}
function cl_calculate_retsave()                  
{
var CL_amount=document.form1.CL_amt.value;

var CL_t2=parseFloat(document.form1.CL_t2.value);
var CL_roi2=parseFloat(document.form1.CL_roi2.value)/100;
var CL_comp=parseFloat(document.form1.CL_comp.options[document.form1.CL_comp.options.selectedIndex].value);
if(CL_comp>0)
{
var CL_rt=Math.pow(1+CL_roi2/CL_comp,CL_comp);
var CL_income=CL_amount*CL_roi2/CL_comp
}
else
{
var CL_rt=Math.pow(1+CL_t2*CL_roi2,1/CL_t2);
var CL_income= CL_amount*CL_t2*CL_roi2
}
var CL_inc;
if(CL_comp<0)CL_inc=  "simple"
if(CL_comp==1)CL_inc=  "annual"
if(CL_comp==2)CL_inc=  "semi annual"
if(CL_comp==4)CL_inc=  "quarterly"
if(CL_comp==12)CL_inc= "monthly"

document.getElementById("CL_tframe").value=CL_inc;
document.getElementById("CL_inc").value=Math.round(CL_income);
document.getElementById("CL_irate").value=Math.round((CL_rt-1)*10000)/100;
document.getElementById("TrTaxInflation").style.display="inline";
document.getElementById("spnclear").style.display = "inline";
formatNumber('CL_inc');
}
var CL_viewHide;
if (document.layers) {
visible = 'show';
hidden = 'hide';
} else if (document.all) {
visible = 'visible';
hidden = 'hidden';
}
function cl_check_retsave(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function CL_display_retsave(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = visible;
}
function CL_hid_retsave(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = hidden;
}
function cl_validate_retsave(frm)
{
if(isNaN(parseFloat(frm.CL_amt.value))||parseFloat(frm.CL_amt.value)<=0)
{
	alert('Invested amount should be greater than 0');
	frm.CL_amt.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_t2.value))||parseFloat(frm.CL_t2.value)<=0)
{
	alert('The period should be greater than 0.');
	frm.CL_t2.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_roi2.value))||parseFloat(frm.CL_roi2.value)<=0)
{
	alert('Rate of interest should be greater than 0.');
	frm.CL_roi2.focus();
	return false;
}
return true;
}
/*-------------------------------------------------------------------------*/
/*SavingEnough*/
function ClearSavingEnough_saveeno()
  {
    document.getElementById("SavingEnoughResult").style.display = "none";
    document.getElementById("spnclear").style.display = "none";
  } 	
function cl_calculate_saveeno()
{
  var CL_current;
  var CL_roi;
  var CL_tenure;                 
  var CL_remain;
  var CL_fv;
  var CL_inf;
  var CL_tp;
  var CL_sav;
  var CL_age;
  var CL_ret;
  var CL_retamt;
  CL_age=parseFloat(document.form1.CL_age.value,10);
  CL_ret=parseFloat(document.form1.CL_ret.value,10);
  CL_retamt=parseFloat(document.form1.CL_retamt.value,10);
  CL_tenure=CL_ret-CL_age;
  if(CL_tenure<0)
  {
   alert('Retirement age should be more than your current age')
   return false;
  }
CL_current=parseFloat(document.form1.CL_current.value,10);
CL_roi=Math.pow(1+parseFloat(document.form1.CL_roi.value,10)/100,1/12)-1;
CL_roi1=parseFloat(document.form1.CL_roi.value,10)/100;
CL_inf=parseFloat(document.form1.CL_inf.value)/100;
CL_fv=CL_retamt*Math.pow(1+CL_inf,CL_tenure);
CL_remain=CL_fv-CL_current*Math.pow((1+CL_roi1),CL_tenure);
CL_msav=parseFloat(document.form1.CL_msav.value);
CL_tp=CL_msav*(Math.pow(1+CL_roi,CL_tenure*12)-1)/CL_roi;
if(isNaN(Math.round((CL_remain*CL_roi)/(Math.pow((1+CL_roi),CL_tenure*12)-1))))
{
	alert('One or more of the numeric fields is wrong. Please Check');
}
else
{
	if(document.layers)
	{
	document.getElementById("emi").value=Math.round((CL_remain*CL_roi)/(Math.pow((1+CL_roi),CL_tenure*12)-1));;
	document.getElementById("CL_fv").value=Math.round(CL_fv);
	document.getElementById("CL_current_answer").value=Math.round(CL_tp+CL_current*Math.pow((1+CL_roi1),CL_tenure));
	}
	else
	{
	document.getElementById("emi").value=Math.round((CL_remain*CL_roi)/(Math.pow((1+CL_roi),CL_tenure*12)-1));
	document.getElementById("CL_fv").value=Math.round(CL_fv);
	document.getElementById("CL_current_answer").value=Math.round(CL_tp+CL_current*Math.pow((1+CL_roi1),CL_tenure));
	}
	formatNumber('emi');
	formatNumber('CL_fv');
	formatNumber('CL_current_answer');
	document.getElementById("SavingEnoughResult").style.display="inline";
	document.getElementById("spnclear").style.display = "inline";
}
}
function cl_check_saveeno(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function cl_validate_saveeno(frm)
{
if(isNaN(parseFloat(frm.CL_age.value))||parseFloat(frm.CL_age.value)<=0)
{
alert('Your age should be greater than 0 years');
frm.CL_age.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_ret.value))||parseFloat(frm.CL_ret.value)<=parseFloat(frm.CL_age.value))
{
alert('Retirement age should be greater than your current age');
frm.CL_ret.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_current.value))||parseFloat(parseFloat(frm.CL_current.value))<0)
{
	alert('Your current savings should be greater than 0');
	frm.current.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_retamt.value))||parseFloat(parseFloat(frm.CL_retamt.value))<0)
{
	alert('Your retirement amount should be greater than or equal to 0');
	frm.CL_retamt.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_msav.value))||parseFloat(parseFloat(frm.CL_msav.value))<0)
{
	alert('Monthly savings should be greater than or equal to 0');
	frm.CL_msav.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_roi.value))||parseFloat(parseFloat(frm.CL_roi.value))<0)
{
	alert('Rate of return on your investment should be greater than 0');
	frm.CL_roi.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_inf.value))||parseFloat(parseFloat(frm.CL_inf.value))<0)
{
	alert('Rate of inflation should be greater than 0');
	frm.CL_inf.focus();
	return false;
}
return true;
}
/*-------------------------------------------------------------------------*/
/*SavingEnoughInner*/
function ClearSavingEnough_saveenouinner()
{
    document.getElementById("TrSavingEnough").style.display="none";
    document.getElementById("spnclear").style.display = "none";
}
function cl_calculate_saveenouinner()
{
  var CL_current;
  var CL_roi;
  var CL_tenure;                 
  var CL_remain;
  var CL_fv;
  var CL_inf;
  var CL_tp;
  var CL_sav;
  var CL_age;
  var CL_ret;
  var CL_retamt;
  CL_age=parseFloat(document.form1.CL_age.value,10);
  CL_ret=parseFloat(document.form1.CL_ret.value,10);
  CL_retamt=parseFloat(document.form1.CL_retamt.value,10);
  CL_tenure=CL_ret-CL_age;
  if(CL_tenure<0)
  {
   alert('Retirement age should be more than your current age')
   return false;
  }
CL_current=parseFloat(document.form1.CL_current.value,10);
CL_roi=Math.pow(1+parseFloat(document.form1.CL_roi.value,10)/100,1/12)-1;
CL_roi1=parseFloat(document.form1.CL_roi.value,10)/100;
CL_inf=parseFloat(document.form1.CL_inf.value)/100;
CL_fv=CL_retamt*Math.pow(1+CL_inf,CL_tenure);
CL_remain=CL_fv-CL_current*Math.pow((1+CL_roi1),CL_tenure);
CL_msav=parseFloat(document.form1.CL_msav.value);
CL_tp=CL_msav*(Math.pow(1+CL_roi,CL_tenure*12)-1)/CL_roi;
if(isNaN(Math.round((CL_remain*CL_roi)/(Math.pow((1+CL_roi),CL_tenure*12)-1))))
{
	alert('One or more of the numeric fields is wrong. Please Check');
}
else
{
	if(document.layers)
	{
	 document.getElementById("emi").value=Math.round((CL_remain*CL_roi)/(Math.pow((1+CL_roi),CL_tenure*12)-1));   
	 document.getElementById("CL_fv").value=Math.round(CL_fv);
	 document.getElementById("CL_current_value").value=Math.round(CL_tp+CL_current*Math.pow((1+CL_roi1),CL_tenure));
	}
	else
	{
	   document.getElementById("emi").value=Math.round((CL_remain*CL_roi)/(Math.pow((1+CL_roi),CL_tenure*12)-1));   
	   document.getElementById("CL_fv").value=Math.round(CL_fv);
	   document.getElementById("CL_current_value").value=Math.round(CL_tp+CL_current*Math.pow((1+CL_roi1),CL_tenure));
	}
	document.getElementById("spnclear").style.display = "inline";
	document.getElementById("emi").value=Math.round((CL_remain*CL_roi)/(Math.pow((1+CL_roi),CL_tenure*12)-1));   
	document.getElementById("CL_fv").value=Math.round(CL_fv);
	document.getElementById("CL_current_value").value=Math.round(CL_tp+CL_current*Math.pow((1+CL_roi1),CL_tenure));
	formatNumber('emi');
	formatNumber('CL_fv');
	formatNumber('CL_current_value');
}
}
var CL_viewHide;
if (document.layers) {
visible = 'show';
hidden = 'hide';
} else if (document.all) {
visible = 'visible';
hidden = 'hidden';
}
function cl_check_saveenouinner(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function CL_display_saveenouinner(viewShow)
{
if (document.layers) 
{
  content = document.layers[viewShow];
}
else if (document.all) 
{
content = document.all(viewShow).style;
}
content.visibility = visible;
}
function CL_hid_saveenouinner(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = hidden;
}
function cl_validate_saveenouinner(frm)
{
if(isNaN(parseFloat(frm.CL_age.value))||parseFloat(frm.CL_age.value)<=0)
{
alert('Your age should be greater than 0 years');
frm.CL_age.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_ret.value))||parseFloat(frm.CL_ret.value)<=parseFloat(frm.CL_age.value))
{
alert('Retirement age should be greater than your current age');
frm.CL_ret.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_current.value))||parseFloat(parseFloat(frm.CL_current.value))<0)
{
	alert('Your current savings should be greater than 0');
	frm.current.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_retamt.value))||parseFloat(parseFloat(frm.CL_retamt.value))<0)
{
	alert('Your retirement amount should be greater than or equal to 0');
	frm.CL_retamt.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_msav.value))||parseFloat(parseFloat(frm.CL_msav.value))<0)
{
	alert('Monthly savings should be greater than or equal to 0');
	frm.CL_msav.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_roi.value))||parseFloat(parseFloat(frm.CL_roi.value))<0)
{
	alert('Rate of return on your investment should be greater than 0');
	frm.CL_roi.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_inf.value))||parseFloat(parseFloat(frm.CL_inf.value))<0)
{
	alert('Rate of inflation should be greater than 0');
	frm.CL_inf.focus();
	return false;
}
document.getElementById("TrSavingEnough").style.display="inline";
return true;
}
/*-------------------------------------------------------------------------*/
/*SavingMillion*/
function ClearSavingMillion_savemill()
{
document.getElementById("SavingMillionResult").style.display="none";
document.getElementById("spnclear").style.display="none";
} 	
function cl_calculate_savemill()
{
var CL_current;
var CL_roi;                               
var CL_tenure;
var CL_remain;
CL_tenure=parseFloat(document.form1.CL_tenure.value,10);
CL_current=parseFloat(document.form1.CL_current.value,10);
CL_roi=Math.pow(1+parseFloat(document.form1.CL_roi.value,10)/100,1/12)-1;
if(CL_current>=1000000)
{
alert('Congratulations you are already a millionaire');
CL_hid_savemill('result');
CL_hid_savemill('explain');
return
}
CL_remain=1000000-CL_current*Math.pow((1+CL_roi),CL_tenure*12);
if(isNaN(Math.round((CL_remain*CL_roi)/(Math.pow((1+CL_roi),CL_tenure*12)-1))))
{
	alert('One or more of the numeric fields is wrong. Please Check');
}
else
{
    document.getElementById("SavingMillionResult").style.display="inline";
	if(document.layers)
	{
	    document.getElementById("cl_emi").value=Math.round((CL_remain*CL_roi)/(Math.pow((1+CL_roi),CL_tenure*12)-1));
	}
	else
	{
	    document.getElementById("CL_emi").value=Math.round((CL_remain*CL_roi)/(Math.pow((1+CL_roi),CL_tenure*12)-1));
	}
	formatNumber('cl_emi');
	document.getElementById("spnclear").style.display="inline";
}
}
function cl_check_savemill(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function CL_display_savemill(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = visible;
}
function CL_hid_savemill(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = hidden;
}
function cl_validate_savemill(frm)
{
if(isNaN(parseFloat(frm.CL_current.value))||parseFloat(frm.CL_current.value)<0)
{
	alert('Your savings should be greater than or equal to 0.');
	frm.CL_current.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_tenure.value))||parseFloat(frm.CL_tenure.value)<=0)
{
	alert('The period should be greater than 0.');
	frm.CL_tenure.focus();
	return false;
}
if(isNaN(parseFloat(frm.CL_roi.value))||parseFloat(frm.CL_roi.value)<=0)
{
	alert('Rate of interest should be greater than 0.');
	frm.CL_roi.focus();
	return false;
}
return true;
}
/*-------------------------------------------------------------------------*/
/*SavingsWorth*/
function ClearSavingsWorth_saveworth()
{
document.getElementById("TrSavingsWorth").style.display="none";
document.getElementById("spnclear").style.display = "none";
}
function cl_calculate_saveworth()
{
var CL_current;
var CL_roi;
var CL_tenure;                          
var CL_vl;
CL_tenure=parseFloat(document.form1.CL_time.value,10);
CL_current=parseFloat(document.form1.CL_current.value,10);
CL_roi=parseFloat(document.form1.CL_roi.value,10)/100;
CL_tax=parseFloat(document.form1.CL_tax.value,10)/100;
CL_roi=CL_roi*(1-CL_tax);
CL_mon=parseFloat(document.form1.CL_mon.value,10);
if (CL_roi==0) CL_roi=0.00000001;
CL_vl=CL_current*(Math.pow((1+CL_roi),CL_tenure));
CL_vl+=parseFloat(document.form1.CL_mon.value,10)*((Math.pow((1+CL_roi),CL_tenure)-1)/CL_roi);
if(isNaN(CL_vl))
{
	alert('One or more of the numeric fields are wrong. Please Check');
}
else
{
	document.getElementById("CL_emi").value=Math.round(CL_vl);
    formatNumber('CL_emi');
}
}
var CL_viewHide;
if (document.layers) {

} else if (document.all) {

}
function cl_check_saveworth(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function CL_display_saveworth(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
}
function CL_hid_saveworth(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = hidden;
}
function CL_vlidate_saveworth(frm)
{
if(isNaN(parseFloat(frm.CL_current.value))||parseFloat(frm.CL_current.value)<=0)
{
alert('Current Savings be greater than 0');
frm.CL_current.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_mon.value))||parseFloat(frm.CL_mon.value)<=0)
{
alert('Annual Savings be greater than 0');
frm.CL_mon.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_roi.value))||parseFloat(frm.CL_roi.value)<=0)
{
alert('Return on Investment should be greater than 0');
frm.CL_roi.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_time.value))||parseFloat(frm.CL_time.value)<=0)
{
alert('Investment horizon should be greater than 0');
frm.CL_time.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_current.value))||parseFloat(frm.CL_current.value)<0)
{
alert('Current savings should be greater than or equal to 0');
frm.CL_current.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_tax.value))||parseFloat(frm.CL_tax.value)<0)
{
//alert('Monthly savings should be greater than or equal to 0');
alert('Tax Rate %  should be greater than 0');
frm.CL_tax.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_roi.value))||parseFloat(frm.CL_roi.value)<0)
{
alert('Return on your investments should be greater than or equal to 0');
frm.CL_roi.focus();
return false;
}
document.getElementById("TrSavingsWorth").style.display="inline";
document.getElementById("spnclear").style.display = "inline";
return true;
}
/*-------------------------------------------------------------------------*/
/*SIPDelayCost*/
function formatNumber_sipdelay(id)
{                     
var obj = document.getElementById(id);
var num = new NumberFormat();
num.setInputDecimal('.');
num.setNumber(obj.value); // obj.value is '100000'
num.setPlaces('2', false);
num.setCurrencyValue('');
num.setCurrency(true);
num.setCurrencyPosition(num.LEFT_OUTSIDE);
num.setNegativeFormat(num.LEFT_DASH);                     
num.setNegativeRed(false);
num.setSeparators(true, ',', ',');
obj.value = num.toFormatted();     
}
function futurevalue_sipdelay(returnspercent,nper,PMT,pv,type)
{
 var rate = returnspercent/100;
 var fv;
 fv =(PMT*(1+rate*type)*(1- Math.pow(1+ rate,nper))/rate)-pv*Math.pow(1+rate,nper);
 return (fv);
} 
function hide_sipdelay()
{
  document.getElementById("hid").style.display="none";
  document.getElementById("spnclear").style.display = "none";
}
function show_sipdelay()
{
  document.getElementById("hid").style.display="inline";
  document.getElementById("spnclear").style.display = "inline";
} 
function calculate_sipdelay()
 {
   var cl_moninst = (document.form1.moninst.value);
   cl_moninst = cl_moninst.replace(/,/,"")
   var cl_tenure = (document.form1.tenure.value); 
   cl_tenure = cl_tenure.replace(/,/,"")
   var cl_rateofretun = (document.form1.rateofretun.value); 
   cl_rateofretun = cl_rateofretun.replace(/,/,"")
   var delay = (document.form1.delay.value); 
   delay = delay.replace(/,/,"")
   var A = (document.form1.tenure.value*12);
   var B = parseFloat(futurevalue_sipdelay(cl_rateofretun,1/12,0,-100,1)-100);
   var C = parseFloat(-futurevalue_sipdelay(B,A,cl_moninst,0,1));
   document.form1.invvaluetoday.value = Math.round(C);
   D = (A - delay);
   E = (-futurevalue_sipdelay(B,D,cl_moninst,0,1));
   document.form1.invvaluedelay.value = Math.round(E);
   document.form1.delaycost.value = Math.round(C-E);
   F = Math.round(Math.round(C-E)/Math.pow((1+0.06),cl_tenure));
   document.form1.lostmoney.value = (F); 
   formatNumber_sipdelay('moninst');
   formatNumber_sipdelay('rateofretun');
   formatNumber_sipdelay('invvaluetoday');
   formatNumber_sipdelay('invvaluedelay');
   formatNumber_sipdelay('delaycost');
   formatNumber_sipdelay('lostmoney');	    
 }
/*-------------------------------------------------------------------------*/
/*SIPNeedCalInner*/
var texttype
if (navigator.appName == "Microsoft Internet Explorer")
{
texttype="innerText";
}
else
{
texttype="textContent";
} 

function formatNumber_sipneedcalc(id)
{
var obj = document.getElementById(id);
var num = new NumberFormat();
num.setInputDecimal('.');
num.setNumber(obj.value); // obj.value is '100000'
num.setPlaces('2', false);
num.setCurrencyValue('');
num.setCurrency(true);
num.setCurrencyPosition(num.LEFT_OUTSIDE);
num.setNegativeFormat(num.LEFT_DASH);
num.setNegativeRed(false);
num.setSeparators(true, ',', ',');
obj.value = num.toFormatted();     
}
function replaceAll_sipneedcalc( str, replacements ) 
{
  for ( i = 0; i < replacements.length; i++ ) 
   {
    var idx = str.indexOf( replacements[i][0] );
    while ( idx > -1 ) 
	{
        str = str.replace( replacements[i][0], replacements[i][1] ); 
        idx = str.indexOf( replacements[i][0] );
    }
  }
 return str;
}
function Comma_sipneedcalc(number) 
{
 number = '' + number;
 if (number.length > 3) 
 {
    var mod = number.length % 3;
    var output = (mod > 0 ? (number.substring(0,mod)) : '');
    for (i=0 ; i < Math.floor(number.length / 3); i++) 
	{
      if ((mod == 0) && (i == 0))
      output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
      else 
      output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
   }
   return (output);
}
else return number;
}
function call_sipneedcalc()
{
  var texttype
     if (navigator.appName == "Microsoft Internet Explorer")
    {
        texttype="innerText";
    }
    else
    {
        texttype="textContent";
    } 
  var sip;
  sip= calculate1_sipneedcalc(eval('document.getElementById("t1").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip) 
  document.getElementById("r2t1").innerHTML = sip;
  sip= calculate1_sipneedcalc(eval('document.getElementById("t2").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip) 
  document.getElementById("r2t2").innerHTML = sip;
  sip= calculate1_sipneedcalc(eval('document.getElementById("t3").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip) 
  document.getElementById("r2t3").innerHTML = sip;
  sip= calculate1_sipneedcalc(eval('document.getElementById("t4").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip) 
  document.getElementById("r2t4").innerHTML = sip;
  sip= calculate1_sipneedcalc(eval('document.getElementById("t5").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip) 
  document.getElementById("r2t5").innerHTML = sip;
  sip= calculate1_sipneedcalc(eval('document.getElementById("t6").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip) 
  document.getElementById("r2t6").innerHTML = sip;
}
function call2_sipneedcalc()
{
  var sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t1").'+texttype),eval('document.getElementById("tab2r1t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip) 
  document.getElementById("tab2r1t1").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t2").'+texttype),eval('document.getElementById("tab2r1t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip) 
  document.getElementById("tab2r1t2").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t3").'+texttype),eval('document.getElementById("tab2r1t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip) 
  document.getElementById("tab2r1t3").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t4").'+texttype),eval('document.getElementById("tab2r1t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip) 
  document.getElementById("tab2r1t4").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t5").'+texttype),eval('document.getElementById("tab2r1t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip) 
  document.getElementById("tab2r1t5").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t6").'+texttype),eval('document.getElementById("tab2r1t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip) 
  document.getElementById("tab2r1t6").innerHTML = sip;
 //>>>>>>>>>>>>>>>>>>>>>>>>>>//
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t1").'+texttype),eval('document.getElementById("tab2r2t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip) 
  document.getElementById("tab2r2t1").innerHTML = sip;
  
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t2").'+texttype),eval('document.getElementById("tab2r2t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip) 
  document.getElementById("tab2r2t2").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t3").'+texttype),eval('document.getElementById("tab2r2t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip) 
  document.getElementById("tab2r2t3").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t4").'+texttype),eval('document.getElementById("tab2r2t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip) 
  document.getElementById("tab2r2t4").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t5").'+texttype),eval('document.getElementById("tab2r2t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip)  
  document.getElementById("tab2r2t5").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t6").'+texttype),eval('document.getElementById("tab2r2t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip)  
  document.getElementById("tab2r2t6").innerHTML = sip;
  //>>>>>>>>>>>>>>>>>>>
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t1").'+texttype),eval('document.getElementById("tab2r3t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip)  
  document.getElementById("tab2r3t1").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t2").'+texttype),eval('document.getElementById("tab2r3t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip)  
  document.getElementById("tab2r3t2").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t3").'+texttype),eval('document.getElementById("tab2r3t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip)  
  document.getElementById("tab2r3t3").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t4").'+texttype),eval('document.getElementById("tab2r3t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip)  
  document.getElementById("tab2r3t4").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t5").'+texttype),eval('document.getElementById("tab2r3t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip)  
  document.getElementById("tab2r3t5").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t6").'+texttype),eval('document.getElementById("tab2r3t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip)  
  document.getElementById("tab2r3t6").innerHTML = sip;
  //>>>>>>>>>>>>>>>>>>>>>>>>..
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t1").'+texttype),eval('document.getElementById("tab2r4t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip)  
  document.getElementById("tab2r4t1").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t2").'+texttype),eval('document.getElementById("tab2r4t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip)  
  document.getElementById("tab2r4t2").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t3").'+texttype),eval('document.getElementById("tab2r4t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip)  
  document.getElementById("tab2r4t3").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t4").'+texttype),eval('document.getElementById("tab2r4t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip)  
  document.getElementById("tab2r4t4").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t5").'+texttype),eval('document.getElementById("tab2r4t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip)  
  document.getElementById("tab2r4t5").innerHTML = sip;
  sip= calculate2_sipneedcalc(eval('document.getElementById("tab2t6").'+texttype),eval('document.getElementById("tab2r4t0").'+texttype));
  sip=Math.round(sip);
  sip = Comma_sipneedcalc(sip)  
  document.getElementById("tab2r4t6").innerHTML = sip;
  //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
}
function calculate2_sipneedcalc(tenure,returns)
{
  var cl_famt = 10000000;
  var A = (1+(returns/100))* (((Math.pow(1+(returns/100),tenure)-1)))/ ((1+(returns/100))-1);
  var B = (futurevalue_sipneedcalc(returns))-100;
  var C = (1+(B/100))* (((Math.pow(1+(B/100),12*tenure)-1)))/ ((1+(B/100))-1);
  var D = cl_famt/A;
  var cl_sipcalculated = cl_famt/C;
  return (cl_sipcalculated);
}
function futurevalue_sipneedcalc(returnspercent)
{
 var rate = returnspercent/100;
 var nper = 1/12;
 var PMT= 0;
 var pv = -100;
 var type = 1;
 var fv;
 fv =(PMT*(1+rate*type)*(1- Math.pow(1+ rate,nper))/rate)-pv*Math.pow(1+rate,nper);
 return (fv);
}
function calculate1_sipneedcalc(expretunvalue)
{
var cl_famt = document.form1.fvamt.value;
cl_famt = replaceAll_sipneedcalc(cl_famt,[[",",""]]);
var cl_tenure = document.form1.tenure.value;
var cl_growth = document.form1.growthrate.value; 
cl_growth = replaceAll_sipneedcalc(cl_growth,[[",",""]]);
if (cl_growth!=0) 
{ 
var A = Math.pow(1+(expretunvalue/100),cl_tenure);
var B = Math.pow(1+(cl_growth/100),cl_tenure);
var C = A - B;
var D = expretunvalue - cl_growth;
var E = C/(D/100);
var F = 1+(expretunvalue/100);
var G = E*F;
var H = cl_famt/G;
var cl_sipcalculated = H/12;
}
else
{
var A = (1+(expretunvalue/100))* (((Math.pow(1+(expretunvalue/100),cl_tenure)-1)))/ ((1+(expretunvalue/100))-1);
var B = (futurevalue_sipneedcalc(expretunvalue))-100;
var C = (1+(B/100))* (((Math.pow(1+(B/100),12*cl_tenure)-1)))/ ((1+(B/100))-1);
var D = cl_famt/A;
var cl_sipcalculated = cl_famt/C;
}
return cl_sipcalculated;	   
}
function calculate_sipneedcalc()
{
var cl_famt = document.form1.fvamt.value;
cl_famt = replaceAll_sipneedcalc(cl_famt,[[",",""]]);
var cl_tenure = document.form1.tenure.value;
var cl_growth = document.form1.growthrate.value;
cl_growth = replaceAll_sipneedcalc(cl_growth,[[",",""]]);
var cl_returns = document.form1.returns.value; 
cl_returns = replaceAll_sipneedcalc(cl_returns,[[",",""]]);
if (cl_growth!=0) 
{ 	 
var A = Math.pow(1+(cl_returns/100),cl_tenure);
var B = Math.pow(1+(cl_growth/100),cl_tenure);
var C = A - B;
var D = cl_returns - cl_growth;
var E = C/(D/100);
var F = 1+(cl_returns/100);
var G = E*F;
var H = cl_famt/G;
var cl_sipcalculated = H/12;
document.form1.sip.value= Math.round(cl_sipcalculated);
formatNumber_sipneedcalc('sip');
}
else
{
var A = (1+(cl_returns/100))* (((Math.pow(1+(cl_returns/100),cl_tenure)-1)))/ ((1+(cl_returns/100))-1);
var B = (futurevalue_sipneedcalc(cl_returns))-100;
var C = (1+(B/100))* (((Math.pow(1+(B/100),12*cl_tenure)-1)))/ ((1+(B/100))-1);
var D = cl_famt/A;
var cl_sipcalculated = cl_famt/C;
document.form1.sip.value= Math.round(cl_sipcalculated);		
formatNumber_sipneedcalc('sip');
}
}
function hide_sipneedcalc()
{
  document.getElementById("hid").style.display="none";
  document.getElementById("hid1").style.display="none";
  document.getElementById("hid2").style.display="none";
  document.getElementById("spnclear").style.display = "none";
}
function show_sipneedcalc()
{
  document.getElementById("hid").style.display="inline";
  document.getElementById("hid1").style.display="inline";
  document.getElementById("hid2").style.display="inline";
  document.getElementById("spnclear").style.display = "inline";
} 
/*-------------------------------------------------------------------------*/
/*SipNeedInner*/
function formatNumber_sipneedin(id)
{
var obj = document.getElementById(id);
var num = new NumberFormat();
num.setInputDecimal('.');
num.setNumber(obj.value); // obj.value is '100000'
num.setPlaces('2', false);                                
num.setCurrencyValue('');
num.setCurrency(true);
num.setCurrencyPosition(num.LEFT_OUTSIDE);
num.setNegativeFormat(num.LEFT_DASH);
num.setNegativeRed(false);
num.setSeparators(true, ',', ',');
obj.value = num.toFormatted();     
}
function futurevalue_sipneedin(returnspercent,nper,PMT,pv,type)
{
 var rate = returnspercent/100;
 var fv;
 fv =(PMT*(1+rate*type)*(1- Math.pow(1+ rate,nper))/rate)-pv*Math.pow(1+rate,nper);
 return (fv);
} 
function cl_calculate_sipneedin()
{
var cl_amtpermonth = (document.form1.amtpermonth.value);
cl_amtpermonth = cl_amtpermonth.replace(/,/,"");
var cl_tenure = (document.form1.tenure.value);
var cl_returns = (document.form1.returns.value); 
cl_returns =  cl_returns.replace(/,/,"");
if (cl_amtpermonth == "")
{
    alert("Enter the Investment Amount");
    document.form1.amtpermonth.focus();
}
else if(cl_tenure == "")
{
    alert("Enter the Investment Years");
    document.form1.tenure.focus();
}
else if(cl_returns == "")
{
    alert("Enter the Returns Expected");
    document.form1.returns.focus();
}
if(cl_amtpermonth != "" && cl_tenure != "" && cl_returns !="")
{
var fv = futurevalue_sipneedin(cl_returns,1/12,0,-100,1)-100;
var famt = Math.round(futurevalue_sipneedin(fv,cl_tenure*12,cl_amtpermonth,0,1)); 
document.form1.emi.value= -famt;
var famt1= (cl_tenure*12*cl_amtpermonth);
document.form1.CL_fv.value = famt1;
var finalvalue = -(famt/famt1) +'';
document.form1.CL_current.value= finalvalue.substring(0,4);	
formatNumber_sipneedin('amtpermonth');
formatNumber_sipneedin('returns');
formatNumber_sipneedin('emi');
formatNumber_sipneedin('CL_fv');
formatNumber_sipneedin('CL_current');
show_sipneedin();
}
}
function hide_sipneedin()
{
  document.getElementById("hid").style.display="none";
  document.getElementById("spnclear").style.display = "none";
}
function show_sipneedin()
{
  document.getElementById("hid").style.display="inline";
  document.getElementById("spnclear").style.display = "inline";
}
/*-------------------------------------------------------------------------*/
/*SIPPVFV*/
function formatNumber_sippvfv(id)
{
var obj = document.getElementById(id);
var num = new NumberFormat();
num.setInputDecimal('.');
num.setNumber(obj.value); // obj.value is '100000'
num.setPlaces('2', false);
num.setCurrencyValue('');                                   
num.setCurrency(true);
num.setCurrencyPosition(num.LEFT_OUTSIDE);
num.setNegativeFormat(num.LEFT_DASH);
num.setNegativeRed(false);
num.setSeparators(true, ',', ',');
obj.value = num.toFormatted();     
}
function futurevalue_sippvfv(returnspercent,nper,PMT,pv,type)
 {
   var rate = returnspercent/100;
   var fv;
   fv =(PMT*(1+rate*type)*(1- Math.pow(1+ rate,nper))/rate)-pv*Math.pow(1+rate,nper);
   return (fv);
 } 
function calculate_sippvfv()
{
var A = (document.form1.moninvest.value);
A = A.replace(/,/,"")
var B = (document.form1.tenure.value);
var C = (document.form1.returns.value);
C = C.replace(/,/,"")
var D = (document.form1.discounting.value);
D = D.replace(/,/,"")
var E = (futurevalue_sippvfv(C,1/12,0,-100,1)-100);
document.form1.futureval.value = Math.round(parseFloat(futurevalue_sippvfv(E,B*12,-A,0,1)))
document.form1.pval.value = Math.round(parseFloat(document.form1.futureval.value)/Math.pow(1+D/100,B)) 	    
formatNumber_sippvfv('moninvest');
formatNumber_sippvfv('returns');
formatNumber_sippvfv('discounting');
formatNumber_sippvfv('futureval');
formatNumber_sippvfv('pval');
}
function hide_sippvfv()
{
  document.getElementById("hid").style.display="none";
  document.getElementById("spnclear").style.display = "none";
}
function show_sippvfv()
{
  document.getElementById("hid").style.display="inline";
  document.getElementById("spnclear").style.display = "inline";
}
/*-------------------------------------------------------------------------*/
/*SIPTableInner*/
function formatNumber_siptab(id)                                       
{
var obj = document.getElementById(id);
var num = new NumberFormat();
num.setInputDecimal('.');
num.setNumber(obj.value); // obj.value is '100000'
num.setPlaces('2', false);
num.setCurrencyValue('');
num.setCurrency(true);
num.setCurrencyPosition(num.LEFT_OUTSIDE);
num.setNegativeFormat(num.LEFT_DASH);
num.setNegativeRed(false);
num.setSeparators(true, ',', ',');
obj.value = num.toFormatted();     
}
function Comma_siptab(number) 
{
 number = '' + number;
 if (number.length > 3) 
 {
    var mod = number.length % 3;
    var output = (mod > 0 ? (number.substring(0,mod)) : '');
    for (i=0 ; i < Math.floor(number.length / 3); i++) 
	{
      if ((mod == 0) && (i == 0))
      output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
      else 
      output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
   }
   return (output);
}
else return number;
}
function cl_call_siptab()
{
var texttype;
var emi;
var sipvalue = document.form1.sipamt.value;

if (navigator.appName == "Microsoft Internet Explorer")
{
    texttype="innerText";
}
else
{
    texttype="textContent";
} 
sipvalue = sipvalue.replace(/,/,"");
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t1").'+texttype),eval('document.getElementById("r1").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r1t1").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t2").'+texttype),eval('document.getElementById("r1").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r1t2").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t3").'+texttype),eval('document.getElementById("r1").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r1t3").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t4").'+texttype),eval('document.getElementById("r1").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r1t4").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t5").'+texttype),eval('document.getElementById("r1").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r1t5").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t6").'+texttype),eval('document.getElementById("r1").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r1t6").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t1").'+texttype),eval('document.getElementById("r2").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r2t1").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t2").'+texttype),eval('document.getElementById("r2").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r2t2").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t3").'+texttype),eval('document.getElementById("r2").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r2t3").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t4").'+texttype),eval('document.getElementById("r2").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r2t4").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t5").'+texttype),eval('document.getElementById("r2").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r2t5").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t6").'+texttype),eval('document.getElementById("r2").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r2t6").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t1").'+texttype),eval('document.getElementById("r3").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r3t1").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t2").'+texttype),eval('document.getElementById("r3").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r3t2").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t3").'+texttype),eval('document.getElementById("r3").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r3t3").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t4").'+texttype),eval('document.getElementById("r3").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r3t4").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t5").'+texttype),eval('document.getElementById("r3").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r3t5").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t6").'+texttype),eval('document.getElementById("r3").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r3t6").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t1").'+texttype),eval('document.getElementById("r4").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r4t1").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t2").'+texttype),eval('document.getElementById("r4").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r4t2").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t3").'+texttype),eval('document.getElementById("r4").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r4t3").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t4").'+texttype),eval('document.getElementById("r4").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r4t4").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t5").'+texttype),eval('document.getElementById("r4").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r4t5").innerHTML= emi;
emi = cl_calculate_siptab(sipvalue,eval('document.getElementById("t6").'+texttype),eval('document.getElementById("r4").'+texttype));
emi = Comma_siptab(emi)
document.getElementById("r4t6").innerHTML= emi;  
formatNumber_siptab('sipamt');
show_siptab();
}  
function cl_calculate_siptab(cl_amtpermonth,cl_tenure,cl_returns)
{   
 var rate = cl_returns/100;
 var nper = 1/12;
 var PMT= 0;
 var pv = -100;
 var type = 1;
 var fv;
 fv =(PMT*(1+rate*type)*(1- Math.pow(1+ rate,nper))/rate)-pv*Math.pow(1+rate,nper);
 fv = fv-100;
 var fv1=fv/100;
 var newtenure= cl_tenure*12;
 var newcl_amtpermonth =cl_amtpermonth;
 pv = 0;
 type =1;
 var famt= Math.round(newcl_amtpermonth*(1+fv1*type)*(1- Math.pow(1+fv1,newtenure))/fv1 - pv*Math.pow(1+fv1,newtenure));
 return (-famt);
}
function hide_siptab()
{
  document.getElementById("hid").style.display="none";
  document.getElementById("spnclear").style.display = "none";
}
function show_siptab()
{
  document.getElementById("hid").style.display="inline";
  document.getElementById("spnclear").style.display = "inline";
}
/*-------------------------------------------------------------------------*/
/*SpenLessandSave*/
function ClearSpendSave_spendsave()
{
    document.getElementById("TrSpendSaveResult").style.display="none";
    document.getElementById("spnclear").style.display = "none";
}
function cl_calculate_spendsave()
{
var CL_roi;                            
var CL_sav;
var CL_t=0;

if(document.form1.t1.value && !isNaN(parseFloat(document.form1.t1.value)))
{
CL_t+=parseFloat(document.form1.t1.value);
}
if(document.form1.t2.value && !isNaN(parseFloat(document.form1.t2.value)))
{
CL_t+=parseFloat(document.form1.t2.value);
}
if(document.form1.t3.value && !isNaN(parseFloat(document.form1.t3.value)))
{
CL_t+=parseFloat(document.form1.t3.value);
}
if(document.form1.t4.value && !isNaN(parseFloat(document.form1.t4.value)))
{
CL_t+=parseFloat(document.form1.t4.value);
}
if(document.form1.t5.value && !isNaN(parseFloat(document.form1.t5.value)))
{
CL_t+=parseFloat(document.form1.t5.value);
}
if(document.form1.t6.value && !isNaN(parseFloat(document.form1.t6.value)))
{
CL_t+=parseFloat(document.form1.t6.value);
}
if(document.form1.t7.value && !isNaN(parseFloat(document.form1.t7.value)))
{
CL_t+=parseFloat(document.form1.t7.value);
}
if(!document.form1.CL_roi.value || isNaN(document.form1.CL_roi.value))
{
alert('Enter your annual return');
document.form1.CL_roi.focus();
return false;
}
if(!document.form1.retage.value || isNaN(document.form1.retage.value))
{
alert('Enter your retirement age');
document.form1.retage.focus();
return false;
}
if(!document.form1.age.value || isNaN(document.form1.age.value))
{
alert('Enter your age');
document.form1.age.focus();
return false;
}
if(document.form1.age.value>document.form1.retage.value)
{
alert('It appears you have already retired');
return false;
}
var diff= parseFloat(document.form1.retage.value)- parseFloat(document.form1.age.value);
CL_roi=Math.pow(1+parseFloat(document.form1.CL_roi.value,10)/100,1/12)-1;
CL_roi=CL_roi+1;
CL_t=Math.round(CL_t*(Math.pow(CL_roi,diff*12)-1)/(CL_roi-1));
	if(document.layers)
	{
	    document.getElementById("emi").value=Math.round(CL_t);
	}
	else
	{
	    document.getElementById("emi").value=Math.round(CL_t);
	}
	formatNumber('emi');
}
function cl_check_spendsave(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
return false;
}
return true;
}
}
function CL_display_spendsave(viewShow) {
if (document.layers) {

} else if (document.all) {

}
}
function CL_hid_spendsave(viewShow) {
if (document.layers) {

} else if (document.all) {

}
}
function cl_validate_spendsave(frm)
{
document.getElementById("TrSpendSaveResult").style.display="inline";
document.getElementById("spnclear").style.display = "inline";
return true;
}
/*-------------------------------------------------------------------------*/
/*TaxFree*/
function ClearTaxFree_taxfree()
{
document.getElementById("TaxFreeresult").style.display="none"
document.getElementById("spnclear").style.display="none"
}
function cl_calculate_taxfree()
{                                          
var CL_amount=document.form1.amt.value;
var CL_t2=parseFloat(document.form1.CL_t2.value);
var CL_roi2=parseFloat(document.form1.CL_roi2.value)/100;
var CL_roi1=parseFloat(document.form1.CL_roi1.value)/100;
var CL_comp1=parseFloat(document.form1.CL_comp1.options[document.form1.CL_comp1.options.selectedIndex].value);
var CL_comp2=parseFloat(document.form1.CL_comp2.options[document.form1.CL_comp2.options.selectedIndex].value);
var CL_tax=parseFloat(document.getElementById("CL_tax").value)/100;
if(CL_amount == "")
{
alert("enter the amount");
document.form1.amt.focus();
return false;
}
if(CL_t2 == "")
{
alert("Enter the Tenure of investment years");
document.form1.CL_t2.focus();
return false;
}
if(CL_roi1 == "")
{
alert("Enter the Interest Earned");
document.form1.CL_roi1.focus();
return false;
}
if(CL_roi2 == "")
{
alert("Enter the Interest Earned");
document.form1.CL_roi2.focus();
return false;
}
if(CL_comp1>0)
{
var CL_rt1=Math.pow(1+CL_roi1/CL_comp1,CL_comp1);

var income1=CL_amount*CL_roi1/CL_comp1*(1-CL_tax)
}
else
{
var CL_rt1=Math.pow(1+CL_t2*CL_roi1,1/CL_t2);
var income1= CL_amount*CL_t2*CL_roi1*(1-CL_tax)
}
CL_rt1=(CL_rt1-1)*(1-CL_tax);

if(CL_comp2>0)
{
var CL_rt2=Math.pow(1+CL_roi2/CL_comp2,CL_comp2);
var CL_income2=CL_amount*CL_roi2/CL_comp2
}
else
{
var CL_rt2=Math.pow(1+CL_t2*CL_roi2,1/CL_t2);
var CL_income2= CL_amount*CL_t2*CL_roi2
}
if(CL_rt2-1>CL_rt1)
{
var CL_material1="Tax-Free";
}
else
{
var CL_material1="Taxed";
}
document.getElementById("CL_avn").value=CL_material1;
document.getElementById("CL_tax_result").value=Math.round((CL_rt1)*10000)/100;
document.getElementById("CL_ntax").value=Math.round((CL_rt2-1)*10000)/100;
document.getElementById("TaxFreeresult").style.display="inline"
}

var CL_viewHide;

function cl_check_taxfree(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function CL_display_taxfree(viewShow) {
document.getElementById("spnclear").style.display="inline"
}
function CL_hid_taxfree(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = hidden;
}
function cl_validate_taxfree(frm)
{
var CL_amount=document.form1.amt.value;
var CL_roi1=document.form1.CL_roi1.value;
var CL_roi2=document.form1.CL_roi2.value;
var CL_t2=document.form1.CL_t2.value;
var CL_tax=parseFloat(document.getElementById("CL_tax").value);

if(isNaN(CL_amount) || CL_amount< 0 || CL_amount == "")
{
alert('Investment amount should be greater than 0');
document.form1.amt.focus();
return false;
}
if(isNaN(CL_t2)||CL_t2<=0 || CL_t2 == "")
{
    alert('Tenure of Investment should be greater than 0');
    document.form1.CL_t2.focus();
    return false;
}
if(isNaN(CL_roi1)||CL_roi1<=0)
{
    alert('Interest earned should be greater than 0');
    document.form1.CL_roi1.focus();
    return false;
}
if(isNaN(CL_roi2)||CL_roi2<=0 || CL_roi2 == "" )
{
    alert('Interest earned should be greater than 0');
    document.form1.CL_roi2.focus();
    return false;
}
if(isNaN(CL_tax)||CL_tax<0||CL_tax>35||CL_tax=="")
{
    alert('Tax should be greater than 0 or less than 36');
    document.form1.CL_tax.focus();
    return false;
}
return true;
}
/*-------------------------------------------------------------------------*/
/*TaxInflation*/
function ClearTaxInflation_taxinf()
{
document.getElementById("TrTaxInflation").style.display="none";
document.getElementById("spnclear").style.display = "none";
}
function cl_calculate_taxinf()
{
var CL_fact=1;
var CL_current;
var CL_roi;
var CL_tenure;                            
var CL_vl;
var CL_type;
var CL_inf;
var CL_real;
CL_tenure=parseFloat(document.form1.CL_time.value,10);
CL_tenure*=CL_fact;
CL_current=parseFloat(document.form1.CL_current.value,10);
CL_roi=parseFloat(document.form1.CL_roi.value,10)/100;
CL_inf=parseFloat(document.form1.CL_inf.value,10)/100;
CL_tax=parseFloat(document.form1.CL_tax.value,10)/100;
CL_roi=CL_roi*(1-CL_tax);
CL_mon=parseFloat(document.form1.CL_mon.value,10);
if (CL_roi==0) CL_roi=0.00000001;
CL_roi=Math.pow((1+CL_roi),1/CL_fact)-1;
CL_vl=CL_current*(Math.pow((1+CL_roi),CL_tenure));
CL_vl+=parseFloat(document.form1.CL_mon.value,10)*((Math.pow((1+CL_roi),CL_tenure)-1)/CL_roi);
CL_real=CL_vl/Math.pow(1+CL_inf,CL_tenure/CL_fact);
if(isNaN(CL_vl))
{
	alert('One or more of the numeric fields are wrong. Please Check');
}
else
{
	document.getElementById("CL_emi").value=Math.round(CL_vl);
	document.getElementById("CL_real").value=Math.round(CL_real);
	document.getElementById("TrTaxInflation").style.display="inline";
	document.getElementById("spnclear").style.display = "inline";
	formatNumber('CL_emi');
	formatNumber('CL_real');
}
}
var CL_viewHide;
if (document.layers) {
visible = 'show';
hidden = 'hide';
} else if (document.all) {
visible = 'visible';
hidden = 'hidden';
}
function cl_check_taxinf(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function CL_display_taxinf(viewShow) {
if (document.layers) {

} else if (document.all) {

}
}
function CL_hid_taxinf(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
}
function CL_vlidate_taxinf(frm)
{
if(isNaN(parseFloat(frm.CL_time.value))||parseFloat(frm.CL_time.value)<=0)
{
alert('Investment horizon should be greater than 0');
frm.age.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_current.value))||parseFloat(frm.CL_current.value)<0)
{
alert('Current savings should be greater than or equal to 0');
frm.CL_current.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_tax.value))||parseFloat(frm.CL_tax.value)<0)
{
alert('Monthly savings should be greater than or equal to 0');
frm.CL_tax.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_roi.value))||parseFloat(frm.CL_roi.value)<0)
{
alert('Return on your investments should be greater than or equal to 0');
frm.CL_roi.focus();
return false;
}
return true;
}
/*-------------------------------------------------------------------------*/
/*TaxSaving*/
function calculate_taxsave()
{
var amount;
var yr
var mon;
var roi;
var tenure;
var reset;
var tax;
tenure=parseFloat(document.form1.tenure.value,10)*12;
amount=parseFloat(document.form1.amount.value,10);
yr=parseFloat(document.form1.yr.options[document.form1.yr.selectedIndex].value,10);
mon=parseFloat(document.form1.mon.options[document.form1.mon.selectedIndex].value,10);
roi=parseFloat(document.form1.roi.value,10)/1200;
reset=parseFloat(document.form1.reset.options[document.form1.reset.selectedIndex].value,10);
tax=parseFloat(document.form1.tax.value,10)/100;
var emi=(amount*12*roi*(Math.pow( (roi*reset+1),tenure/reset))) /((Math.pow((1+roi*reset),tenure/reset) - 1)*12);
var k=(1+roi*reset);
var n=0;
if( reset==12)
{

}
else
{
n=12- mon + 1
var p=amount;

}
var cyr=parseFloat(document.form1.yr.options[document.form1.yr.selectedIndex].text,10);
if(mon>9)
{
cyr-=1;
}
var interest=0;
var principal=0;
var cprincipal=0;
var cinterest=0;
var intr=0;
plast=p;
var bgc='';
document.write('<body bgcolor=#ffffff' + bgc + '>')
document.write('<P><TABLE border=1 cellPadding=1 cellSpacing=0 width=100%><TR><TD align=center><font face=verdana size=2><b>Year</b></font></TD><TD><font face=verdana size=2><b>Principal Paid</b></font></TD><TD><font face=verdana size=2><b>Interest Paid</b></font></TD><TD><font face=verdana size=2><b>Tax saved on Principal</b></font></TD><TD><font face=verdana size=2><b>Tax saved on Interest</b></font></TD><TD><font face=verdana size=2><b>Total Tax Saved</b></font></TD></TR>')
if(reset==1)
{
for(i=mon;i<13;i++)
{
if (interest<100000) interest+=p*(roi);
intr+=p*roi;
if (principal<20000) principal+=(emi-p*(roi));
p=p-(emi-p*(roi))
if(p<1) i=13

}
interest=Math.min(interest,100000);
principal=Math.min(principal,20000);
document.write('<TR><TD align=center><font face=verdana size=2>'+ cyr + '-' + Math.round(cyr+1) + '</font></TD><TD ><font face=verdana size=2>' + Math.round(plast-p) + '</font></TD><TD ><font face=verdana size=2>'+ Math.round(intr) + '</font></TD><TD ><font face=verdana size=2>'+ Math.round(principal*0.2) + '</font></TD><TD ><font face=verdana size=2>' +Math.round(interest*tax) + '</font></TD><TD ><font face=verdana size=2>'+ Math.round(principal*0.2 +interest*tax)+ '</font></TD></TR>')

plast=p;
cinterest+=interest;
cprincipal+=principal;
interest=0;
principal=0;
cyr+=1;
intr=0;
do
{
for(i=1;i<13;i++)
{

if (interest<100000) interest+=p*(roi);
intr+=p*roi;
if (principal<20000) principal+=(emi-p*(roi));
p=p-(emi-p*(roi))
if(p<1) i=13

}
interest=Math.min(interest,100000);
principal=Math.min(principal,20000);
document.write('<TR><TD align=center><font face=verdana size=2>'+ cyr + '-' + Math.round(cyr+1) + '</font></TD><TD ><font face=verdana size=2>' + Math.round(plast-p) + '</font></TD><TD ><font face=verdana size=2>'+ Math.round(intr) + '</font></TD><TD ><font face=verdana size=2>'+ Math.round(principal*0.2) + '</font></TD><TD ><font face=verdana size=2>' +Math.round(interest*tax) + '</font></TD><TD ><font face=verdana size=2>'+ Math.round(principal*0.2 +interest*tax)+ '</font></TD></TR>')

plast=p;
cinterest+=interest;
cprincipal+=principal;
interest=0;
principal=0;
cyr+=1;
intr=0;
} while(p>1)
document.write('</table>')
}
else
{
var plast=amount;
n=12;
var p=amount*Math.pow(k,n/reset)-(emi*reset)*(Math.pow(k,n/reset)-1)/(k-1);
var pemi=0;
if((plast-p)!=0) 
{
pemi=(plast-p)/12;
}
var iemi=emi-pemi
var prin=0;
for(i=mon;i<13;i++)
{
	if (interest<100000) interest+=iemi;
	intr+=iemi;
	if (principal<20000) principal+=pemi;
	prin+=pemi;
}
interest=Math.min(interest,100000);
principal=Math.min(principal,20000);
document.write('<TR><TD align=center><font face=verdana size=2>'+ cyr + '-' + Math.round(cyr+1) + '</font></TD><TD ><font face=verdana size=2>' + Math.round(prin) + '</font></TD><TD ><font face=verdana size=2>'+ Math.round(intr) + '</font></TD><TD ><font face=verdana size=2>'+ Math.round(principal*0.2) + '</font></TD><TD ><font face=verdana size=2>' +Math.round(interest*tax) + '</font></TD><TD ><font face=verdana size=2>'+ Math.round(principal*0.2 +interest*tax)+ '</font></TD></TR>')
cinterest+=interest;
cprincipal+=principal;
interest=0;
principal=0;
cyr+=1;
intr=0;
prin=0;

do
{
for(i=1;i<mon;i++)
{
if (interest<100000) interest+=iemi;
intr+=iemi;
if (principal<20000) principal+=pemi;
prin+=pemi;
if(p<1) i=13

}
interest=Math.min(interest,100000);
principal=Math.min(principal,20000);
plast=p
n+=12;
p=amount*Math.pow(k,n/reset)-(emi*reset)*(Math.pow(k,n/reset)-1)/(k-1);
pemi=(plast-p)/12
iemi=emi-pemi

if(plast>10)
{

	for(i=mon;i<13;i++)
	{
	if (interest<100000) interest+=iemi;
	intr+=iemi;
	if (principal<20000) principal+=pemi;
	prin+=pemi;
	}
}
interest=Math.min(interest,100000);
principal=Math.min(principal,20000);
document.write('<TR><TD align=center><font face=verdana size=2>'+ cyr + '-' + Math.round(cyr+1) + '</font></TD><TD ><font face=verdana size=2>' + Math.round(prin) + '</font></TD><TD ><font face=verdana size=2>'+ Math.round(intr) + '</font></TD><TD ><font face=verdana size=2>'+ Math.round(principal*0.2) + '</font></TD><TD ><font face=verdana size=2>' +Math.round(interest*tax) + '</font></TD><TD ><font face=verdana size=2>'+ Math.round(principal*0.2 +interest*tax)+ '</font></TD></TR>')

cinterest+=interest;
cprincipal+=principal;
interest=0;
principal=0;
cyr+=1;
intr=0;
prin=0;
} while(p>1)

if(mon>1)
{
for(i=1;i<mon;i++)
{
if (interest<100000) interest+=iemi;
intr+=iemi;
if (principal<20000) principal+=pemi;
prin+=pemi;
}
interest=Math.min(interest,100000);
principal=Math.min(principal,20000);
cinterest+=interest;
cprincipal+=principal;
document.write('<TR><TD align=center><font face=verdana size=2>'+ cyr + '-' + Math.round(cyr+1) + '</font></TD><TD ><font face=verdana size=2>' + Math.round(prin) + '</font></TD><TD ><font face=verdana size=2>'+ Math.round(intr) + '</font></TD><TD ><font face=verdana size=2>'+ Math.round(principal*0.2) + '</font></TD><TD ><font face=verdana size=2>' +Math.round(interest*tax) + '</font></TD><TD ><font face=verdana size=2>'+ Math.round(principal*0.2 +interest*tax)+ '</font></TD></TR>')
}
document.write('</table>')
document.write('<table><tr><td><font face=verdana size=2><b>Total Tax Saving: Rs. '+Math.round(cprincipal*0.2+cinterest*tax)+'<b></td></tr></table>')
}
}

var viewHide;
if (document.layers) {
visible = 'show';
hidden = 'hide';
} else if (document.all) {
visible = 'visible';
hidden = 'hidden';
}
function check_taxsave(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function display_taxsave(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
}
}
function validate_taxsave(frm)
{
if(!frm.amount.value||parseFloat(frm.amount)<=0)
{
	alert('Loan amount should be greater than 0');
	frm.amount.focus();
	return false;
}
if(!frm.tenure.value||parseFloat(frm.tenure.value)<=0)
{
	alert('Tenure should be greater than 0');
	frm.tenure.focus();
	return false;
}
if(!frm.roi.value||parseFloat(frm.roi.value)<=0)
{
	alert('Rate of interest should be greater than 0');
	frm.roi.focus();
	return false;
}
if(!frm.tax.value||parseFloat(frm.tax.value)<0||parseFloat(frm.tax.value)>36)
{
	alert('Tax Rate of interest should be between 0 and 35');
	frm.roi.focus();
	return false;
}
return true;
}
/*-------------------------------------------------------------------------*/
/*WealthRetirementInner*/
function ClearWealthRetire_wealthret()
{
document.getElementById("TrWealthRetire").style.display="none";
document.getElementById("spnclear").style.display = "none";
}
function cl_calculate_wealthret()
{                                      
var CL_current;
var CL_roi;
var CL_tenure;
var CL_vl;

CL_tenure=(parseFloat(document.form1.ret.value,10)-parseFloat(document.form1.age.value,10));
CL_current=parseFloat(document.form1.CL_current.value,10);
CL_roi=Math.pow(parseFloat(document.form1.CL_roi.value,10)/100 +1,1/12)-1;
if (CL_roi==0) CL_roi=0.00000001;
CL_vl=CL_current*Math.pow((1+CL_roi*12),CL_tenure);
CL_vl+=parseFloat(document.form1.CL_mon.value,10)*((Math.pow((1+CL_roi),CL_tenure*12)-1)/CL_roi);
if(isNaN(CL_vl))
{
	alert('One or more of the numeric fields are wrong. Please Check');
}
else
{
	if(document.all)
	{
	    document.getElementById("CL_emi").value = Math.round(CL_vl);
	}
	if(document.layers)
	{
	    document.getElementById("CL_emi").value = Math.round(CL_vl);
	}
	document.getElementById("CL_emi").value = Math.round(CL_vl);
	document.getElementById("spnclear").style.display = "inline";
	formatNumber('CL_emi');
}
}
var CL_viewHide;
if (document.layers) {
visible = 'show';
hidden = 'hide';
} else if (document.all) {
visible = 'visible';
hidden = 'hidden';
}
function cl_check_wealthret(fld,typ)
{
if(typ=="int")
{
if(isNaN(fld.value))
{
alert('Please enter a Number in the given field');
fld.focus();
}
}
}
function CL_display_wealthret(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = visible;
}
function CL_hid_wealthret(viewShow) {
if (document.layers) {
content = document.layers[viewShow];
} else if (document.all) {
content = document.all(viewShow).style;
}
content.visibility = hidden;
}
function CL_vlidate_wealthret(frm)
{
if(isNaN(parseFloat(frm.age.value))||parseFloat(frm.age.value)<=0)
{
alert('Your age should be greater than 0');
frm.age.focus();
return false;
}
if(isNaN(parseFloat(frm.ret.value))||parseFloat(frm.ret.value)<=parseFloat(frm.age.value))
{
alert('Your retirement age should be greater than your present age');
frm.ret.focus();
return false;
}
if(isNaN(parseFloat(frm.ret.value))||parseFloat(frm.ret.value)<=parseFloat(frm.age.value))
{
alert('Your retirement age should be greater than your present age');
frm.ret.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_current.value))||parseFloat(frm.CL_current.value)<0)
{
alert('Current savings should be greater than or equal to 0');
frm.CL_current.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_mon.value))||parseFloat(frm.CL_mon.value)<0)
{
alert('Monthly savings should be greater than or equal to 0');
frm.CL_mon.focus();
return false;
}
if(isNaN(parseFloat(frm.CL_roi.value))||parseFloat(frm.CL_roi.value)<0)
{
alert('Return on your investments should be greater than or equal to 0');
frm.CL_roi.focus();
return false;
}
document.getElementById("TrWealthRetire").style.display="inline";
return true;
}

