// ----------------------  AJAX ----------------------

var ajax = new Array();
var ajax2 = new Array();

function getCityList(sel) {
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('Prov_cerca').options.length = 0;	// Empty city select box
	
	var obj2 = document.getElementById('Com_cerca');
	obj2.options.length = 0;	
	
	if(countryCode.length > 0){
		var index = ajax.length;
		ajax[index] = new sack();		
		ajax[index].requestFile = 'getCities.php?countryCode=' + countryCode;	// 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('Prov_cerca');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}



function getComList(sel) {
	var provinciaCode = sel.options[sel.selectedIndex].value;
	document.getElementById('Com_cerca').options.length = 0;	// Empty city select box
	if(provinciaCode.length > 0){
		var index = ajax2.length;
		ajax2[index] = new sack();
		ajax2[index].requestFile = 'getCities.php?provinciaCode=' + provinciaCode;	// Specifying which file to get
		ajax2[index].onCompletion = function(){ createComuni(index) };	// Specify function that will be executed after file has been found
		ajax2[index].runAJAX();		// Execute AJAX function
	}
}

function createComuni(index) {
	var obj2 = document.getElementById('Com_cerca');
	eval(ajax2[index].response);	// Executing the response from Ajax as Javascript code	
}

// ----------------------  FINE AJAX ----------------------