// JavaScript Document
function verify(f){
	if(f.name=="registrazione"){
		if (f.nome.value == ""){
			errorString = "NOME obbligatorio";
			f.nome.focus();
			alert(errorString);
			return false;
		}
		
		if (f.userid.value == "")
		{
			errorString = "USER ID obbligatoria";
			f.userid.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 = "Inserire indirizzo EMAIL valido";
			alert(errorString);
			Ctrl.focus();
			return (result);
		}
		if (!f.privacy.checked) {
			errorString = "E' obbligatorio accettare l'informativa sulla PRIVACY";
			f.privacy.focus();
			alert(errorString);
			return false;
		}

	} else if(f.name=="password_reminder"){
		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 = "Inserire indirizzo EMAIL valido";
			alert(errorString);
			Ctrl.focus();
			return (result);
		}
	}
	else if(f.name=="frm_catalogo"){
		if (f.nome.value == ""){
			errorString = "NOME obbligatorio";
			f.nome.focus();
			alert(errorString);
			return false;
		}
			if (f.cognome.value == "")
		{
			errorString = "COGNOME obbligatorio";
			f.cognome.focus();
			alert(errorString);
			return false;
		}
		if (f.indirizzo.value == "")
		{
			errorString = "INDIRIZZO obbligatorio";
			f.indirizzo.focus();
			alert(errorString);
			return false;
		}
		if (f.comune.value == "")
		{
			errorString = "CITTA' obbligatoria";
			f.comune.focus();
			alert(errorString);
			return false;
		}
		if (f.cap.value == "")
		{
			errorString = "CAP obbligatorio";
			f.cap.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 = "Inserire indirizzo EMAIL valido";
			alert(errorString);
			Ctrl.focus();
			return (result);
		}
		if (!f.privacy.checked) {
			errorString = "E' obbligatorio accettare l'informativa sulla PRIVACY";
			f.privacy.focus();
			alert(errorString);
			return false;
		}
	}
	else if(f.name=="ricerca"){
		if (f.valore.value == ""){
			errorString = "Inserire un prodotto da ricercare";
			f.valore.focus();
			alert(errorString);
			return false;
		}
	}
	else if(f.name=="frm_contatti"){
		if (f.nome.value == ""){
			errorString = "NOME obbligatorio";
			f.nome.focus();
			alert(errorString);
			return false;
		}
		
		/*if (f.cognome.value == "")
		{
			errorString = "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 = "Inserire indirizzo EMAIL valido";
			alert(errorString);
			Ctrl.focus();
			return (result);
		}
		
		if (f.commento.value == "")
		{
			errorString = "TESTO obbligatorio";
			f.commento.focus();
			alert(errorString);
			return false;
		}
		if (!f.privacy.checked) {
			errorString = "E' obbligatorio accettare l'informativa sulla PRIVACY";
			f.privacy.focus();
			alert(errorString);
			return false;
		}
	} else if(f.name=="frm_preventivo"){
		if (f.nome.value == ""){
			errorString = "NOME obbligatorio";
			f.nome.focus();
			alert(errorString);
			return false;
		}
		
		if (f.cognome.value == "")
		{
			errorString = "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 = "Inserire indirizzo EMAIL valido";
			alert(errorString);
			Ctrl.focus();
			return (result);
		}
		
		if (f.oggetto.value == "")
		{
			errorString = "OGGETTO obbligatorio";
			f.oggetto.focus();
			alert(errorString);
			return false;
		}
		
		if (f.testo.value == "")
		{
			errorString = "TESTO obbligatorio";
			f.testo.focus();
			alert(errorString);
			return false;
		}
		if (!f.privacy.checked) {
			errorString = "E' obbligatorio accettare l'informativa sulla PRIVACY";
			f.privacy.focus();
			alert(errorString);
			return false;
		}
	} else if(f.name=="mod_profilo"){	
		if (f.nome.value == ""){
			errorString = "NOME obbligatorio";
			f.nome.focus();
			alert(errorString);
			return false;
		}
		
		/*if (f.cognome.value == "")
		{
			errorString = "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 = "Inserire un indirizzo EMAIL valido";
			alert(errorString);
			Ctrl.focus();
			return (result);
		}

		if (f.userid.value == ""){
			errorString = "USER ID obbligatoria";
			f.userid.focus();
			alert(errorString);
			return false;
		}

		if ((f.password.value != "") && ((f.new_pass.value != "") && (f.new_pass.value != f.new_pass2.value)))
		{
			errorString = "Le PASSWORD inserite non coincidono";
			f.password.focus();
			alert(errorString);
			return false;
		}
	}
}
