var earningsCap=123600
var scheme=0
var taxMessage=0

function Comma(SS) { var T='', S=String(SS), L=S.length-1, C, j
  for (j=0; j<=L; j++) {
    T+=C=S.charAt(j)
    if ((j < L) && ((L-j)%3 == 0) && (C != '-')) T+=',' }
  return T
}

function mailIt() {
	targetMail=sliderForm.inputTarget.value
    Mail="mailto:Please input the appropriate email address here?subject=Retirement Planning&body=My projected pension income is "+outputSLPension.innerHTML+". Based on the income I'd like at retirement, I have a shortfall of "+outputShortfall.innerHTML+"\r\r\n\n\n"
    window.location.href=Mail;
} 

// tiering / matching

function BTPaymentPre(eeCont,scheme) {
var erCont=0

if (scheme==1) {
	if (eeCont==2) { erCont=3 }
	if (eeCont==3) { erCont=4.5 }
	if (eeCont==4) { erCont=6 }
	if (eeCont==5) { erCont=8 }
	if (eeCont==6) { erCont=8.5 }	
	if (eeCont==7) { erCont=9 }	
	if (eeCont>=8) { erCont=9 }	
}
if (scheme==2) {
	if (eeCont==4) { erCont=6 }
	if (eeCont==5) { erCont=8 }
	if (eeCont==6) { erCont=8.5 }	
	if (eeCont==7) { erCont=9 }	
	if (eeCont>=8) { erCont=9 }	
}
if (scheme==3) {
	if (eeCont==4) { erCont=5 }	
	if (eeCont==5) { erCont=8 }
	if (eeCont==6) { erCont=8.5 }	
	if (eeCont==7) { erCont=9 }	
	if (eeCont>=8) { erCont=9 }	
}

return erCont
}

function BTPaymentPost(eeCont,scheme) {
var erCont=0

if (scheme==1) {
	if (eeCont==2) { erCont=3 }
	if (eeCont==3) { erCont=4.5 }
	if (eeCont==4) { erCont=6 }
	if (eeCont==5) { erCont=8 }
	if (eeCont==6) { erCont=8.5 }	
	if (eeCont==7) { erCont=9 }	
	if (eeCont>=8) { erCont=9 }	
}
if (scheme==2) {
	if (eeCont==4) { erCont=6 }
	if (eeCont==5) { erCont=8 }
	if (eeCont==6) { erCont=8.5 }	
	if (eeCont==7) { erCont=9 }	
	if (eeCont>=8) { erCont=9 }	
}
if (scheme==3) {
	if (eeCont==4) { erCont=6 }	
	if (eeCont==5) { erCont=8 }
	if (eeCont==6) { erCont=8.5 }	
	if (eeCont==7) { erCont=9 }	
	if (eeCont>=8) { erCont=9 }	
}
	
return erCont


}


// end of tiering

function doTheCalc() {

if (sliderForm.sexVal[0].checked) {
	sexValue="male"
} else {
	sexValue="female"
}
stripCommas();
if (!validInputs()) {

setCommas();
	return false;
}
var eeTotal=parseInt(sliderForm.eeInput.value);



eeTotal=parseInt(sliderForm.eeInput.value);

doCalc(sliderForm.ageInput.value,sexValue,sliderForm.retAgeInput.value, sliderForm.lumpsumInput.value,sliderForm.salaryInput.value,eeTotal,sliderForm.erInput.value,sliderForm.inputTarget.value,sliderForm.yearlyInput.value,sliderForm.hrsInput.value,sliderForm.hiddenScheme.value);
setCommas();
}

  var slider1 = new Slider("Slider1");
  slider1.onchange = "document.sliderForm.inputTarget.value = '£'+Comma( (Math.round(slider1.getValue()/500)*500) )";
  slider1.buttonHiliteImg = "static/img/sliderbutton.gif";
  slider1.maxSlide = 200; 
  slider1.buttonWidth = 22;
  slider1.buttonHeight = 28; 
  slider1.leftValue = 1000;
  slider1.rightValue = 70000;
  slider1.defaultValue = 20000;  
  slider1.onmouseup = "doTheCalc()" 
  
  
  var slider2 = new Slider("Slider2");
  slider2.onchange = "document.sliderForm.retAgeInput.value = Math.round(slider2.getValue())";
  slider2.buttonHiliteImg = "static/img/sliderbutton.gif";
  slider2.maxSlide = 200; 
  slider2.buttonWidth = 22;
  slider2.buttonHeight = 28; 
  slider2.leftValue = 55;
  slider2.rightValue = 75;
  slider2.defaultValue = 65;
  slider2.onmouseup = "prepCalc()"  
  
  var slider3 = new Slider("Slider3");
  slider3.onchange = "document.sliderForm.eeInput.value =Math.round(slider3.getValue())";
  slider3.buttonHiliteImg = "static/img/sliderbutton.gif";
  slider3.maxSlide = 200;
  slider3.buttonWidth = 22;
  slider3.buttonHeight = 28; 
  slider3.leftValue = 0;
  slider3.rightValue = 100;
  slider3.defaultValue = 0;  
  slider3.onmouseup = "doTheCalc()"  
  
 
  
function resetForm() {
	sliderForm.incomeAge.value=65
	sliderForm.erInput.value=splashER.value
	sliderForm.eeInput.value=splashEE.value
	sliderForm.retAgeInput.value=65

	sliderForm.yearlyInput.value=0
	sliderForm.lumpsumInput.value=0
	sliderForm.ageInput.value=splashAge.value
	sliderForm.salaryInput.value=splashSalary.value
	if (splashSex[0].checked) {
		document.sliderForm.sexVal[0].checked=true
	} else {
		document.sliderForm.sexVal[1].checked=true
	}
	setTarget(splashSalary.value)
	slider2.setValue(65)	
	slider3.setValue(splashEE.value)
	doTheCalc()
	
}
function prepCalc() {
	stripCommas();
		sliderForm.yearlyInput.className="inputBox"
		sliderForm.incomeAge.className="inputBoxSmall"	
	if (sliderForm.retAgeInput.value==sliderForm.ageInput.value || sliderForm.retAgeInput.value < sliderForm.ageInput.value ) {
		window.alert("Sorry, we are unable to provide you with a quote within one year of your chosen retirement date. Please contact your employer or financial adviser.")
		return;
	}
	if (sliderForm.yearlyInput.value>0 && (sliderForm.incomeAge.value>sliderForm.retAgeInput.value)) {
		window.alert("Sorry, the date your yearly income starts must be less than or equal to your chosen retirement date.\nPlease either decrease the start date or convert your yearly income to a lump sum before proceeding.");
		sliderForm.yearlyInput.className="inputBoxHi"
		sliderForm.incomeAge.className="inputBoxSmallHi"
		return;
	}


	if(validInputs()) 
	{  

//paul devlin added the following code to allow BSP to be shown for females
		if (sliderForm.sexVal[0].checked) 
		{
			//male
			StatePensionAge="65";
		} 
		else
		{
			//female
			StatePensionAge="60";
		}

		if (sliderForm.retAgeInput.value < StatePensionAge) 
		{
			exclude.style.display="none"
			sliderForm.excludeBSP.checked=true
		}
		else 
		{
			exclude.style.display=""
			sliderForm.excludeBSP.checked=false
		}
		doTheCalc()
	}
}

