/**
 * @author matteo
 * 
 * Al cambio di select box aggiunte due campi nascosti
 * updatePlace == 1
 * destination == codice destinazione
 */
function travelsearch_onSelectChange(){

	
    formSearch = this.form;
	//hidden = document.createElement("input");
	
	hidden = $("<input/>");
	hidden.attr("type",'hidden');
	hidden.attr("name",'updatePlace');
	hidden.val(1);
    $(formSearch).append(hidden);
	
	
	
	var curId = $(".place-list").index(this);
	$(".place-list:gt("+curId+")").val(0);
	var prevIdx = curId-1;
	
	
	
//	hidden = $("#destination");
//	if((val = parseInt($(this).val())) && !isNaN(val)) {
//		hidden.val($(this).val());
//	}
//	// se ho selezionato il valore vuoto è perche voglio tornare indietro
//	// devo pure azzerare i select successivi, devo selezionarli e poi fare
//	// uno slice
//	else if(pVal = $(".place-list").eq(prevIdx).val()){
//		hidden.val(pVal);
//		
//	}
//	else {
//		console.log("Mi fotto");
//		hidden.val("");
//	}
	
	formSearch.submit();
}

