var Counties	= [];
var AllTowns	= [];

function loadIntoArray(value, key) {
	if(typeof(Counties[key]) == 'undefined') {
		Counties[key] = [];
	}
	Counties[key][Counties[key].length] = value;
	AllTowns[AllTowns.length] = value;
}

function loadSelectedTowns(county) {
	for(i=document.forms[0]['ctl00$cntMainPageText$txt_Town'].length; i>=0; i--) {
		document.forms[0]['ctl00$cntMainPageText$txt_Town'][i] = null;
	}
	// add a funky little delay in here, so the user knows something has happened...
	window.setTimeout('delayedLoading(' + county + ')', 400);
}

function delayedLoading(county) {
	
	document.forms[0]['ctl00$cntMainPageText$txt_Town'][0] = new Option('All', -2);

	// find which array to use (all or specific)
	if(county == -2) {
		var arrTowns = AllTowns;
	}
	else {
		var arrTowns = Counties[county];
	}
	// load into selections, providing that some data exists inside this array?
	if(arrTowns) {
		for(i=0; i<arrTowns.length; i++) {
			document.forms[0]['ctl00$cntMainPageText$txt_Town'][i + 1] = new Option(arrTowns[i]);
		}
	}
	document.forms[0]['ctl00$cntMainPageText$txt_Town'].selectedIndex = 0;
}
