// JavaScript Document
function movein(which,html)
	{
		which.style.background='#000080'
		descript.innerHTML=html
	}
	
	function moveout(which)
	{
		which.style.background='#B0C1EE'
		descript.innerHTML=' '
	}
	
	
		function movein2(which,html)
	{
		which.style.background='#FF9900'
		descript.innerHTML=html
	}	
	
		function movein3(which,html)
	{
		which.style.background='#FFFF00'
		descript.innerHTML=html
	}
	
	function moveout3(which)
	{
		which.style.background='#FFFFCC'
		descript.innerHTML=' '
	}
function calculate(form) {
age = parseFloat(form.Age.value);
nra = parseFloat(form.RetirementAge.value);

inf = parseFloat(form.Inflation.value);
growth = parseFloat(form.GrowthRate.value);
//ann = parseFloat(form.AnnuityRate.value);
rcont = parseFloat(form.MonthlyContribution.value);
index = form.InflateContributions.value;
scont = parseFloat(form.ExistingFundValues.value);

	if (index == "1") {index1 = 0;}
	
	if (index == "2") {index1 = inf;}
				
	if (index == "3") {index1 = inf+1;}
				
	if (index == "4") {index1 = inf+2;}

		if (growth>9) {
	javascript:alert ("Be realistic about the rate of return that you can expect. While "+(form.GrowthRate.value)+"% pa might be achievable you may find that it is too optimistic and you may not be saving enough. We have left the growth rate unchanged");
	}

ann = nra/12

	
growth = ((growth+100)/100);
index1 = ((index1+100)/100);
ann = (ann/100);
term = (nra-age); 
tfund = 0;
defl = (100-inf)/100;

for ( i = 0; i < term; i++){
tfund = ((rcont*12)+scont+tfund)*growth;
scont = 0;
rcont = (rcont*index1);
}

tfund2 = tfund;
for ( i = 0; i < term; i++){
tfund2 = (tfund2*defl);
}
mincome = tfund*ann/12;
mincome2 = tfund2*ann/12;

form.FundValue.value = Math.round(tfund*100)/100;
form.IncomeMonthly.value = Math.round(mincome*100*12)/100;
form.IncomeToday.value = Math.round(mincome2*100*12)/100;
}
function help1(form){
form.HelpBox.value = "Annual growth of your investment in percentage terms. The Financial Services Authority approves the use of 5%, 7% and 9%."
}
function help2(form){
form.HelpBox.value = "At retirement your accumulated fund will be used to buy an income, known as an annuity. This figure represents the annuity rate as a percentage."
}
function help3(form){
form.HelpBox.value = "Apply automatic increases to your contributions to combat the effects of inflation. "
}
function help4(form){
form.HelpBox.value = "A one off lumpsum payment at the start or the value of an existing pension."
}
function help5(form){
form.HelpBox.value = "Inflation will reduce what you can buy in the future, so this is the real purchasing power of your pension in todays terms."
}
