function VerificaEmail(email) 
{
    var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
	if (!espressione.test(email))
	{
	    return false;
	}
    return true;
    
}

//Costruzione messsaggio errore utente
function AddStrMsgUser(msgUser,strToAdd)
{
	if (msgUser=="")
	{
		msgUser = strToAdd;
	}
	else
	{
		msgUser = msgUser + "\n" + strToAdd;
	}
	return msgUser;
}

//Controllo form contatti
function CheckFormContattiEng(which)
{
	var pass=true;
	var msg="";
	var msgcampo="";
	
	if (which.txtCognome.value == "") 
	{
		pass=false;
		msg = "- You must enter your Surname"
	}
	if (which.txtNome.value == "") 
	{
		pass=false;
		msgcampo= "- You must enter your name"
		msg=AddStrMsgUser(msg,msgcampo)
	}
	if (which.txtAzienda.value == "") 
	{
		pass=false;
		msgcampo= "- You must enter your Company name"
		msg=AddStrMsgUser(msg,msgcampo)
	}
	if (which.txtEmail.value == "") 
	{
		pass=false;
		msgcampo= "- You must enter your Email"
		msg=AddStrMsgUser(msg,msgcampo)
	}
	else
	{
	    var EmailOk = true;
	    EmailOk = VerificaEmail(which.txtEmail.value);
	    if (!EmailOk)
	    {
	        pass=false;
		    msgcampo= "- Invalid Email address"
		    msg=AddStrMsgUser(msg,msgcampo)
	    }
	}
	if (!which.chkContattoPreventivo.checked && !which.chkAltro.checked && !which.chkMaggInfo.checked)
	{
	    pass=false;
		msgcampo= "- You must indicate at least 1 request"
		msg=AddStrMsgUser(msg,msgcampo)
	}
	
	//
	if (!pass)
	{
		msg = "There are some errors in the form:" + "\n" + msg;
		alert(msg);
	}
	return pass;
	
}
//Controllo form contatti
function CheckFormContattiIta(which)
{
	var pass=true;
	var msg="";
	var msgcampo="";
	
	if (which.txtCognome.value == "") 
	{
		pass=false;
		msg = "- Cognome non inserito"
	}
	if (which.txtNome.value == "") 
	{
		pass=false;
		msgcampo= "- Nome non inserito"
		msg=AddStrMsgUser(msg,msgcampo)
	}
	if (which.txtAzienda.value == "") 
	{
		pass=false;
		msgcampo= "- Azienda non inserita"
		msg=AddStrMsgUser(msg,msgcampo)
	}
	if (which.txtEmail.value == "") 
	{
		pass=false;
		msgcampo= "- Email non inserita"
		msg=AddStrMsgUser(msg,msgcampo)
	}
	else
	{
	    var EmailOk = true;
	    EmailOk = VerificaEmail(which.txtEmail.value);
	    if (!EmailOk)
	    {
	        pass=false;
		    msgcampo= "- Email non valida"
		    msg=AddStrMsgUser(msg,msgcampo)
	    }
	}
	if (!which.chkContattoPreventivo.checked && !which.chkAltro.checked && !which.chkMaggInfo.checked)
	{
	    pass=false;
		msgcampo= "- Nessuna richiesta selezionata"
		msg=AddStrMsgUser(msg,msgcampo)
	}
	
	//
	if (!pass)
	{
		msg = "Sono presenti degli errori nel form:" + "\n" + msg;
		alert(msg);
	}
	return pass;
	
}