function doSal(salary) {
document.onkeydown = function() {
		if (event.keyCode == 13) {
			setTarget(salary);
			prepCalc()
		}
	}
}

function doOnEnter() {
document.onkeydown = function() {
		if (event.keyCode == 13) {
			prepCalc()
		}
	}
}

function do1OnEnter(what) {
document.onkeydown = function() {
		if (event.keyCode == 13) {
stripCommas();if(validInputs()) {slider1.setValue(what);doTheCalc()}
		}
	}
}
function do2OnEnter(what) {
document.onkeydown = function() {
		if (event.keyCode == 13) {
stripCommas();if(validInputs()) {slider2.setValue(what);doTheCalc()}
		}
	}
}
function doEEOnEnter(what) {
document.onkeydown = function() {
		if (event.keyCode == 13) {
			stripCommas();
			if(validInputs()) { 
				setIncreaseLimits(what);
				doTheCalc() 
			}
		}
	}
}

function doEEPOnEnter(what) {
document.onkeydown = function() {
		if (event.keyCode == 13) {
stripCommas();if(validInputs()) {doTheCalc()}
		}
	}
}
function doEROnEnter(what) {
document.onkeydown = function() {
		if (event.keyCode == 13) {
stripCommas();if(validInputs()) {doTheCalc()}
		}
	}
}

function setTarget(toWhat) {
toWhat=Math.round(parseFloat(toWhat)*0.75)
slider1.setValue(toWhat)
}

function setIncreaseLimits(toWhat) {
	toWhat=parseFloat(toWhat)
	if (toWhat+slider3.getValue()>100) {
		slider3.setValue(100-toWhat)
	}
	slider3.rightValue=(100-toWhat)
	slider3.setValue(document.sliderForm.eeInput.value)
	erLimit.innerText=(100-toWhat)+"%"
}

function showSplash() {
splashBox0.style.display=""
}

function setCommas() {
	document.sliderForm.salaryInput.value="£"+Comma(document.sliderForm.salaryInput.value)
	document.sliderForm.yearlyInput.value="£"+Comma(document.sliderForm.yearlyInput.value)
	document.sliderForm.lumpsumInput.value="£"+Comma(document.sliderForm.lumpsumInput.value)	
	document.sliderForm.inputTarget.value="£"+Comma(document.sliderForm.inputTarget.value)	
	outputShortfall.innerText="£"+Comma(sliderForm.hiddenShortfall.value)
	outputSLPension.innerText="£"+Comma(sliderForm.hiddenPension.value)			
	outputPension.innerText="£"+Comma(document.sliderForm.hiddenIMV.value)			

		
}

function stripCommas() {
	document.sliderForm.salaryInput.value=stringFilter(document.sliderForm.salaryInput.value)
	document.sliderForm.yearlyInput.value=stringFilter(document.sliderForm.yearlyInput.value)
	document.sliderForm.lumpsumInput.value=stringFilter(document.sliderForm.lumpsumInput.value)	
	document.sliderForm.inputTarget.value=stringFilter(document.sliderForm.inputTarget.value)	
		

}

function stringFilter (s) {

filteredValues = ",£%";     
var i;
var returnString = "";
for (i = 0; i < s.length; i++) {  
var c = s.charAt(i);
if (filteredValues.indexOf(c) == -1) returnString += c;
}
return returnString;
}




function closeSplash(age,sal,male,female,eeCont,hrsWorked,scheme) {
	var validInputs=true;
	var errorMessage="";
	if ((age<16) || (age>64)) {
		errorMessage+="- Please enter an age between 16 - 64\n"
		validInputs=false
	}
	if (!IsNumeric(age)) {
		errorMessage+="- Please enter an age between 16 - 64\n"
		validInputs=false
	}	
	if ((parseFloat(sal)<1000) || (parseFloat(sal)>10000000)) {
		errorMessage+="- your salary must be between £1,000 and £10,000,000.\n"
		validInputs=false
	}
	if (!IsNumeric(sal)) {
		errorMessage+="- your salary must be greater than £10,000,000.\n"
		validInputs=false
	}		
	if ((male==false) && (female==false)) {
		errorMessage+="- Please select your gender.\n"
		validInputs=false
	}
	
	if ((parseInt(eeCont)<0) || (parseInt(eeCont)>100)) {
		errorMessage+="- Please enter an integer percentage of your gross annual salary between 2% - 100%\n"
		validInputs=false
	}
	if (!IsNumeric(eeCont)) {
		errorMessage+="- Please enter an integer percentage of your gross annual salary between 2% - 100%\n"
		validInputs=false
	}		
	
	if ((parseFloat(hrsWorked)<1) || (parseFloat(hrsWorked)>36)) {
		errorMessage+="- Please enter the number of hours you work per week between 1 - 36\n"
		validInputs=false
	}
	if (!IsNumeric2(hrsWorked)) {
		errorMessage+="- Please enter the number of hours you work per week between 1 - 36\n"
		validInputs=false
	}	
	if (scheme==0) {
		errorMessage+="- Please select your previous BT Pension Scheme Membership\n"
		validInputs=false
	}
	if ((scheme==1) && (eeCont<2)) {
		errorMessage+="- The minimum payment for former SLFPP members in the BT Retirement Saving Scheme is 2% of salary\n"
		validInputs=false
	}	
	if ((scheme==2) && (eeCont<4)) {
		errorMessage+="- The minimum payment for former BTRP members in the BT Retirement Saving Scheme is 4% of salary\n"
		validInputs=false
	}		
	if ((scheme==3) && (eeCont<4)) {
		errorMessage+="- The minimum payment for New Entrants in the BT Retirement Saving Scheme is 4% of salary\n"
		validInputs=false
	}			

	if (!validInputs) {
		window.alert(errorMessage)
		return false
	}
	if ( (eeCont<5) ) {
		window.alert("For monthly payments less than 5% of your salary, a minimum payment will not be made by your employer. More details can be found in the Assumptions section.")
	}

	sliderForm.ageInput.value=age
	sliderForm.salaryInput.value=sal
	sliderForm.hrsInput.value=hrsWorked
	sliderForm.hiddenScheme.value=scheme
	var erValue=BTPaymentPre(eeCont,scheme)
	slider3.setValue(eeCont)	
sliderForm.eeInput.value=parseInt(eeCont)
sliderForm.erInput.value=parseFloat(erValue)
	setTarget(sal)
	if (male) {
		document.sliderForm.sexVal[0].checked=true
	} else {
		document.sliderForm.sexVal[1].checked=true
	}
	splashBox0.style.display="none"
	//setIncreaseLimits(ee)
	doTheCalc()
}

