MonNonInfExp='';
MonInfExp='';
MonPerExp='';
MonFamInc='';
MonFamSav='';

//not in table
MonFamFixInc='';
InvRetRate=''
//


RiskTol='';
RiskCap='';
TaxRate='';
MonHsExp='';
MonHsAcc='';
MonEntTrv='';
MonGoods='';
MonVac='';
MonOthr1='';
MonOthr2='';
MonOthr3='';
MonCarLoan='';
MonHsLoan='';
MonLoan1='';
MonLoan2='';
MonLoan3='';

RetInvRetRate='12';
RetTaxRate='';
CurAge='';
RetAge='';
InfPer=100;
NonInfPer=0;
RetIncPer='';


function getData()
{

frmobj= document.mycost;

if(CurAge!='undefined')
{
frmobj.txtCurAge.value=CurAge;
frmobj.txtRetAge.value=RetAge;
frmobj.txtInfExp.value=MonInfExp;
frmobj.txtNonInfExp.value=MonNonInfExp;
frmobj.txtInfPer.value=InfPer;
frmobj.txtNonInfPer.value=NonInfPer;


}


}


function putData()
{
frmobj= document.mycost;
frameobj=parent.frames.datacontainer;

CurAge=frmobj.txtCurAge.value;
RetAge=frmobj.txtRetAge.value;
MonInfExp=frmobj.txtInfExp.value;
MonNonInfExp=frmobj.txtNonInfExp.value;
InfPer=frmobj.txtInfPer.value;
NonInfPer=frmobj.txtNonInfPer.value;


}

function getRetYear()
{
var frmobj;
frmobj= document.mycost;
currDate= new Date();
currYear=currDate.getFullYear();
frmobj.txtYear.value=currYear+(frmobj.txtRetAge.value-frmobj.txtCurAge.value)
frmobj.txtYear1.value=frmobj.txtYear.value

}

function getFutAdExp()
{
var frmobj;
frmobj= document.mycost;

//frmobj.txtFutAdExp.value=getPureNumber(frmobj.txtMonFutExp.value)-(frmobj.txtMonRet1.value*1)-(frmobj.txtMonRet2.value*1);
frmobj.txtFutAdExp.value=(getPureNumber(frmobj.txtMonFutExp.value)*(1-(frmobj.txtRetIncPer.value*0.01)));

if(!isNaN(frmobj.txtFutAdExp.value))

{

frmobj.txtFutAdExp.value=format(frmobj.txtFutAdExp.value,'currency');

//gFutAdExp = format(frmobj.txtFutAdExp.value,'currency');


//dispstr="<br><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"72\"><tr>";
//dispstr=dispstr+"<td bgcolor=\"white\"  height=\"16\" valign=\"bottom\" colspan=2 align=\"left\" width=2px><img src=\"/images/insurance/tl_responsecurve.gif\"></td>";
//dispstr=dispstr+"<td width=\"100%\" height=\"16\"><img src=\"/images/insurance/response.gif\"></td>";
//dispstr=dispstr+"<td height=\"16\"></td></tr><tr>";
//dispstr=dispstr+"<td bgcolor=\"#fb9c46\" width=\"2px\" colspan=3 height=\"3\"><img src=\"/images/common/blank.gif\" width=\"5px\"></td>";
//dispstr=dispstr+"<td bgcolor=\"#fb9c46\" width=\"2px\" rowspan=3 height=\"56\"><img src=\"/images/common/blank.gif\" width=\"1px\"></td>";
//dispstr=dispstr+"</tr><tr><td bgcolor=\"#fb9c46\" width=\"1px\" height=\"34\"><font size=\"2\" face=\"Arial\"><img src=\"/images/common/blank.gif\" width=\"1px\"></font></td>";
//dispstr=dispstr+"<td bgcolor=\"#ffffff\" height=\"34\"><font size=\"2\" face=\"Arial\">&nbsp;&nbsp;</font></td>";
//dispstr=dispstr+"<td bgcolor=\"#ffffff\" width=\"99%\" width=\"99%\" height=\"34\" class=\"cl5\">";

//dispstr=dispstr+"<img src='images/blank.gif' height=5px width=1px><br><b>Answer:</b>&nbsp;In addition to your other income, you will require<b> Rs "+frmobj.txtFutAdExp.value+ "</b>&nbsp;from investment income to pay for your monthly expenses in your year of retirement.";
dispstr="Answer:&nbsp;In addition to your other income, you will require<span  style=\"color:#ff6600;\"><b> Rs "+frmobj.txtFutAdExp.value+ "</b></span>&nbsp;from investment income to pay for your monthly expenses in your year of retirement.";
//dispstr=dispstr+"</font></td></tr><tr><td bgcolor=\"#fb9c46\" width=\"1px\" ><img src=\"/images/common/blank.gif\" width=\"1px\"></td>";
//dispstr=dispstr+"<td bgcolor=\"#fb9c46\" width=\"1px\" colspan=3 ><img src=\"/images/common/blank.gif\" width=\"1px\"></td>";
//dispstr=dispstr+"</tr>";
//dispstr=dispstr+"<tr><td colspan=3><font class=cl5>This is the requirement in your retirement year. With inflation, you will need that much more (compounded) in following years.</font></td></tr></table>";
dispstr=dispstr+"<br><br>This is the requirement in your retirement year. With inflation, you will need that much more (compounded) in following years.";



if(frmobj.txtRetIncPer.value !=""){
	document.getElementById("ansdiv4").innerHTML=dispstr;
	document.getElementById("ansdiv4").style.visibility='visible';

}else{
	document.getElementById("ansdiv").innerHTML=dispstr;
	document.getElementById("ansdiv").style.visibility='visible';


}


document.getElementById("middleblock").style.visibility='hidden';
document.getElementById("middleblock1").style.visibility='hidden';
document.getElementById("middleblock2").style.visibility='visible';



}
else
{

alert("Input values are inappropriate.");
frmobj.txtFutAdExp.value='';
}
}





