// JavaScript Document
function verify(f){
	if(f.name=="registrazione"){
		if (f.nick.value == ""){
			errorString = "Il campo NOME UTENTE è obbligatorio";
			f.nick.focus();
			alert(errorString);
			return false;
		}
		
		if (f.password.value == "")
		{
			errorString = "Il campo PASSWORD è obbligatorio";
			f.password.focus();
			alert(errorString);
			return false;
		}
		
		if (f.password2.value == "")
		{
			errorString = "Scrivere di nuovo la PASSWORD";
			f.password2.focus();
			alert(errorString);
			return false;
		}
		
		if (f.password2.value != f.password.value)
		{
			errorString = "Le PASSWORD inserite non coincidono";
			f.password.focus();
			alert(errorString);
			return false;
		}
		
		if (f.nome.value == ""){
			errorString = "Il campo NOME è obbligatorio";
			f.nome.focus();
			alert(errorString);
			return false;
		}
		
		if (f.cognome.value == "")
		{
			errorString = "Il campo COGNOME è obbligatorio";
			f.cognome.focus();
			alert(errorString);
			return false;
		}
		
		Ctrl = f.email;
		result = false;
		space_tokens = Ctrl.value.split(" ");
		if(space_tokens.length == 1)
		{
			at_tokens = Ctrl.value.split("@");
			if(at_tokens.length == 2)
			{
				if(at_tokens[1].length != 0)
				{
					right_dot_tokens = at_tokens[1].split(".");
					if(right_dot_tokens.length >= 2)
					{
						if (right_dot_tokens[1].length != 0)
						{
							result=true;
						}
					}
				}
			}
		}
		
		if (!result)
		{
			errorString = "Inserisci un'indirizzo E-MAIL valido";
			alert(errorString);
			Ctrl.focus();
			return (result);
		}
		
		if (f.email2.value == "")
		{
			errorString = "Scrivere di nuovo l/'EMAIL";
			f.email2.focus();
			alert(errorString);
			return false;
		}
		
		if (f.email2.value != f.email.value)
		{
			errorString = "Le EMAIL inserite non coincidono";
			f.email.focus();
			alert(errorString);
			return false;
		}
		
		if (f.regolamento.value == "NO")
		{
			errorString = "E' necessario accettare esplicitamente il regolamento di CINEMONITOR";
			alert(errorString);
			f.regolamento.focus();
			return false;
		}
		
		if (f.privacy.value == "NO"){
			errorString = "E' necessario il consenso esplicito al TRATTAMENTO DEI DATI PERSONALI";
			alert(errorString);
			return false;
		}
	} else if(f.name=="mod_profilo"){
		if (f.nick.value == ""){
			errorString = "Il campo NOME UTENTE è obbligatorio";
			f.nick.focus();
			alert(errorString);
			return false;
		}
		
		if (f.password2.value != f.password.value)
		{
			alert(f.password2.value+" "+f.password.value);
			errorString = "Le PASSWORD inserite non coincidono";
			f.password.focus();
			alert(errorString);
			return false;
		}
		
		if (f.nome.value == ""){
			errorString = "Il campo NOME è obbligatorio";
			f.nome.focus();
			alert(errorString);
			return false;
		}
		
		if (f.cognome.value == "")
		{
			errorString = "Il campo COGNOME è obbligatorio";
			f.cognome.focus();
			alert(errorString);
			return false;
		}
		
		Ctrl = f.email;
		result = false;
		space_tokens = Ctrl.value.split(" ");
		if(space_tokens.length == 1)
		{
			at_tokens = Ctrl.value.split("@");
			if(at_tokens.length == 2)
			{
				if(at_tokens[1].length != 0)
				{
					right_dot_tokens = at_tokens[1].split(".");
					if(right_dot_tokens.length >= 2)
					{
						if (right_dot_tokens[1].length != 0)
						{
							result=true;
						}
					}
				}
			}
		}
		
		if (!result)
		{
			errorString = "Inserisci un'indirizzo E-MAIL valido";
			alert(errorString);
			Ctrl.focus();
			return (result);
		}
	}
}