function updateSelectComuni( codice_provincia ) {

	url = '/api/get_xml_lista_comuni.php?codep=' + escape(codice_provincia);
	sendHttpRequest( url );
	
}

/////////// AJAX
function handleHttpResponse() {
	if (http.readyState == 4) {
		if (http.responseText.indexOf('invalid') == -1) {
			
			var xmlDocument = http.responseXML;
			var list_name = xmlDocument.getElementsByTagName('list_name').item(0).firstChild.data;
			//alert(list_name);
			
			if ( list_name == 'comuni' ) {

				oSelect = document.getElementById("nominativo_city");
				
				clearSelect( oSelect, false );
				
			}
					
			var oList = xmlDocument.getElementsByTagName('item');
			//alert(oList.length);
			
			var insert_default_option = false;
			var first_option_label = '';
			var first_option_value = '';
			
			if (oList.length > 0) {
				//clearSelect( oSelect, false );
				fillSelectCustom( oSelect, oList, 'nome', 'nome', insert_default_option, first_option_label, first_option_value );
			} else {
				clearSelect( oSelect, true );
			}
			
			isWorking = false;
		}
	}
}

function postNominativo( theForm ) {
	
	fieldName			= document.getElementById('nominativo_name');
	fieldSurname		= document.getElementById('nominativo_surname');
	fieldEmail			= document.getElementById('nominativo_email');
	fieldTelCasa		= document.getElementById('nominativo_home');
	fieldTelUfficio		= document.getElementById('nominativo_office');
	fieldTelCell		= document.getElementById('nominativo_mobile');
	fieldProv			= document.getElementById('nominativo_prov');
	fieldComune			= document.getElementById('nominativo_city');
	fieldAutorizzazione	= document.getElementById('nominativo_autorizzazione');
	fieldTrasferimento	= document.getElementById('nominativo_trasferimento');
	
	errNome				= document.getElementById('err_nome');
	errCognome			= document.getElementById('err_cognome');
	errEmail			= document.getElementById('err_email');
	errTelefono			= document.getElementById('err_telefono');
	errProvincia		= document.getElementById('err_provincia');
	errComune			= document.getElementById('err_comune');
	errAutorizzazione	= document.getElementById('err_autorizzazione');
	errTrasferimento	= document.getElementById('err_trasferimento');
	
	var errore_nominativo = false;
	
	if (fieldName.value.length == 0) {
		errNome.style.display = '';
		fieldName.style.backgroundColor = '#ffff00';
		errore_nominativo = true;
	} else {
		errNome.style.display = 'none';
		fieldName.style.backgroundColor = '';
	}
	
	if (fieldSurname.value.length == 0) {
		errCognome.style.display = '';
		fieldSurname.style.backgroundColor = '#ffff00';
		errore_nominativo = true;
	} else {
		errCognome.style.display = 'none';
		fieldSurname.style.backgroundColor = '';
	}
	
	if (fieldEmail.value.length == 0) {
		errEmail.style.display = '';
		fieldEmail.style.backgroundColor = '#ffff00';
		errore_nominativo = true;
	} else {
		errEmail.style.display = 'none';
		fieldEmail.style.backgroundColor = '';
	}
	
	if (fieldTelCasa.value.length == 0 && fieldTelUfficio.value.length == 0 && fieldTelCell.value.length == 0) {
		errTelefono.style.display = '';
		fieldTelCasa.style.backgroundColor = '#ffff00';
		fieldTelUfficio.style.backgroundColor = '#ffff00';
		fieldTelCell.style.backgroundColor = '#ffff00';
		errore_nominativo = true;
	} else {
		errTelefono.style.display = 'none';
		fieldTelCasa.style.backgroundColor = '';
		fieldTelUfficio.style.backgroundColor = '';
		fieldTelCell.style.backgroundColor = '';
	}
	
	if (fieldProv.value.length == 0) {
		errProvincia.style.display = '';
		fieldProv.style.backgroundColor = '#ffff00';
		errore_nominativo = true;
	} else {
		errProvincia.style.display = 'none';
		fieldProv.style.backgroundColor = '';
	}
	
	if (fieldComune.value.length == 0) {
		errComune.style.display = '';
		fieldComune.style.backgroundColor = '#ffff00';
		errore_nominativo = true;
	} else {
		errComune.style.display = 'none';
		fieldComune.style.backgroundColor = '#ffff00';
	}

	if (fieldAutorizzazione.checked == false) {
		errAutorizzazione.style.display = '';
		errore_nominativo = true;
	} else {
		errAutorizzazione.style.display = 'none';
	}

	if (fieldTrasferimento.checked == false) {
		errTrasferimento.style.display = '';
		errore_nominativo = true;
	} else {
		errTrasferimento.style.display = 'none';
	}
	
	if ( errore_nominativo ) {
		
		document.getElementById('errore_nominativo').style.display = '';
		return false;
		
	} else {
		
		document.getElementById('errore_nominativo').style.display = 'none';
	}
	
	theForm.imp_mutuo.value		= document.form_importi.imp_mutuo.value;
	theForm.cod_ann.value		= document.form_importi.cod_ann.value;
	theForm.tasso.value			= document.form_importi.tasso.value;

	return true;
	
}