function monthsBetween(thisDate, thatDate) {
if (thisDate> thatDate) {
return monthsBetween(thatDate, thisDate);
}
 
var number = 0;
if (thatDate.getFullYear()> thisDate.getFullYear()) {
number = number + (thatDate.getFullYear() - thisDate.getFullYear() - 1) * 12;
} else {
return thatDate.getMonth() - thisDate.getMonth();
}
 
if (thatDate.getMonth()> thisDate.getMonth()) {
number = number + 12 + thatDate.getMonth() - thisDate.getMonth();
} else {
number = number + (12 - thisDate.getMonth()) + thatDate.getMonth();
}
return number;
}

function doCalc(curAge,sx,retAge,lumpsum,salary,ee,er,target,yearlyPen,hrsWorked,scheme) {

// constants / assumptions

var annualInflationRate=0.025
var annualEarningsInflation=0.025
var annualManagementCharge=0.01
var annualInvestmentGrowthRate=0.07
var annuityExpenseRate=0.02
var annuityEscalationRate=0.0
var annuityPaymentFrequency=12
var RPI=0.025
var annuityInterestRate=0.002
var spousePercentage=0.5
var annualCreationOfUnit=0.0052
var HWR=hrsWorked/36
var basicStatePension=102.15
var gtee=5
earningsCap=123600
var dateToUse=new Date();
var april2009=new Date();
april2009.setFullYear(2009,3,1)
var april2010=new Date();
april2010.setFullYear(2010,3,1)
var todayDate=new Date();
if (todayDate>april2009) {
	dateToUse=todayDate
} else {
	dateToUse=april2009
}
//window.alert("scheme:"+scheme)
var preER=BTPaymentPre(ee,scheme)
var postER=BTPaymentPost(ee,scheme)
var underpinPre=1500
var underpinPost=1500
if (ee<5) {
	underpinPre=0
	underpinPost=0
}

// date difference

var monthsToGo=monthsBetween(dateToUse,april2010)
if (dateToUse<april2010) {
	//window.alert("er:"+preER)
	sliderForm.erInput.value=parseFloat(preER)
} else {
	sliderForm.erInput.value=parseFloat(postER)
}
// user inputs

if ((retAge=="") || (retAge==null)) {
	retAge="0"
}
if ((lumpsum=="") || (lumpsum==null)) {
	lumpsum="0"
}
if ((yearlyPen=="") || (yearlyPen==null)) {
	yearlyPen="0"
}
if ((ee=="") || (ee==null)) {
	ee="0"
}
if ((er=="") || (er==null)) {
	er="0"
}

var currentAge=parseInt(curAge)
var sex=sx
var retirementAge=parseInt(retAge)
var existingFund=parseFloat(lumpsum)
var grossSalary=parseFloat(salary)
var eeCont=parseFloat(ee)
var erCont=parseFloat(er)
var inputTarget=parseFloat(target)

if (!validAge(currentAge)) {
	return false;
}

if (!validRetAge(retirementAge)) {
	return false;
}

if (!validSalary(grossSalary)) {
	return false;
}

if (!validTarget(inputTarget)) {
	return false;
}



// get date of birth

var YOB=getYOB(curAge)
//tested correct

var spouseYOB=0
var spouseCurrAge=0
var spouseRetirementAge=0

if (sex=="male") {
	spouseYOB=YOB+3
	spouseCurrAge=currentAge-3
	spouseRetirementAge=retirementAge-3
} else {
	spouseYOB=YOB-3
	spouseCurrAge=currentAge+3
	spouseRetirementAge=retirementAge+3	
}
//tested correct
//window.alert("Year of birth:"+YOB+"\nSpouse YOB:"+spouseYOB+"\nSpouse current age:"+spouseCurrAge+"\nSpouse retirement //age:"+spouseRetirementAge)

// UEL and tiering here	
// calculate monthly contribution
var monthlyCont=((eeCont+erCont)*(grossSalary/12)) / 100
//looks ok
//window.alert("Monthly contribution:"+monthlyCont)

// set fund starting value to be existing fund value

var fund=existingFund
//window.alert("Existing fund:"+fund)

// set value for Single Life calculation

var j=(1.0+annuityInterestRate) / (1.0+annuityEscalationRate) - 1.0
var k1=(annuityInterestRate)
//window.alert("Rate for single life calc:"+j)

// get PMA / PFA denominator
var denom=0.0
var denomg=0.0
var row1=retirementAge
if (sex=="male") {

	denom=getPMA(row1,YOB)
	denomg=getPMA(row1+gtee,YOB)
} else {

	denom=getPFA(row1,YOB)
	denomg=getPFA(row1+gtee,YOB)
}
//window.alert("Value from mortality table:"+denom)


//tested correct

// calculate single life - this could be wrong
var sigmaValue=0
for (t=gtee;t<=(120-retirementAge);t++) {
	if (sex=="male") {
		sigmaValue+=( getPMA(row1+t,YOB) / Math.pow((1+k1),t))
	} else {
		sigmaValue+=( getPFA(row1+t,YOB) / Math.pow((1+k1),t))
	}
}

//window.alert("Single life - before mort rate applied:"+sigmaValue)

sigmaValue=sigmaValue / denom

//window.alert("Single life divided by mort rate:"+sigmaValue)

var aduegtee = (1-(Math.pow (1/(1+annuityInterestRate),gtee)))/12
aduegtee = aduegtee / (1-(Math.pow(1/(1+annuityInterestRate),1/12)))
//window.alert("aduegtee:"+aduegtee)
var adj=((11/24)*(denomg/denom)) / Math.pow((1+annuityInterestRate),gtee)
//sigmaValue=(1+annuityExpenseRate)*(sigmaValue-(annuityPaymentFrequency-1)/(2*annuityPaymentFrequency))
sigmaValue=(1+annuityExpenseRate)*(sigmaValue-adj+aduegtee)
//window.alert("Sigma value:"+sigmaValue)

//window.alert("Single life after annuity expense rate applied:"+sigmaValue)

//calculate reversionary factor
var denom2=0.0
var denom2g=0.0
if (sex=="male") {
	denom2=getPFA(spouseRetirementAge,spouseYOB)
	denom2g=getPFA(spouseRetirementAge+gtee,spouseYOB)
} else {
	denom2=getPMA(spouseRetirementAge,spouseYOB)
	denom2g=getPMA(spouseRetirementAge+gtee,spouseYOB)
}

var maxAge=0
// if (spouseRetirementAge>retirementAge) {
//	maxAge=retirementAge
//} else {
//	maxAge=spouseRetirementAge+3
//}

if (spouseRetirementAge>retirementAge) {
	maxAge=spouseRetirementAge
} else {
	maxAge=retirementAge
}

var reversionaryFactor=0
for (u=gtee;u<=(120-maxAge);u++) {
if (sex=="male") {
	retAge1=getPMA(retirementAge,YOB)
	retAge2=getPMA(retirementAge+u,YOB)
	retAge3=getPFA(spouseRetirementAge+u,spouseYOB)
	reversionaryFactor+=((retAge1-retAge2)*retAge3) / Math.pow((1+k1),u)
} else {
	retAge1=getPFA(retirementAge,YOB)
	retAge2=getPFA(retirementAge+u,YOB)
	retAge3=getPMA(spouseRetirementAge+u,spouseYOB)
	reversionaryFactor+=((retAge1-retAge2)*retAge3) / Math.pow((1+k1),u)
}
}

var adj2=((11/24)*((denom-denomg)*denom2g))
adj2=adj2/(denomg*denom2g)
adj2=adj2/Math.pow((1+k1),gtee)


//window.alert("adj2:"+adj2)

reversionaryFactor=(reversionaryFactor/(denom*denom2))-adj2


reversionaryFactor=(1+annuityExpenseRate)*(reversionaryFactor)
//window.alert("Reversionary factor:"+reversionaryFactor)


sigmaValue=sigmaValue+((0.5)*(reversionaryFactor))
//window.alert("Single life with reversionary fact2or applied:"+sigmaValue)


// calculate factor

var amcPower=Math.pow(1-(annualManagementCharge/365),365)
var growthRate=(1+annualInvestmentGrowthRate)
var cOfUnits=Math.pow((1+(annualCreationOfUnit/12)),12)
var factor=amcPower*growthRate*cOfUnits

//calculate term
var term=retirementAge-currentAge
term2=term
term=(term*12)



var fund=existingFund
var conted=false
var conted2=false
var debug=false
var premCount=0
var termCount=0
var underpin=0
var monthlyERCont=0
var initialERCont=erCont
var initialUnderpin=0
var initialCap=0
var initialValue=0
var initialEECont=eeCont
var initialSalary=grossSalary
var monthlyEECont=0
var underpinHWR=0
for (x=0;x<term;x++) {
	if (monthsToGo>0) {
		erCont=preER
		underpin=underpinPre
	} else {
		erCont=postER
		underpin=underpinPost
	}
	if (salary==0) {
		underpin=0
	}
    monthlyERCont=((erCont)*(grossSalary/12)) / 100
    monthlyEECont=((eeCont)*(grossSalary/12)) / 100
	underpinHWR=underpin*(HWR/12)
	if ((scheme==1)) {
		if (underpinHWR > monthlyERCont) {
			monthlyERCont=underpinHWR
			if (initialValue==0) {
				initialValue=underpinHWR
			}
		}
	} else {
		if (earningsCap<grossSalary) {	
			monthlyERCont=((erCont)*(earningsCap/12)) / 100
			if (initialValue==0) {
				initialValue=monthlyERCont
			}
		}
		if (underpinHWR > monthlyERCont) {
			monthlyERCont=underpinHWR
			if (initialValue==0) {
				initialValue=underpinHWR
			}			
		}
		if (initialValue==0) {
			initialValue=monthlyERCont
		}
	}
	fund=(fund+monthlyERCont+monthlyEECont)*(Math.pow(factor,(parseInt(1)/12)))
	premCount++
	monthsToGo--
	if (premCount==12) {
		earningsCap=Math.ceil( (earningsCap*1.025/600) ) * 600
		//window.alert("fund:"+fund+"\nER:"+monthlyERCont+"\nEE"+monthlyEECont+"\nearnings cap:"+earningsCap)
		grossSalary=grossSalary*1.04
		currentAge++
		premCount=0
	}

} 


var annualERCont=(initialSalary)*(initialEECont/100)
var annualEECont=(initialSalary)*(initialERCont/100)
if ((annualERCont+annualEECont)<=50000) {
	taxMessage=0;
} else {
	if (taxMessage==0) {
		taxMessage=1;
	}
}
if (taxMessage==1) {
	if ((annualERCont+annualEECont)>50000) {
		window.alert('You may be subject to additional tax changes if you pay over £50,000 into your pension plans in a tax year, this tool does not take account of this tax charge');
	taxMessage=2;
	}
}


//discount to today's term

	fund=fund / Math.pow((1+RPI),(term2))


var pension=fund/sigmaValue
//window.alert("Fund:"+fund+"\nAnnuity:"+sigmaValue+"\nPension:"+pension)

<!-- window.alert("Annual pension:"+pension) -->
<!-- outputPension.value=parseInt(fund) -->
<!-- outputPensionAnnual.value=parseInt(pension) -->
var prevBenTot=0
if (!sliderForm.excludeBSP.checked) {
	prevBenTot=basicStatePension*52;
}
if (retirementAge >= parseInt(sliderForm.incomeAge.value) ) {
 prevBenTot+=parseInt(yearlyPen) 
}

var shortFall=(parseInt(inputTarget-(to3SigFig(pension+prevBenTot))))
if (shortFall<0) shortFall=0
outputShortfall.innerText=shortFall
sliderForm.hiddenShortfall.value=shortFall

outputEEMonthly.innerText="£"+Comma(parseInt( (initialSalary/12)*(initialEECont/100)))
sliderForm.hiddenEEMonthly.value=parseInt( (initialSalary/12)*(initialEECont/100))
if (initialValue!=0) {
outputERMonthly.innerText="£"+Comma(parseInt( initialValue))
} else {
	outputERMonthly.innerText="£"+Comma(parseInt( (initialSalary/12)*(initialERCont/100)))
}



totalCylinders=(prevBenTot+pension+shortFall)
if (shortFall>0) {totalCylinders=parseInt(sliderForm.inputTarget.value) }
cNum1=parseInt(totalCylinders/1000*1000)
cNum2=parseInt(((totalCylinders/3)*2)/1000*1000)
cNum3=parseInt(((totalCylinders/3))/1000*1000)

cn1.innerText="£"+parseInt(cNum1/100)*100
cn2.innerText="£"+parseInt(cNum2/100)*100
cn3.innerText="£"+parseInt(cNum3/100)*100

percentPrevBen=parseInt((prevBenTot/totalCylinders)*100)
percentPension=parseInt((pension/totalCylinders)*100)
percentShortfall=parseInt((shortFall/totalCylinders)*100)

var filler=(100-(percentPrevBen+percentPension+percentShortfall))
if (filler<0) { percentPension-=filler }
if (filler>0) { percentPension+=filler }


height1=parseInt((2*percentPrevBen))
height2=parseInt((2*percentPension))
height3=parseInt((2*percentShortfall))

prevbenBlock.style.height=height1
pensionBlock.style.height=height2
shortfallBlock.style.height=height3

if (height1==0) { prevbenBlock.style.display="none" } else { prevbenBlock.style.display="" }
if (height2==0) { pensionBlock.style.display="none" } else { pensionBlock.style.display="" }
if (height3==0) { shortfallBlock.style.display="none" } else { shortfallBlock.style.display="" }

if (prevBenTot<=0 && pension<=0 && shortFall>0) {
	//red only - working
	green_top.style.display="none"
	green_top2.style.display="none"	
	red_green.style.display="none"	
	red_bottom.style.display="none"		
	green_bottom.style.display="none"
	prevbenBlock.style.display="none"
	blue_top.style.display="none"
	blue_bottom.style.display="none"
	pensionBlock.style.display="none"	
	red_top.style.display="block"
	shortfallBlock.style.display="block"	
	red_bottom2.style.display="block"
	shortfallBlock.style.height=(height3+27)	
}

if (prevBenTot>0 && pension<=0 && shortFall>0) {
	// green red - working
	green_top.style.display="none"
	green_top2.style.display="none"	
	red_green.style.display="block"	
	red_bottom.style.display="none"		
	green_bottom.style.display="block"
	prevbenBlock.style.display="block"
	blue_top.style.display="none"
	blue_bottom.style.display="none"
	pensionBlock.style.display="none"	
	red_top.style.display="block"
	shortfallBlock.style.display="block"	
	red_bottom2.style.display="none"
	shortfallBlock.style.height=(height3+15)
}

if (prevBenTot<=0 && pension>0 && shortFall>0) {
	// blue red - working
	green_top.style.display="none"
	green_top2.style.display="none"	
	red_green.style.display="none"	
	red_bottom.style.display="block"		
	green_bottom.style.display="none"
	prevbenBlock.style.display="none"
	blue_top.style.display="none"
	blue_bottom.style.display="block"
	pensionBlock.style.display="block"	
	red_top.style.display="block"
	shortfallBlock.style.display="block"	
	red_bottom2.style.display="none"
	shortfallBlock.style.height=(height3+7)	
	pensionBlock.style.height=(height2+8)
}

if (prevBenTot>0 && pension>0 && shortFall>0) {
	// all 3 - working
	green_top.style.display="none"
	green_top2.style.display="block"	
	red_green.style.display="none"	
	red_bottom.style.display="block"		
	green_bottom.style.display="block"
	prevbenBlock.style.display="block"
	blue_top.style.display="none"
	blue_bottom.style.display="none"
	pensionBlock.style.display="block"	
	red_top.style.display="block"
	shortfallBlock.style.display="block"	
	red_bottom2.style.display="none"
}

if (prevBenTot>0 && pension>0 && shortFall<=0) {
	// green blue - working
	green_top.style.display="none"
	green_top2.style.display="block"	
	red_green.style.display="none"	
	red_bottom.style.display="none"		
	green_bottom.style.display="block"
	prevbenBlock.style.display="block"
	blue_top.style.display="block"
	blue_bottom.style.display="none"
	pensionBlock.style.display="block"	
	red_top.style.display="none"
	shortfallBlock.style.display="none"	
	red_bottom2.style.display="none"
	pensionBlock.style.height=(height2+15)	
}

if (prevBenTot<=0 && pension>0 && shortFall<=0) {
	// blue only - working
	green_top.style.display="none"
	green_top2.style.display="none"	
	red_green.style.display="none"	
	red_bottom.style.display="none"		
	green_bottom.style.display="none"
	prevbenBlock.style.display="none"
	blue_top.style.display="block"
	blue_bottom.style.display="block"
	pensionBlock.style.display="block"	
	red_top.style.display="none"
	shortfallBlock.style.display="none"	
	red_bottom2.style.display="none"
	pensionBlock.style.height=(height2+27)	
}

if (prevBenTot>0 && pension<=0 && shortFall<=0) {
	// green only
	green_top.style.display="block"
	green_top2.style.display="none"	
	red_green.style.display="none"	
	red_bottom.style.display="none"		
	green_bottom.style.display="block"
	prevbenBlock.style.display="block"
	blue_top.style.display="none"
	blue_bottom.style.display="none"
	pensionBlock.style.display="none"	
	red_top.style.display="none"
	shortfallBlock.style.display="none"	
	red_bottom2.style.display="none"
	prevbenBlock.style.height=(height1+27)
}


document.sliderForm.hiddenPension.value=to3SigFig(pension+prevBenTot)
outputSLPension.innerText=to3SigFig(pension+prevBenTot)
document.sliderForm.hiddenIMV.value=to3SigFig(pension)
document.sliderForm.hiddenHrs.value=hrsWorked
document.sliderForm.hiddenScheme.value=scheme

pension=to3SigFig(pension)
outputPension.innerText=to3SigFig(pension)
pensionBlock.title="The value of your pension is £"+pension
shortfallBlock.title="Your shortfall is £"+shortFall
prevbenBlock.title="The total value of your existing benefits is £"+parseInt(prevBenTot)
}


