<!--- Code to calculate Starting Age --->
function Calculate() {
	var m = document.AgeCalc.Month.value
	var y = document.AgeCalc.Year.value
	//var textvar = "Children born 1 Jan 2001 to 31 December 2001 will start Year 1 in 2007. Enrolment in Prep will be considered if they are assessed and it is determined that they will not be ready to start Year 1 before 2008.";
	//var text2002 = "Students born 1 July 2002 to 31 december 2002 would normally be eligible for preschool in 2007. However, with preschool finishing at the end of 2006, parents will need to make other arrangements for their children undtil 2008 when they will be eligible for Prep.";

	if (y != 0 && m != 0) {
		if (y == 2001) { 
			document.AgeCalc.PPStart.value = "-----"; 
		    document.AgeCalc.Y1Start.value = "2007"; 
			toggleDiv('div1',1);
			toggleDiv('div2',0);			
			toggleDiv('div3',0);
			}
		else if (y == 2002 && m < 7)  {
			document.AgeCalc.PPStart.value = "2007"; 
		    document.AgeCalc.Y1Start.value = "2008";
			toggleDiv('div2',1);	
			toggleDiv('div3',1);				
			}
		else if (y == 2002 && m >= 7)  {
			document.AgeCalc.PPStart.value = "2008"; 
		    document.AgeCalc.Y1Start.value = "2009"; 
			toggleDiv('div2',1);
			}
		else if (y == 2003 && m < 7)  {
			document.AgeCalc.PPStart.value = "2008"; 
		    document.AgeCalc.Y1Start.value = "2009"; 
			
			}
		else if (y == 2003 && m >= 7 || y == 2004 && m < 7)  {
			document.AgeCalc.PPStart.value = "2009"; 
		    document.AgeCalc.Y1Start.value = "2010";
			toggleDiv('div4',1);			
			}
		else if (y == 2004 && m >= 7 || y == 2005 && m < 7)  {
			document.AgeCalc.PPStart.value = "2010"; 
		    document.AgeCalc.Y1Start.value = "2011";
			}
			
		else if (y == 2005 && m >= 7 || y == 2006 && m < 7)  {
			document.AgeCalc.PPStart.value = "2011"; 
		    document.AgeCalc.Y1Start.value = "2012";
			}
			
		else if (y == 2006 && m >= 7 || y == 2007 && m < 7)  {
			document.AgeCalc.PPStart.value = "2012"; 
		    document.AgeCalc.Y1Start.value = "2013";
			}

		else if (y == 2007 && m >= 7 || y == 2008 && m < 7)  {
			document.AgeCalc.PPStart.value = "2013"; 
		    document.AgeCalc.Y1Start.value = "2014";
			}

		else if (y == 2008 && m >= 7 || y == 2009 && m < 7)  {
			document.AgeCalc.PPStart.value = "2014"; 
		    document.AgeCalc.Y1Start.value = "2015";
			}
			
		else if (y == 2009 && m >= 7 || y == 2010 && m < 7)  {
			document.AgeCalc.PPStart.value = "2015"; 
		    document.AgeCalc.Y1Start.value = "2016";			
			}	
			
		else if (y == 2010 && m >= 7)  {
			document.AgeCalc.PPStart.value = "2016"; 
		    document.AgeCalc.Y1Start.value = "2017";			
			}				
						
	
	}
}



<!--- Protect the starting year fields by moving focus to the month field --->
function MoveCursor() {
	document.AgeCalc.Month.focus(); 
}

<!--- Clear the Starting Year fields when a birth month or year is changed --->
function Clear() {
	document.AgeCalc.PPStart.value = "";
	document.AgeCalc.Y1Start.value = ""; 
	toggleDiv('div1',0);
	toggleDiv('div2',0);
	toggleDiv('div3',0);

}

<!-- display text
function toggleDiv(id,flagit) {
if (flagit=="1"){
if (document.layers) document.layers[''+id+''].visibility = "show"
else if (document.all) document.all[''+id+''].style.visibility = "visible"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
}
else
if (flagit=="0"){
if (document.layers) document.layers[''+id+''].visibility = "hide"
else if (document.all) document.all[''+id+''].style.visibility = "hidden"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
}
}