function getPriorRetWel()
{
var frmobj;
frmobj= document.getElementById("mycost");

tempFutAdExp=getPureNumber(frmobj.txtFutAdExp.value);

C12=frmobj.txtNonInfExp.value*1;
C17=frmobj.txtNonInfPer.value*0.01;
B34=tempFutAdExp;
B40=frmobj.txtAnuRet.value*0.01;
B42=frmobj.txtTaxRate.value*0.01;
B44=frmobj.txtAnuInf.value*0.01;

frmobj.txtWel.value=(B34-C12*C17)/(B40*(1-B42)-B44)*12+(C12*C17)/(B40*(1-B42))*12;

if(isNaN(frmobj.txtWel.value))
{
alert('Input values are inappropriate.');
frmobj.txtWel.value='';
}
else
{


frmobj.txtWel.value=format(frmobj.txtWel.value,'currency');

//dispstr="<br><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"72\"><tr>";
//dispstr=dispstr+"<td bgcolor=\"white\"  height=\"16\" valign=\"bottom\" colspan=2 align=\"left\" width=2px><img src=\"/images/insurance/tl_responsecurve.gif\"></td>";
//dispstr=dispstr+"<td width=\"100%\" height=\"16\"><img src=\"/images/insurance/response.gif\"></td>";
//dispstr=dispstr+"<td height=\"16\"></td></tr><tr>";
//dispstr=dispstr+"<td bgcolor=\"#fb9c46\" width=\"2px\" colspan=3 height=\"3\"><img src=\"/images/common/blank.gif\" width=\"5px\"></td>";
//dispstr=dispstr+"<td bgcolor=\"#fb9c46\" width=\"2px\" rowspan=3 height=\"56\"><img src=\"/images/common/blank.gif\" width=\"1px\"></td>";
//dispstr=dispstr+"</tr><tr><td bgcolor=\"#fb9c46\" width=\"1px\" height=\"34\"><font size=\"2\" face=\"Arial\"><img src=\"/images/common/blank.gif\" width=\"1px\"></font></td>";
//dispstr=dispstr+"<td bgcolor=\"#ffffff\" height=\"34\"><font size=\"2\" face=\"Arial\">&nbsp;&nbsp;</font></td>";
//dispstr=dispstr+"<td bgcolor=\"#ffffff\" width=\"99%\" width=\"99%\" height=\"34\" class=\"cl5\">";
//dispstr=dispstr+"<img src='images/blank.gif' height=5px width=1px><br><b>Answer:</b>&nbsp;You require <b> Rs "+frmobj.txtWel.value+ "</b>&nbsp;in financial wealth by the time you are retired to fund your retirement expenses";
dispstr="You require <span  style=\"color:#ff6600;\"><b> Rs "+frmobj.txtWel.value+ "</b></span>&nbsp;in financial wealth by the time you are retired to fund your retirement expenses";
//dispstr=dispstr+"</font></td></tr><tr><td bgcolor=\"#fb9c46\" width=\"1px\" ><img src=\"/images/common/blank.gif\" width=\"1px\"></td>";
//dispstr=dispstr+"<td bgcolor=\"#fb9c46\" width=\"1px\" colspan=3 ><img src=\"/images/common/blank.gif\" width=\"1px\"></td>";
//dispstr=dispstr+"</tr></table><br>";


document.getElementById("ansdiv2").innerHTML=dispstr;
document.getElementById("ansdiv2").style.visibility='visible';
//document.getElementById("ansdiv").innerHTML=dispstr; // comentted 22 oct
document.getElementById("ansdiv").style.visibility='hidden';
document.getElementById("middleblock").style.visibility='hidden';
document.getElementById("middleblock1").style.visibility='hidden';
document.getElementById("middleblock2").style.visibility='hidden';
document.getElementById("middleblock3").style.visibility='visible';
document.getElementById("bkbt").style.visibility='visible';



}


drawSavingsPlan();

}