function getMemUpTo(age,grade) {
if (grade<3) {
	if (age >=45 && age <51) {
		return 5.0;
	}
	if (age >=51 && age <56) {
		return 6.0;
	}
	return 7.0;
} else {
	if (age < 30) {
		return 3.0;
	}
	if (age >=30 && age < 46) {
		return 4.0;
	}
	if (age >=46 && age <51 ) {
		return 5.0;
	}
	if (age >=51 && age <56) {
		return 6.0;
	}
	return 7.0
}
}

function getFirmUpTo(age,grade) {
if (grade<3) {
	if (age == 45) {
		return 13.0;
	}
	if (age >=46 && age <51) {
		return 15.5;
	}
	if (age >=51 && age <56) {
		return 19.5;
	}
	return 23.5;
} else {
	if (age < 30) {
		return 3.0;
	}
	if (age >=30 && age < 40) {
		return 4.0;
	}
	if (age >=40 && age < 46) {
		return 8.5;
	}	
	if (age >=46 && age <51 ) {
		return 11.0;
	}
	if (age >=51 && age <56) {
		return 13.5;
	}
	return 16.0
}
}


function getMemAbove(age,grade) {
if (grade<3) {
	if (age >=45 && age <51) {
		return 6.0;
	}
	if (age >=51 && age <56) {
		return 7.0;
	}
	return 8.0;
} else {
	if (age < 30) {
		return 3.0;
	}
	if (age >=30 && age < 40) {
		return 4.0;
	}
	if (age >=40 && age < 46 ) {
		return 5.0;
	}
	if (age >=46 && age < 51) {
		return 6.0;
	}
	if (age >=51 && age < 56) {
		return 7.0;
	}	
	return 8.0
}
}

