/* Modified Monday 12th November, 2007 by Dipen Narendra Kumar */
/* Copyright and All Rights Reserved*/
/* Implemting Catchment Area with build205.html, mapsBuild205.js*/
/* Uploaded as final version Friday 29th November, 2007*/

/*====================================================================*/

/*
*** Multiple dynamic combo boxes
*** by Mirko Elviro, 9 Mar 2005
*** Script featured and available on JavaScript Kit (http://www.javascriptkit.com)
***
***Please do not remove this comment
*/

// This script supports an unlimited number of linked combo boxes
// Their id must be "combo_0", "combo_1", "combo_2" etc.
// Here you have to put the data that will fill the combo boxes
// ie. data_2_1 will be the first option in the second combo box
// when the first combo box has the second option selected

/*====================================================================*/

/* Naming conventions used:
* primary - Primary Schools
* secondary - Seconday Schools
* primary_secondary - Primary and Secondary Schools (Combined)
* college - Colleges
* other - Anything else 
*/

//First combo box
//Area Names
data_1 = new Option("Select Area:");
data_2 = new Option("Leicestershire");
data_3 = new Option("Coventry");

//Second combo box
//Leicestershire County
data_1_1 = new Option("Primary School");
data_1_2 = new Option("Secondary School");
data_1_3 = new Option("College");
//End Leicestershire

//Coventry
data_2_1 = new Option("Secondary School");
data_2_2 = new Option("College");
data_2_3 = new Option("Specialist");
//End Coventry

//Third combo box
//Leicestershire Options List depending on User selection
//Primary Schools
data_1_1_1 = new Option("Barwell Infant School","leicestershire_Barwell_Infant_Primary_School");
data_1_1_2 = new Option("Newlands Community","leicestershire_Newlands_Community_Primary_School");
data_1_1_3 = new Option("Sketchly Hill Primary","leicestershire_Sketchly_Hill_Primary_School");
data_1_1_4 = new Option("Weavers Close CoE Primary","leicestershire_Earl_Shilton_Weavers_Close_CoE_Primary_School");
data_1_1_5 = new Option("Townlands CoE Primary","leicestershire_Earl_Shilton_Townlands_CoE_Primary_School");
data_1_1_6 = new Option("Battling Brook Primary","leicestershire_Hinckley_Battling_Brook_Community_Primary_School");
data_1_1_7 = new Option("Holliers Walk Primary","leicestershire_Hinckley_Holliers_Walk_Primary_School");
data_1_1_8 = new Option("Richmond Primary","leicestershire_Hinckley_Richmond_Primary_School");
data_1_1_9 = new Option("St Mary's CofE Primary","leicestershire_Hinckley_St_Marys_CofE_Primary_School");
data_1_1_10 = new Option("All Saints CofE Primary","leicestershire_Sapcote_All_Saints_CoE_Primary_School");
data_1_1_11 = new Option("Manorfield CofE Primary","leicestershire_Stoney_Stanton_Manorfield_CoE_Primary_School");
data_1_1_12 = new Option("Burbage Junior School","leicestershire_Burbage_Junior_Primary_School");
data_1_1_13 = new Option("Westfield Junior School","leicestershire_Hinckley_Westfield_Junior_Primary_School");

//Secondary Schools
data_1_2_1 = new Option("Ashby School","leicestershire_Ashby_Secondary_School_(with_6th_Form)");

//College
data_1_3_1 = new Option("William Bradford Community","leicestershire_Barwell_William_Bradford_Community_College_(with_6th_Form)");
data_1_3_2 = new Option("The Beauchamp College","leicestershire_Leicester_The_Beauchamp_College_(with_6th_Form)");
data_1_3_3 = new Option("Bosworth Community","leicestershire_Bosworth_Community_College_(with_6th_Form)");
data_1_3_4 = new Option("Countersthorpe Community","leicestershire_Countersthorpe_Community_College_(with_6th_Form)");
data_1_3_5 = new Option("Groby Community","leicestershire_Groby_Community_College_(with_6th_Form)");
data_1_3_6 = new Option("Guthlaxton College","leicestershire_Guthlaxton_College_(with_6th_Form)");
data_1_3_7 = new Option("John Cleveland College","leicestershire_Hinckley_John_Cleveland_College_(with_6th_Form)");
data_1_3_8 = new Option("Hind Leys Community","leicestershire_Hind_Leys_Community_College_(with_6th_Form)");
data_1_3_9 = new Option("King Edward VII School","leicestershire_Melton_Mowbray_King_Edward_VII_School_(with_6th_Form)");
data_1_3_10 = new Option("King Edward VII College","leicestershire_King_Edward_VII_Science_and_Sport_College_(with_6th_Form)");
data_1_3_11 = new Option("Longslade Community","leicestershire_Longslade_Community_College_(with_6th_Form)");
data_1_3_12 = new Option("Lutterworth College","leicestershire_Lutterworth_College_(with_6th_Form)");
data_1_3_13 = new Option("Rawlins Community","leicestershire_Rawlins_Community_College_(with_6th_Form)");
data_1_3_14 = new Option("Robert Smyth School","leicestershire_The_Robert_Smyth_School_(with_6th_Form)");
data_1_3_15 = new Option("Wreake Valley Community","leicestershire_Wreake_Valley_Community_College_(with_6th_Form)");
//End Leicestershire

