function ValidaUtente()
{
	if (document.forms[0].nome.value == "" ||
		document.forms[0].cognome.value == "" ||
		document.forms[0].azienda.value == "" ||
		document.forms[0].email.value == "" 	)
	{
		alert("Compilare tutti i campi obbligatori!");
		return false;
	}
	else
	{
		if (!checkMail(document.forms[0].email.value))
		{
			alert("Indirizzo email non valido!");
			return false;
		}
		else
		{
			return true;
		}
	}
}

function ValidaRegistrazione()
{
	if (document.forms[0].username.value == "" ||
		document.forms[0].password.value == "")
	{
		alert("Compilare tutti i campi!");
		return false;
	}
	else
	{
		if (!checkMail(document.forms[0].username.value))
		{
			alert("Indirizzo email non valido!");
			return false;
		}
		else
		{
			return true;
		}
	}	
}

function ValidaMessaggio()
{
	if (document.forms[0].txtNome.value == "" ||
		document.forms[0].txtCognome.value == "" ||
		document.forms[0].txtEmail.value == "" ||
		document.forms[0].messaggio.value == ""
		)
	{
		alert("Compilare tutti i campi");
		return false;
	}
	else
	{
		
		if (!checkMail(document.forms[0].txtEmail.value))
		{
			alert("Indirizzo email non valido!");
			return false;
		}
		else
		{
			return true;
		}
	}
}

function checkMail(email)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return (filter.test(email));
}
