var ajax = new sack();

var ajaxFilePath = "ajax-list-store.php";

function getComList(sel) {
	var prov = sel.options[sel.selectedIndex].value;
	document.getElementById('comune').options.length = 0;
	//document.getElementById('btt_cerca').disabled = true;
	document.getElementById('point').options.length = 1;
	//document.getElementById('point').selectedIndex  = 0;
	if(prov.length>0){
		ajax.requestFile = ajaxFilePath+'?pr='+prov;	// Specifying which file to get
		ajax.onCompletion = createComboProv;	// Specify function that will be executed after file has been found
		ajax.runAJAX();		// Execute AJAX function
	}
}

function getPointList(sel,hiddenFilm) {
	var provincia = document.getElementById('provincia');
	var punto_vendita = document.getElementById('point');
	
	if (hiddenFilm) var prov = document.form_account.provincia.value;
	else var prov = provincia.options[provincia.selectedIndex].value;
	
	punto_vendita.options.length = 0;	// Empty city select box
	
	var comune = sel.options[sel.selectedIndex].value;
	//comune = comune.replace('&', '%26');
	
	if(prov.length>0){
			ajax.requestFile = ajaxFilePath+'?pr='+prov+'&com='+comune;	// Specifying which file to get
			ajax.onCompletion = createComboCom;	// Specify function that will be executed after file has been found
			ajax.runAJAX();		// Execute AJAX function
			//if (prov == 0) document.getElementById('btt_cerca').disabled = true;
			//else document.getElementById('btt_cerca').disabled = false;
	}
	else {
			comune.options[comune.options.length] = new Option('Comune','');
			document.getElementById('btt_cerca').disabled = true;
	}
}


function createComboProv() {
	var obj = document.getElementById('comune');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}

function createComboCom() {
	var obj = document.getElementById('point');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}