function getFirmAbove(age,grade) {
if (grade<3) {
	if (age == 45) {
		return 17.0;
	}
	if (age >=46 && age <51) {
		return 21.5;
	}
	if (age >=51 && age <56) {
		return 27.5;
	}
	return 33.5;
} else {
	if (age < 30) {
		return 3.0;
	}
	if (age >=30 && age < 40) {
		return 4.0;
	}
	if (age >=40 && age < 46) {
		return 12.5;
	}	
	if (age >=46 && age <51 ) {
		return 17.0;
	}
	if (age >=51 && age <56) {
		return 21.5;
	}
	return 26.0
}
}


function to3SigFig(what) {
	valRounded=""
	valToRound=parseInt(what)+""
	for (i=0;i<valToRound.length;i++) {
		if (i<3) {
			valRounded+=valToRound.charAt(i)
		} else {
			valRounded+="0"
		}
	}
	return parseInt(valRounded)
}

// function to calculate year of birth (assumes age is age last birthday)

function getYOB(age) {

var now=new Date()
var year=now.getYear()
var month=now.getMonth()
year=year-age
//if (month < 7) {
//	year=year-1
//} 
return year

}

// function to get a specified entry of the PMA table, based on retirement age and DOB

function getPMA(retAge,yearOfBirth) {

	var YOBArray=PMA[retAge].split(",");
	
	yearOfBirth=yearOfBirth-1925
	
	return PMAresult=YOBArray[yearOfBirth]

}
	