function callAssetAllocater()
{
document.mycost.action="assetallocater.asp";
document.mycost.submit();
}


function showOptional()
{
	if(document.layers)
	{
		return;

	}

	if(document.all)
	{
	spanObj1=document.all.lifeEx.style;
	spanObj2=document.all.saveRate.style;
	show="visible";
	hide="hidden"
	
	obj=document.mycost.radFunStyle;

		if(obj[0].checked)
		{
		document.mycost.txtOptional.size=2;
		spanObj1.visibility=show;
		spanObj2.visibility=hide;
		document.mycost.txtOptional.style.visibility='visible';
		document.mycost.txtOptional.value='00';
		}
		if(obj[1].checked)
		{
		spanObj1.visibility=hide;
		spanObj2.visibility=hide;


		document.mycost.txtOptional.size=1;
		document.mycost.txtOptional.value='';
		document.mycost.txtOptional.style.visibility='hidden';
		}
		if(obj[2].checked)
		{
		document.mycost.txtOptional.size=3;
		spanObj1.visibility=hide;
		spanObj2.visibility=show;
		document.mycost.txtOptional.style.visibility='visible';		
		document.mycost.txtOptional.value='00';
		
		}
	}

}


function checkTaxRate()
{
frmobj=document.mycost;

tempval=frmobj.txtTaxRate.value;
if(tempval>33)
{
frmobj.txtTaxRate.value=33;
}
if(tempval<0)
{
frmobj.txtTaxRate.value=0;
}
}

function checkInfRate()
{
frmobj=document.mycost;

tempInfRate=frmobj.txtAnuInf.value*1;

tempRet=frmobj.txtAnuRet.value*1;

tempTax=frmobj.txtTaxRate.value*0.01;

if(tempInfRate>=tempRet*(1-tempTax))
{

tempInfRate=(tempRet*(1-tempTax))-0.5;

}

if(tempInfRate<0)
{
frmobj.txtAnuInf.value=0;

}
else
{
frmobj.txtAnuInf.value=tempInfRate;
}

}




