function select_province() {
	var regione = document.getElementById("selReg").value;
	numerorandom = Math.random();
	$.get("/ajax/select_province.php", {regione: regione}, function(data) {
		$("#selPRov").empty();
		$("#selProv").append(data);
	});
	return false;
}

function select_comuni() {
	var provincia = document.getElementById("selProv").value;
	numerorandom = Math.random();
	$.get("/ajax/select_comuni.php", {provincia: provincia}, function(data) {
		$("#selCom").empty();
		$("#selCom").append(data);
	});
	return false;
}

function cfpiva() {
	var tipo = document.getElementById("selTipo").value;
	if(tipo == "1") {
		$("#codicefiscale").html("Codice fiscale");
		$("#ragionesociale").html("Contatto telefonico");
		$("#logo-azienda").hide();
		$("#descrizione-azienda").hide();
	} else {
		$("#codicefiscale").html("Partita IVA");
		$("#ragionesociale").html("Ragione sociale");
		$("#logo-azienda").show();
		$("#descrizione-azienda").show();
		
	}
}

function ordina() {
	var ordine = document.getElementById("ricerca_ordine");
	var regione = document.getElementById("ricerca_regione");
	var provincia = document.getElementById("ricerca_provincia");
	var tipoannuncio = document.getElementById("ricerca_tipoannuncio");
	
	var url = "/cerca.php?order="+ordine.value;
	if(regione != null) var url = url+"&regione="+regione.value;
	if(provincia != null) var url = url+"&provincia="+provincia.value;
	if(tipoannuncio != null) var url = url+"&tipoannuncio="+tipoannuncio.value;
	
	window.location = url;
}