
function select_country(id) {
	JSBASE.getEl("country").length = 0;
	JSBASE.getEl("country").options[ JSBASE.getEl("country").length ] = new Option( "Please Select" );
	
	for( var key in country ) {
		var selected = ( key == id ) ? true : false ;
		JSBASE.getEl("country").options[ JSBASE.getEl("country").length ] = new Option( country[key] , key , selected , selected );
		if( selected ) {
			select_county(key);
		}
	}
}

function select_county(id) {
	JSBASE.getEl("county").length = 0;
	JSBASE.getEl("county").options[ JSBASE.getEl("county").length ] = new Option( "Please Select" );
	
	JSBASE.getEl("council").length = 0;
	JSBASE.getEl("council").options[ JSBASE.getEl("council").length ] = new Option( "Please Select" );
	
	JSBASE.getEl("school").length = 0;
	JSBASE.getEl("school").options[ JSBASE.getEl("school").length ] = new Option( "Please Select" );
	
	for( var key in county ) {
		if( county[key][0] == id ) {
			JSBASE.getEl("county").options[ JSBASE.getEl("county").length ] = new Option( county[key][1] , key );
		}
	}
}

function select_council(id) {
	JSBASE.getEl("council").length = 0;
	JSBASE.getEl("council").options[ JSBASE.getEl("council").length ] = new Option( "Please Select" );
	
	JSBASE.getEl("school").length = 0;
	JSBASE.getEl("school").options[ JSBASE.getEl("school").length ] = new Option( "Please Select" );
	
	for( var key in borough ) {
		if( borough[key][0] == id ) {
			JSBASE.getEl("council").options[ JSBASE.getEl("council").length ] = new Option( borough[key][1] , key );
		}
	}
}

function select_school(id) {
	JSBASE.getEl("school").length = 0;
	for( var key in school ) {
		if( school[key][0] == id ) {
			JSBASE.getEl("school").options[ JSBASE.getEl("school").length ] = new Option( school[key][2] , school[key][1] );
		}
	}
}

function init_feedback() {

	// set defaults
	select_country(0);
		
	// setup events
	JSBASE.addEvent( JSBASE.getEl("country"), "change", function(e) {
	
		var index = JSBASE.getEl("country").options.selectedIndex;
		var id = JSBASE.getEl("country").options[index].value;
		select_county(id);
	
	} );
	JSBASE.addEvent( JSBASE.getEl("county"), "change", function(e) {
	
		var index = JSBASE.getEl("county").options.selectedIndex;
		var id = JSBASE.getEl("county").options[index].value;
		select_council(id);
	
	} );
	JSBASE.addEvent( JSBASE.getEl("council"), "change", function(e) {
	
		var index = JSBASE.getEl("council").options.selectedIndex;
		var id = JSBASE.getEl("council").options[index].value;
		select_school(id);
	
	} );
}