function getFutExp()
{
	C7=(document.mycost.txtInfExp.value*1); 

	C8=(document.mycost.txtNonInfExp.value*1); 
	C12=(document.mycost.txtInfPer.value*0.01);	
	C13=(document.mycost.txtNonInfPer.value*0.01);
	currdate= new Date();
	currYear=currdate.getFullYear();	
			
	testYear=document.mycost.txtYear1.value*1;
	diffYears=eval(testYear)-eval(currYear);
	
	var obj;

	obj=document.mycost.selAnuInf.options;
		for(i=0;i < obj.length;i++)
		{
			if(obj[i].selected)
			{E15=(obj[i].value*1);break;} 
		}


MonFutExp=(((C7*C12)*Math.pow((1+(E15*.01)),(diffYears)))+(C8*C13));



//alert("testYear="+testYear);
//alert("currdate="+currdate);
//alert("c18="+C8);
//alert("c13="+C13);
//alert("Diffyears="+diffYears);
//alert("E15="+E15);
//alert("c12="+C12);


//alert("c7="+C7);
//alert("MonFutExp"+MonFutExp);

	
if(isNaN(MonFutExp))
{
alert('Input values are inappropriate.');
//alert('paresh'+diffYears+'mongia');
}
else
{
document.mycost.txtMonFutExp.value=format(MonFutExp,'currency');

gMonFutExp=format(MonFutExp,'currency');

//dispstr="<br><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"72\"><tr>";
//dispstr=dispstr+"<td bgcolor=\"white\"  height=\"16\" valign=\"bottom\" colspan=2 align=\"left\" width=2px><img src=\"/images/insurance/tl_responsecurve.gif\"></td>";
//dispstr=dispstr+"<td width=\"100%\" height=\"16\"><img src=\"/images/insurance/response.gif\"></td>";
//dispstr=dispstr+"<td height=\"16\"></td></tr><tr>";
//dispstr=dispstr+"<td bgcolor=\"#fb9c46\" width=\"2px\" colspan=3 height=\"3\"><img src=\"/images/common/blank.gif\" width=\"5px\"></td>";
//dispstr=dispstr+"<td bgcolor=\"#fb9c46\" width=\"2px\" rowspan=3 height=\"56\"><img src=\"/images/common/blank.gif\" width=\"1px\"></td>";
//dispstr=dispstr+"</tr><tr><td bgcolor=\"#fb9c46\" width=\"1px\" height=\"34\"><font size=\"2\" face=\"Arial\"><img src=\"/images/common/blank.gif\" width=\"1px\"></font></td>";
//dispstr=dispstr+"<td bgcolor=\"#ffffff\" height=\"34\"><font size=\"2\" face=\"Arial\">&nbsp;&nbsp;</font></td>";
//dispstr=dispstr+"<td bgcolor=\"#ffffff\" width=\"99%\" width=\"99%\" height=\"34\" class=\"tim\">";
//dispstr=dispstr+"<img src='images/blank.gif' height=5px width=1px><br><font class=cl5><b>Answer:</b>&nbsp;You will need <b>Rs "+gMonFutExp+ "</b>&nbsp;per month for your expenses in the year you retire.<br><font class=cl5>This amount relates only to the retirement year. Inflation will increase this considerably in each of the following years.</font>";


dispstr="Answer:</b>&nbsp;You will need <span  style=\"color:#ff6600;\"><b>Rs "+gMonFutExp+ "</b></span>&nbsp;per month for your expenses in the year you retire.<br>This amount relates only to the retirement year. Inflation will increase this considerably in each of the following years.";
//dispstr=dispstr+"</font></td></tr><tr><td bgcolor=\"#fb9c46\" width=\"1px\" ><img src=\"/images/common/blank.gif\" width=\"1px\"></td>";
//dispstr=dispstr+"<td bgcolor=\"#fb9c46\" width=\"1px\" colspan=3 ><img src=\"/images/common/blank.gif\" width=\"1px\"></td>";
//dispstr=dispstr+"</tr></table>";
//dispstr=dispstr+"";


document.getElementById("ansdiv").innerHTML=dispstr;
document.getElementById("ansdiv").style.visibility='visible';
document.getElementById("middleblock").style.visibility='hidden';
document.getElementById("middleblock1").style.visibility='visible';
document.getElementById("bkbt").style.visibility='visible';



}

}