function getPFA(retAge,yearOfBirth) {

	var fYOBArray=PFA[retAge].split(",");
	
	fyearOfBirth=yearOfBirth-1925
	
	return PFAresult=fYOBArray[fyearOfBirth]

}	
function validInputs() {

	if (!validTotalConts(sliderForm.eeInput.value,sliderForm.erInput.value,0)) {
		return false
	}

	if (!validAge(sliderForm.ageInput.value)) {
		sliderForm.ageInput.focus()
		return false;
	}
	if (!validSalary(sliderForm.salaryInput.value)) {
		sliderForm.salaryInput.focus()	
		return false;
	}
	if (!validHours(sliderForm.hrsInput.value)) {
		sliderForm.hrsInput.focus()
		return false;
	}
	if (!validRetAge(sliderForm.retAgeInput.value)) {
		sliderForm.retAgeInput.focus()	
		return false;
	}	
	if (!validYearly(sliderForm.yearlyInput.value)) {
		sliderForm.yearlyInput.focus()		
		return false;
	}	
	if (!validIncAge(sliderForm.incomeAge.value)) {
		sliderForm.incomeAge.focus()		
		return false;
	}			
	if (!validLumpsum(sliderForm.lumpsumInput.value)) {
		sliderForm.lumpsumInput.focus()		
		return false;
	}	
	if (!validYearly(sliderForm.yearlyInput.value)) {
		sliderForm.yearlyInput.focus()		
		return false;
	}
	if (!validTarget(sliderForm.inputTarget.value)) {
		sliderForm.inputTarget.focus()		
		return false;
	}			
		
	if (!validER(sliderForm.erInput.value)) {
		sliderForm.erInput.focus()		
		return false;
	}	
	if (!validIncreasedEE(sliderForm.eeInput.value)) {
		sliderForm.eeInput.focus()		
		return false;
	}				
	return true;
}
	
function validTotalConts(val1, val2, val3) {

	return true;
}
	
function validAge(toVal) {
	if (!IsNumeric1(toVal)) {
		window.alert("Please enter an age between 16 - 64")
		return false;
	}
	if ((toVal<16) || (toVal>64)) {
		window.alert("Please enter an age between 16 - 64")	
		return false;
	} else {
		return true;
	}
} 

function validHours(toVal) {
	if (!IsNumeric2(toVal)) {
		window.alert("Please enter the number of hours you work per week between 1 - 36.")
		return false;
	}
	if ((toVal<1) || (toVal>36)) {
		window.alert("Please enter the number of hours you work per week between 1 - 36.")	
		return false;
	} else {
		return true;
	}
} 

function validRetAge(toVal) {
	if (!IsNumeric1(toVal)) {
		window.alert("Please enter a retirement age between 55 - 75")
		return false;
	}
	if ((toVal<55) || (toVal>75)) {
		window.alert("Please enter a retirement age between 55 - 75")	
		return false;
	} else {
		return true;
	}
} 

function validIncAge(toVal) {
	if (!IsNumeric1(toVal)) {
		window.alert("The age your yearly pension income takes effect must be a number between 50 and 75")
		return false;
	}
	if ((toVal<50) || (toVal>75)) {
		window.alert("The age your yearly pension income takes effect must be a number between 50 and 75")	
		return false;
	} else {
		return true;
	}
} 

function validSalary(toVal) {
	if (!IsNumeric(toVal)) {
		window.alert("Your salary must be between £1,000 and £10,000,000.")
		return false;
	}
	if ((toVal<1000) || (toVal>10000000)) {
		window.alert("Your salary must be between £1,000 and £10,000,000.")	
		return false;
	} else {
		return true;
	}
} 

