var ajax = new Array();

function getAreaList(sel)
{
	var regionid = sel.options[sel.selectedIndex].value;
	document.getElementById('area').options.length = 0;	// Empty city select box
	document.getElementById('city').options.length = 0;	// Empty city select box
	if(regionid.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = '/getdata.php?search_regionid='+regionid;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createAreas(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createAreas(index)
{
	var obj = document.getElementById('area');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}

function getCityList(sel)
{
	var areaid = sel.options[sel.selectedIndex].value;
	document.getElementById('city').options.length = 0;	// Empty city select box
	if(areaid.length>0)
	{
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = '/getdata.php?search_areaid='+areaid;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCities(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
	else
	{
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = '/getdata.php?search_areaid=0';	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCities(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createCities(index)
{
	var obj = document.getElementById('city');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}