function getTotExp()
{
document.mycost.txtTotExp.value=(document.mycost.txtNonInfExp.value*1)
+(document.mycost.txtInfExp.value*1);
}


function checkYear()
{
currdate=new Date();
currYear=currdate.getFullYear();

testYear=document.mycost.txtYear.value*1;

if((testYear-currYear)>100)
{alert("Enter a year which is less than 100 years From Now");
return;
}
else
{
document.mycost.txtYear1.value=testYear;
document.mycost.txtYear2.value=testYear;
}
}


function drawSavingsPlan()
{
frmobj= document.mycost;

frmobj.txtCurAge1.value=frmobj.txtCurAge.value;
frmobj.txtRetAge1.value=frmobj.txtRetAge.value;
frmobj.txtRetInfExp.value=frmobj.txtInfExp.value*frmobj.txtInfPer.value*0.01;
frmobj.txtRetNonInfExp.value=frmobj.txtNonInfExp.value*frmobj.txtNonInfPer.value*0.01;
frmobj.txtInfRate1.value=frmobj.selAnuInf.value;
frmobj.txtInfRate2.value=frmobj.txtAnuInf.value;
frmobj.txtPerMet.value=frmobj.txtRetIncPer.value;
frmobj.txtAnuRet1.value=frmobj.txtAnuRet.value;
frmobj.txtFund.value='';
frmobj.txtEstMonSav.value='';

}