//Secondary Schools
data_2_1_1 = new Option("President Kennedy School","coventry_President_Kennedy_Secondary_School");
data_2_1_2 = new Option("Foxford School & College","coventry_Foxford_School_and_Community_Arts_College");
data_2_1_3 = new Option("Stoke Park School","coventry_Stoke_Park_School");
data_2_1_4 = new Option("Whitley Abbey School","coventry_Whitley_Abbey_Community_School");

//College
data_2_2_1 = new Option("Barr's Hill School","coventry_Barrs_Hill_School_and_Community_College_(with_6th_Form)");
data_2_2_2 = new Option("Coundon Court School","coventry_Coundon_Court_Secondary_and_Community_College_(with_6th_Form)");
data_2_2_3 = new Option("Ernesford Grange School","coventry_Ernesford_Grange_School_and_Community_College_(with_6th_Form)");
data_2_2_4 = new Option("Finham Park School","coventry_Finham_Park_School_(with_6th_Form)");
data_2_2_5 = new Option("Lyng Hall School","coventry_Lyng_Hall_School_(with_6th_Form)");
data_2_2_6 = new Option("The Westwood School","coventry_The_Westwood_School_A_Technology_College_(with_6th_Form)");
data_2_2_7 = new Option("The Woodlands School","coventry_The_Woodlands_School_(with_6th_Form)");
data_2_2_8 = new Option("Woodway Park School","coventry_Woodway_Park_School_(with_6th_Form)");

//Other
data_2_3_1 = new Option("Caludon Castle School","covenrty_Caludon_Castle_Business_Enterprise_School");
data_2_3_2 = new Option("Sidney Stringer School","Sidney_Stringer_School");
//End Coventry

//Other Parameters
displaywhenempty="Selection Required Above"
valuewhenempty=-1

displaywhennotempty="Select:"
valuewhennotempty=0

function change(currentbox) {
	numb = currentbox.id.split("_");
	currentbox = numb[1];
	
	i=parseInt(currentbox)+1
	
	// I empty all combo boxes following the current one
	
	while ((eval("typeof(document.getElementById(\"combo_"+i+"\"))!='undefined'")) &&
			(document.getElementById("combo_"+i)!=null)) {
				son = document.getElementById("combo_"+i);
				// I empty all options except the first one (it isn't allowed)
				for (m=son.options.length-1;m>0;m--) son.options[m]=null;
				// I reset the first option
				son.options[0]=new Option(displaywhenempty,valuewhenempty)
				i=i+1
			}	
	
	// now I create the string with the "base" name ("stringa"), ie. "data_1_0"
	// to which I'll add _0,_1,_2,_3 etc to obtain the name of the combo box to fill
	
	stringa='data'
		i=0
		while ((eval("typeof(document.getElementById(\"combo_"+i+"\"))!='undefined'")) &&
				(document.getElementById("combo_"+i)!=null)) {
					eval("stringa=stringa+'_'+document.getElementById(\"combo_"+i+"\").selectedIndex")
					if (i==currentbox) break;
					i=i+1
				}		
		
		// filling the "son" combo (if exists)
		
		following=parseInt(currentbox)+1
	
	if ((eval("typeof(document.getElementById(\"combo_"+following+"\"))!='undefined'")) &&
			(document.getElementById("combo_"+following)!=null)) {
				son = document.getElementById("combo_"+following);
				stringa=stringa+"_"
					i=0
					while ((eval("typeof("+stringa+i+")!='undefined'")) || (i==0)) {
						
						// if there are no options, I empty the first option of the "son" combo
						// otherwise I put "-select-" in it
						
						if ((i==0) && eval("typeof("+stringa+"0)=='undefined'"))
							if (eval("typeof("+stringa+"1)=='undefined'"))
								eval("son.options[0]=new Option(displaywhenempty,valuewhenempty)")
								else
									eval("son.options[0]=new Option(displaywhennotempty,valuewhennotempty)")
									else
										eval("son.options["+i+"]=new Option("+stringa+i+".text,"+stringa+i+".value)")
										i=i+1
					}
					//son.focus()
					i=1
					combostatus=''
					cstatus=stringa.split("_")
				while (cstatus[i]!=null) {
					combostatus=combostatus+cstatus[i]
					i=i+1
				}
				return combostatus;
			}
}