function fun_valida(azione)
	{
	var a,b,strAlert,strAlert1;
	a = 0;
	b = 0;
	strAlert = "";
	strAlert1 = "";
	var regMail = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	var regPiva = new RegExp("^\d\d\d\d\d\d\d\d\d\d\d$");
	var regCodFisc = new RegExp("^\D\D\D\D\D\D\d\d\D\d\d\D\d\d\d\D$");
	
	if (azione == "ins")
		{
			
		if (document.registrati.nome.value == "")
			{
			a++;
			strAlert += "\n* compila il campo nome;";
			}
		if (document.registrati.cognome.value == "")
			{
			a++;
			strAlert += "\n* compila il campo cognome;";
			}
		if (!regMail.test(document.registrati.e_mail.value))
			{
			a++;
			strAlert += "\n* Inserisci un indirizzo e-mail valido;";
			}
		if (document.registrati.piva.value == "")
			{
			a++;
			strAlert += "\n* conpila il campo piva/codice fiscale;";
			}
		else if ((!document.registrati.piva.value.match(/^\d{11}$/)) && (!document.registrati.piva.value.match(/^\D{6}\d{2}\D\d{2}\D\d{3}\D$/)))
			{
			b++;
			strAlert1 += "\n* inserisci una P.IVA o codice fiscale valido;";
			}
		if (document.registrati.indirizzo.value == "")
			{
			a++;
			strAlert += "\n* compila il campo indirizzo;";
			}
		if (document.registrati.citta.value == "")
			{
			a++;
			strAlert += "\n* compila il campo cittą;";
			}
		if (!document.registrati.cap.value.match(/^\d{5}$/))
			{
			a++;
			strAlert += "\n* inserisci un CAP valido;";
			}
		if (document.registrati.prov.value == "-")
			{
			a++;
			strAlert += "\n* seleziona una provincia;";
			}
		if (!document.registrati.telefono.value.match(/^\d{5,}$/))
			{
			a++;
			strAlert += "\n* insersci un numero di telefono valido;";
			}
		if ((document.registrati.fax.value != "") && (!document.registrati.fax.value.match(/^\d{5,}$/)))
			{
			a++;
			strAlert += "\n* insersci un fax valido;";
			}
		if (document.registrati.psw.value == "")
			{
			a++;
			strAlert += "\n* specifica la password;";
			}
		else if (document.registrati.cpsw.value == "")
			{
			a++;
			strAlert += "\n* reinsersci la password per confermarla;";
			}
		else if (document.registrati.cpsw.value != document.registrati.psw.value)
			{
			b++;
			strAlert1 += "\n* Le password non corrispondono;";
			}
		// controllo presente solo nel caso di richiesta di contatto
		if (document.registrati.azione.value == "ins_contatto")
			{
			if (document.registrati.testo.value == "")
				{
				a++;
				strAlert += "\n* Specifica il testo della richiesta;";
				}
			}
		if (document.registrati.privacy.checked == false)
			{
			a++;
			strAlert += "\n* Leggi e accetta l'informativa sulla privacy;";
			}
		}
	else
		{
		// sezione dei campi non obbligatori
		if (document.registrati1.psw.value != "")
			{
			if (document.registrati1.cpsw.value != document.registrati1.psw.value)
				{
				b++;
				strAlert1 += "\n* Le password non corrispondono;";
				}
			}
		// sezione dati bancari
		var var_banca = document.registrati1.banca.value;
		var var_conto = document.registrati1.conto.value;
		var var_intestazione = document.registrati1.intestazione.value;
		var var_abi = document.registrati1.abi.value;
		var var_cab = document.registrati1.cab.value;
		var var_cin = document.registrati1.cin.value;
		if ((var_banca != "") || (var_conto != "") || (var_intestazione != "") || (var_abi != "") || (var_cab != "") || (var_cin != ""))
			{
			if (var_banca == "")
				{
				a++;
				strAlert += "\n* Inserisci il nome della Banca di appoggio;";
				}
			if (var_conto == "")
				{
				a++;
				strAlert += "\n* Inserisci il numero di conto corrente;";
				}
			else if (!var_conto.match(/^\d{5,}$/))
				{
				b++;
				strAlert1 += "\n* Numero di conto non valido;"
				}
			if (var_intestazione == "")
				{
				a++;
				strAlert += "\n* Inserisci l'intestatario del conto corrente;";
				}
			if (var_abi == "")
				{
				a++;
				strAlert += "\n* Inserisci il codice ABI del conto corrente;";
				}
			else if (!var_abi.match(/^\d{5}$/))
				{
				b++;
				strAlert1 += "\n* ABI non valido;"
				}
			if (var_cab == "")
				{
				a++;
				strAlert += "\n* Inserisci il codice CAB del conto corrente;";
				}
			else if (!var_cab.match(/^\d{5}$/))
				{
				b++;
				strAlert1 += "\n* CAB non valido;"
				}
			if (var_cin == "")
				{
				a++;
				strAlert += "\n* Inserisci il codice CIN del conto corrente;";
				}
			else if (!var_cin.match(/^\D$/))
				{
				b++;
				strAlert1 += "\n* CIN non valido;"
				}
			}
		if (document.registrati1.nome.value == "")
			{
			a++;
			strAlert += "\n* compila il campo nome;";
			}
		if (document.registrati1.cognome.value == "")
			{
			a++;
			strAlert += "\n* compila il campo cognome;";
			}
		if (!regMail.test(document.registrati1.e_mail.value))
			{
			a++;
			strAlert += "\n* Inserisci un indirizzo e-mail valido;";
			}
		if (document.registrati1.piva.value == "")
			{
			a++;
			strAlert += "\n* conpila il campo piva/codice fiscale;";
			}
		else if ((!document.registrati1.piva.value.match(/^\d{11}$/)) && (!document.registrati1.piva.value.match(/^\D{6}\d{2}\D\d{2}\D\d{3}\D$/)))
			{
			b++;
			strAlert1 += "\n* inserisci una P.IVA o codice fiscale valido;";
			}
		if (document.registrati1.indirizzo.value == "")
			{
			a++;
			strAlert += "\n* compila il campo indirizzo;";
			}
		if (document.registrati1.citta.value == "")
			{
			a++;
			strAlert += "\n* compila il campo cittą;";
			}
		if (!document.registrati1.cap.value.match(/^\d{5}$/))
			{
			a++;
			strAlert += "\n* inserisci un CAP valido;";
			}
		if (document.registrati1.prov.value == "-")
			{
			a++;
			strAlert += "\n* seleziona una provincia;";
			}
		if (!document.registrati1.telefono.value.match(/^\d{5,}$/))
			{
			a++;
			strAlert += "\n* insersci un numero di telefono valido;";
			}
		if ((document.registrati1.fax.value != "") && (!document.registrati1.fax.value.match(/^\d{5,}$/)))
			{
			a++;
			strAlert += "\n* insersci un fax valido;";
			}
		}
	
	
	err_tot=a+b;
	
	if ((a!=0)&&(b!=0))
		{
		window.alert("ATTENZIONE \n " + strAlert + "\n\nED INOLTRE: \n" + strAlert1 + "\n\nTOTALE ERRORI: " + err_tot);
		return false;
		}
	if ((a!=0)&&(b==0))
		{
		window.alert("ATTENZIONE \n " + strAlert + "\n\nTOTALE ERRORI: " + err_tot);
		return false;
		}
	if ((a==0)&&(b!=0))
		{
		window.alert("ATTENZIONE \n " + strAlert1 + "\n\nTOTALE ERRORI: " + err_tot)
		return false;
		}
	if ((a==0)&&(b==0))
		{ return true; }
	}