function VerificaCampi(theForm, ListaCampi)
{
	var CampiOb;
	CampiOb = ListaCampi.split(":");
	for (i=0; i < CampiOb.length; i++)
	{
		if (theForm[CampiOb[i]].value == "" &&
			theForm[CampiOb[i]].type != "submit" &&
 			theForm[CampiOb[i]].type != "reset" &&
			theForm[CampiOb[i]].type != "button" &&
			theForm[CampiOb[i]].type != "hidden")
		{
			alert("Non sono stati compilati tutti i campi obbligatori");
			theForm[CampiOb[i]].focus();
			return false;
		}
	}
	
	// test if valid email address, must have @ and .
	var checkEmail = "@.";
	var checkStr = theForm.Email.value;
	var EmailValid = false;
	var EmailAt = false;
	var EmailPeriod = false;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkEmail.length;  j++)
		{
			if (ch == checkEmail.charAt(j) && ch == "@") EmailAt = true;
			if (ch == checkEmail.charAt(j) && ch == ".") EmailPeriod = true;
	  	if (EmailAt && EmailPeriod) break;
	  	if (j == checkEmail.length) break;
		}
		// if both the @ and . were in the string
		if (EmailAt && EmailPeriod)
		{
			EmailValid = true
			break;
		}
	}
	if (!EmailValid)
	{
		alert("L'indirizzo email deve contenere \"@\" e \".\".");
		theForm.Email.focus();
		return (false);
	}
	
	// check if both email fields are the same
	if (theForm.Email.value != theForm.Email2.value)
	{
		alert("L'indirizzo email e l'indirizzo email di conferma non sono uguali.");
		theForm.Email2.focus();
		return (false);
	}

	// require at least 5 characters in the password field
	if (theForm.Password.value.length < 5)
	{
		alert("Inserire una password di almeno 5 caratteri.");
		theForm.Password.focus();
		return (false);
	}

	// check if both password fields are the same
	if (theForm.Password.value != theForm.Password2.value)
	{
		alert("La password e la password di controllo non sono uguali.");
		theForm.Password2.focus();
		return (false);
	}
	
	// check if consenso = 1
	if (theForm.Consenso.value != 1)
	{
		alert("Il campo di dichiarazione di presa visione e' obbligatorio.");
		theForm.Consenso.focus();
		return (false);
	}
	
	return (true);
}