function getMonSavPlan()
{
K=frmobj.txtFund.value*1;
R=frmobj.txtAnuRet1.value*0.01;
n=(frmobj.txtRetAge1.value-frmobj.txtCurAge1.value)*12;
A=getPureNumber(frmobj.txtWel.value);


firstStep=Math.pow((1+R),(n/12));

secondStep=firstStep*K;
thirdStep=A-secondStep;
fourthStep=thirdStep/(firstStep-1);
fifthStep=(Math.pow((1+R),(1/12))-1);
sixthStep=fourthStep*fifthStep;

flag=0

if(sixthStep<=0)
{
alert("you don't need to have monthly contributions");
flag=1;


/*dispstr="<br><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"72\"><tr>";
dispstr=dispstr+"<td bgcolor=\"white\"  height=\"16\" valign=\"bottom\" colspan=2 align=\"left\" width=2px><img src=\"/images/insurance/tl_responsecurve.gif\"></td>";
dispstr=dispstr+"<td width=\"100%\" height=\"16\"><img src=\"/images/insurance/response.gif\"></td>";
dispstr=dispstr+"<td height=\"16\"></td></tr><tr>";
dispstr=dispstr+"<td bgcolor=\"#fb9c46\" width=\"2px\" colspan=3 height=\"3\"><img src=\"/images/common/blank.gif\" width=\"5px\"></td>";
dispstr=dispstr+"<td bgcolor=\"#fb9c46\" width=\"2px\" rowspan=3 height=\"56\"><img src=\"/images/common/blank.gif\" width=\"1px\"></td>";
dispstr=dispstr+"</tr><tr><td bgcolor=\"#fb9c46\" width=\"1px\" height=\"34\"><font size=\"2\" face=\"Arial\"><img src=\"/images/common/blank.gif\" width=\"1px\"></font></td>";
dispstr=dispstr+"<td bgcolor=\"#ffffff\" height=\"34\"><font size=\"2\" face=\"Arial\">&nbsp;&nbsp;</font></td>";
dispstr=dispstr+"<td bgcolor=\"#ffffff\" width=\"99%\" width=\"99%\" height=\"34\" class=\"cl5\">";
dispstr=dispstr+"<img src='images/blank.gif' height=5px width=1px><br><b>Answer:</b>&nbsp;You don't need to have monthly contributions.";
dispstr=dispstr+"</font></td></tr><tr><td bgcolor=\"#fb9c46\" width=\"1px\" ><img src=\"/images/common/blank.gif\" width=\"1px\"></td>";
dispstr=dispstr+"<td bgcolor=\"#fb9c46\" width=\"1px\" colspan=3 ><img src=\"/images/common/blank.gif\" width=\"1px\"></td>";
dispstr=dispstr+"</tr></table><br>";*/

dispstr="<br>Answer:&nbsp;You don't need to have monthly contributions.";

document.getElementById("ansdiv").innerHTML=dispstr;
document.getElementById("ansdiv").style.visibility='visible';
document.getElementById("middleblock").style.visibility='hidden';
document.getElementById("middleblock1").style.visibility='hidden';
document.getElementById("middleblock2").style.visibility='hidden';
document.getElementById("middleblock3").style.visibility='hidden';
document.getElementById("bkbt").style.visibility='visible';




}

if(isNaN(sixthStep))
{
alert('Input values are inappropriate.');

}
else
{
frmobj.txtEstMonSav.value=format(sixthStep,'currency');

if(flag != 1)
{


/*dispstr="<br><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"72\"><tr>";
dispstr=dispstr+"<td bgcolor=\"white\"  height=\"16\" valign=\"bottom\" colspan=2 align=\"left\" width=2px><img src=\"/images/insurance/tl_responsecurve.gif\"></td>";
dispstr=dispstr+"<td width=\"100%\" height=\"16\"><img src=\"/images/insurance/response.gif\"></td>";
dispstr=dispstr+"<td height=\"16\"></td></tr><tr>";
dispstr=dispstr+"<td bgcolor=\"#fb9c46\" width=\"2px\" colspan=3 height=\"3\"><img src=\"/images/common/blank.gif\" width=\"5px\"></td>";
dispstr=dispstr+"<td bgcolor=\"#fb9c46\" width=\"2px\" rowspan=3 height=\"56\"><img src=\"/images/common/blank.gif\" width=\"1px\"></td>";
dispstr=dispstr+"</tr><tr><td bgcolor=\"#fb9c46\" width=\"1px\" height=\"34\"><font size=\"2\" face=\"Arial\"><img src=\"/images/common/blank.gif\" width=\"1px\"></font></td>";
dispstr=dispstr+"<td bgcolor=\"#ffffff\" height=\"34\"><font size=\"2\" face=\"Arial\">&nbsp;&nbsp;</font></td>";
dispstr=dispstr+"<td bgcolor=\"#ffffff\" width=\"99%\" width=\"99%\" height=\"34\" class=\"tim\">";
dispstr=dispstr+"<img src='images/blank.gif' height=5px width=1px><br><b>Answer:</b>&nbsp;You need to save and invest<b> Rs "+frmobj.txtEstMonSav.value+ "</b>&nbsp;every month from now until retirement in order to fund your estimated retirement expenses";
dispstr=dispstr+"</font></td></tr><tr><td bgcolor=\"#fb9c46\" width=\"1px\" ><img src=\"/images/common/blank.gif\" width=\"1px\"></td>";
dispstr=dispstr+"<td bgcolor=\"#fb9c46\" width=\"1px\" colspan=3 ><img src=\"/images/common/blank.gif\" width=\"1px\"></td>";
dispstr=dispstr+"</tr></table><br>";*/

dispstr="<br>Answer:&nbsp;You need to save and invest<span  style=\"color:#ff6600;\"><b> Rs "+frmobj.txtEstMonSav.value+ "</b></span>&nbsp;every month from now until retirement in order to fund your estimated retirement expenses";

document.getElementById("ansdiv").innerHTML=dispstr;
document.getElementById("ansdiv1").innerHTML=dispstr;
document.getElementById("middleblock").style.visibility='hidden';
document.getElementById("middleblock1").style.visibility='hidden';
document.getElementById("middleblock2").style.visibility='hidden';
document.getElementById("middleblock3").style.visibility='hidden';
document.getElementById("bkbt").style.visibility='visible';

}

}

}

function Retcheck(obj1,obj2)
{
	if(eval(obj1.value)>=eval(obj2.value))
		{
			alert("Your retirement age should be greater than your current age.");
			obj1.value="";
			obj2.value="";
			obj1.focus();
			return(false);
		}
}