var ajax = new sack();

function getCityList(sel)
{
	var subregionCode = sel.options[sel.selectedIndex].value;
	document.getElementById('city').options.length = 0;	// Empty city select box
	if(subregionCode.length>0){
		ajax.requestFile = 'ajax_get_towns.php?subregionCode='+subregionCode;	// Specifying which file to get
		ajax.onCompletion = createCities;	// Specify function that will be executed after file has been found
		ajax.runAJAX();		// Execute AJAX function
	}
}

function createCities()
{
	var obj = document.getElementById('city');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}

function getSubRegionList(sel)
{
	var regionCode = sel.options[sel.selectedIndex].value;
	document.getElementById('subregion').options.length = 0;	// Empty region select box
	document.getElementById('city').options.length = 1;	// Empty town select box except for instruction
	if(regionCode.length>0){
		ajax.requestFile = 'ajax_get_subregions.php?regionCode='+regionCode;	// Specifying which file to get
		ajax.onCompletion = createSubRegions;	// Specify function that will be executed after file has been found
		ajax.runAJAX();		// Execute AJAX function
	}
}

function createSubRegions()
{
	var obj = document.getElementById('subregion');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}