function validYearly(toVal) {
	if (toVal=="0") return true;
	if (!IsNumeric(toVal)) {
		window.alert("Please enter an income between £500 - £100,000 or £0 if you do not wish to include this in your projection")
		return false;
	}	
	toVal=parseFloat(toVal)
	if ((toVal<500.00) || (toVal>100000.00)) {
		window.alert("Please enter an income between £500 - £100,000 or £0 if you do not wish to include this in your projection")	
		return false;
	} else {
		return true;
	}
} 
function validLumpsum(toVal) {
	if (toVal=="0") return true;
	if (!IsNumeric(toVal)) {
		window.alert("Please enter a value between £1,000 - £1,000,000 or £0 if you do not wish to include this in your projection")
		return false;
	}		
	toVal=parseFloat(toVal)
	if ((toVal<1000.00) || (toVal>1000000.00)) {
		window.alert("Please enter a value between £1,000 - £1,000,000 or £0 if you do not wish to include this in your projection")	
		return false;
	} else {
		return true;
	}
} 

function validEE(toVal) {
	if (!IsNumeric(toVal)) {
		window.alert("Please enter an integer percentage of your gross monthly salary between 0% - 100%")
		return false;
	}		
	toVal=parseFloat(toVal)
	if ((toVal<0) || (toVal>100)) {
		window.alert("Please enter an integer percentage of your gross monthly salary between 0% - 100%")	
		return false;
	} else {
		return true;
	}
} 

function validER(toVal) {
	
	toVal=parseFloat(toVal)
	if ((toVal<0) || (toVal>30)) {
		window.alert("Your employer's payment should be a percentage between 0 and 30.")	
		return false;
	} else {
		return true;
	}
} 

function validIncreasedEE(toVal) {
	if (!IsNumeric(toVal)) {
		window.alert("Please enter an integer percentage of your gross annual salary between 2% - 100%.")
		return false;
	}		
	toVal=parseFloat(toVal)
	var age=sliderForm.ageInput.value
	var scheme=sliderForm.hiddenScheme.value
	var eeCont=toVal
	if ((toVal<0) || (toVal>100)) {
		window.alert("Please enter an integer percentage of your gross annual salary between 2% - 100%.")	
		return false;
	}
	if ((scheme==1) && (eeCont<2)) {
		window.alert("The minimum payment for former SLFPP members in the BT Retirement Saving Scheme is 2% of salary")
		sliderForm.eeInput.value=2
		slider3.setValue(2)			
		return false;
	}	
	if ((scheme==2) && (eeCont<4)) {
		window.alert("The minimum payment for former BTRP members in the BT Retirement Saving Scheme is 4% of salary")
		sliderForm.eeInput.value=4		
		slider3.setValue(4)			
		return false;
	}		
	if ((scheme==3) && (eeCont<4)) {
		window.alert("The minimum payment for New Entrants in the BT Retirement Saving Scheme is 4% of salary")
		sliderForm.eeInput.value=5		
		slider3.setValue(5)			
		return false;
	}			
	
	return true;
} 


function validTarget(toVal) {
	if (!IsNumeric(toVal)) {
		window.alert("Please enter a target retirement income between £1,000 - £70,000.")
		return false;
	}	
	if ((toVal<1000.00) || (toVal>70000.00)) {
		window.alert("Please enter a target retirement income between £1,000 - £70,000.")	
		return false;
	} else {
		return true;
	}
} 

function mandatoryFields(age,salary) {
	if ((age==null) || (age=="")) {
		return false;
	}
	if ((salary==null) || (salary="")) {
		return false;
	}
	return true;
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789,-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
function IsNumeric1(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }   

function IsNumeric2(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }  
   
   

		var textSquirt="'hidden'"   
function showHelp(forWhat) {
	if (forWhat=="salary") {
		helpWindow.style.visibility="visible"
		helpWindow.innerHTML="Your basic gross annual salary net of National Insurance contributions and tax including any London Weighting and certain other allowances but excluding overtime payments. (Sunday overtime, however, is pensionable).<br/><br/>If you are a member of BT Retirement Plan or a New Entrant to BT Retirement Saving Scheme, a notional earnings cap will apply to your employer's payments. Your employer's payments will only be a percentage of your salary up to the notional earnings cap. Details can be found in the assumptions section.<br/><br/><a href='#' onclick=helpWindow.style.visibility="+textSquirt+"><img src='static/img/help_stop.gif' border='0'/></a>"
	}
	if (forWhat=="age") {
		helpAge.style.visibility="visible"
		helpAge.innerHTML="Please type your age next birthday.<br/><br/><a href='#' onclick=helpAge.style.visibility="+textSquirt+"><img src='static/img/help_stop.gif' border='0'/></a>"
	}
	if (forWhat=="sex") {
		helpSex.style.visibility="visible"	
		helpSex.innerHTML="Please select the relevant button (M for Male, F for Female)<br/><br/><a href='#' onclick=helpSex.style.visibility="+textSquirt+"><img src='static/img/help_stop.gif' border='0'/></a>"
	}
	
	if (forWhat=="hrsWorked") {
		helpSex.style.visibility="visible"	
		helpSex.innerHTML="Please type your total hours worked per week. The full time working hours per week is 36 hours.<br/><br/><a href='#' onclick=helpSex.style.visibility="+textSquirt+"><img src='static/img/help_stop.gif' border='0'/></a>"
	}	
	if (forWhat=="existingIncome") {
		helpIncome.style.visibility="visible"
		helpIncome.innerHTML="If you have been a member of a Final Salary or Defined Benefit pension scheme and you wish to include this:<br/>enter the amount of pension income you expect to receive each year. You will find this on a statement from the trustees who run the scheme. Please also input the age this pension is due to start. This age will also be shown on the statement from the trustees.<br/><br/>You should include the pension income amount given in today's terms, including current and future accruals (if any). This is what you might get back if it was reduced by future inflation.<br/><br/>Other yearly incomes can be included in this section, e.g. rental income, inheritance monies etc. The amount entered should reflect the amount you think will be paid from your chosen age expressed in today's terms.<br/><br/>Note: If you retire before the age you receive this yearly income, your projected income on retiral will not include this figure.<br/><br/><a href='#' onclick=helpIncome.style.visibility="+textSquirt+"><img src='static/img/help_stop.gif' border='0'/></a>"
	}	
	if (forWhat=="existingLump") {
		helpLump.style.visibility="visible"
		helpLump.innerHTML="If you have any other money purchase plans which you would like to have included in the calculation, please enter the transfer value or fund value. (This figure will be shown on your most recent statement for that plan). If you have more than one plan pension plan please add the transfer values together and input the total into this field.<br/><br/><a href='#' onclick=helpLump.style.visibility="+textSquirt+"><img src='static/img/help_stop.gif' border='0'/></a>"
	}
	if (forWhat=="bsp") {
		helpBSP.style.visibility="visible"	
		helpBSP.innerHTML="Tick this box if you want to exclude Basic State Pension from the calculation. If you reach State Pension age on or after 6 April 2010, you will need 30 qualifying years for a full Basic State Pension. Qualifying years are the years in which you have been paying, treated as paying or credited with National Insurance contributions.<br/><br/>Note: If you retire earlier than your State Pension Age, your projected income on retiral will not include this figure.<br/><br/><a href='#' onclick=helpBSP.style.visibility="+textSquirt+"><img src='static/img/help_stop.gif' border='0'/></a>"
	}	
	if (forWhat=="target") {
		helpTarget.style.visibility="visible"	
		helpTarget.innerHTML="Initially the target income field will default to the smaller of 75% of your gross annual salary and £70 000. Please overtype the default income or use the slider bar to increase/decrease this amount by moving the dial. You may be able to convert some of this pension to a tax-free lump sum.<br/><br/>Note: The upper limit has been chosen to reduce the likelihood of exceeding the Lifetime Allowance when you convert your pension to a monthly income (See the Tax Section below for details on Lifetime Allowance).<br/><br/><a href='#' onclick=helpTarget.style.visibility="+textSquirt+"><img src='static/img/help_stop.gif' border='0'/></a>"
	}	
	if (forWhat=="shortfall") {
		helpShortfall.style.visibility="visible"
		helpShortfall.innerHTML="This figure will be displayed after the calculation routine has run. The figure can be increased /decreased by changing the inputs using the various slider bars provided or by changing the figures in the interactive fields.<br/><br/><a href='#' onclick=helpShortfall.style.visibility="+textSquirt+"><img src='static/img/help_stop.gif' border='0'/></a>"
	}				
	if (forWhat=="totalIMV") {
		helpIMV.style.visibility="visible"		
		helpIMV.innerHTML="This figure has been calculated using the information you have given in the fields provided. This figure will change when you change the information you have provided on this screen.<br/><br/>Note: If you retire earlier than your State Pension Age, this figure will not include your Basic State Pension.<br/>If you retire earlier than the age your other yearly income is paid, this figure will not include that income figure.<br/><br/><a href='#' onclick=helpIMV.style.visibility="+textSquirt+"><img src='static/img/help_stop.gif' border='0'/></a>"
	}	
		
	if (forWhat=="nrd") {
		helpRetAge.style.visibility="visible"		
		helpRetAge.innerHTML="Currently, the State Pension Age for men is 65.  On 6 April 2010, the State Pension Age for women started to increase gradually from 60 to 65, to match men's. The Government has announced new proposals for increasing the State Pension Age if you were born between 6 April 1953 and 5 April 1960.<br/><br/>The proposal would mean women's State Pension Age would increase more quickly to 65 between April 2016 and November 2018.  From December 2018 the State Pension Age for both men and women would start to increase to reach 66 by April 2020.  The Government is also considering the timetable for future increases to the State Pension Age from 66 to 68.  Any change to the timetable needs the approval of Parliament.<br/><br/><a href='#' onclick=helpRetAge.style.visibility="+textSquirt+"><img src='static/img/help_stop.gif' border='0'/></a>"
	}		
	if (forWhat=="existEE") {
		helpInitialEE.style.visibility="visible"
		helpInitialEE.innerHTML="The calculator assumes your payments are an integer percentage of your gross monthly salary before tax and national insurance are deducted. It will also assume that your payments increase each year in line with a salary escalation rate of 4%.<br/>The minimum amount you can pay will be 2% for former SLFPP members, and 4% for New Entrants and former BTRP members.<br/><br/><a href='#' onclick=helpInitialEE.style.visibility="+textSquirt+"><img src='static/img/help_stop.gif' border='0'/></a>"
	}		
	if (forWhat=="plusEE") {
		helpIncrEE.style.visibility="visible"	
		helpIncrEE.innerHTML="The calculator assumes your payments are an integer percentage of your gross monthly salary before tax and national insurance are deducted. It will also assume that your payments increase each year in line with a salary escalation rate of 4%.<br/>The minimum amount you can pay will be 2% for former SLFPP members, and 4% for New Entrants and former BTRP members.<br/><br/><a href='#' onclick=helpIncrEE.style.visibility="+textSquirt+"><img src='static/img/help_stop.gif' border='0'/></a>"
	}	
	if (forWhat=="flatEE") {
		helpFlatEE.style.visibility="visible"	
		helpFlatEE.innerHTML="This field displays your proposed percentage as a flat amount in the first month.<br/><br/><a href='#' onclick=helpFlatEE.style.visibility="+textSquirt+"><img src='static/img/help_stop.gif' border='0'/></a>"
	}		
	if (forWhat=="helpItself") {
		helpItself.style.visibility="visible"	
		helpItself.innerHTML="Please hover over each field for detailed help and explanation of each item on the calculator.<br/><br/><a href='#' onclick=helpItself.style.visibility="+textSquirt+"><img src='static/img/help_stop.gif' border='0'/></a>"
	}			
	
	if (forWhat=="ER") {
		helpER.style.visibility="visible"		
		helpER.innerHTML="If your employer will make payments to your pension, you can enter the percentage or flat amount here.<br/>It is also assumed that this payment will increase each year in line with the Retail Price Index (RPI) - currently assumed to be 2.5% a year.<br/>Your employer or financial adviser can tell you the rules and limits for any employer payments. It is possible to overtype or use the slider bar to increase/decrease the amount.<br/>Some employers may offer to 'match' employee payments. You can use a combination of the employer and your own payments sliders to see what different 'matching' payments provide at retirement.<br/><br/><a href='#' onclick=helpER.style.visibility="+textSquirt+"><img src='static/img/help_stop.gif' border='0'/></a>"
	}	
	if (forWhat=="flatamnt") {
		helpIncrEE.style.visibility="visible"	
		helpIncrEE.innerHTML="Your employer will make additional payments to your pension based on your payments as a percentage of annual salary up to the notional earnings cap. The notional earnings cap will not apply to former SLFPP members.<br/><br/>For members making payments of 5% and above, a minimum employer payment of £1500 p.a. will be applied from 1 April 2009, increasing to £1500 p.a. from 1 April 2010. These payments will be applied pro rata for part time employees or for leavers during the year.<br/><br/><a href='#' onclick=helpIncrEE.style.visibility="+textSquirt+"><img src='static/img/help_stop.gif' border='0'/></a>"
	}			
	if (forWhat=="imv") {
		footer.innerHTML="This is your total projected pension income, including any income you may have from previous penions and the basic state pension.<br/><br/><a href='javascript:hideHelp()'><img src='static/img/help_stop.gif' border='0'/></a>"
	}				
					
}
