// FORM VALIDATION CHECK --------------------------------------------------------------

function ValidLength(item, len) 
{	
	return(item.length >=len);
}

function ValidEmail(item)
{	
	if(!ValidLength(item,5)) return false;
	if(item.indexOf('@',0) == -1) return false;
	if(item.indexOf('.',0) == -1) return false;
	if(item.indexOf(',',0) > 0) return false;
	return true;	
}

function sendform_de()
{	
	errfound = false;
	
	if (!ValidLength(document.Form1.TxtNome.value,3))
		error(document.Form1.TxtNome,"Bitte geben Sie Ihren Namen ein.");
	if (!ValidEmail(document.Form1.TxtMail.value))
		error(document.Form1.TxtMail, "Bitte geben Sie Ihre E-Mail Adresse ein.");
	if (document.Form1.TxtPrivacy.checked == 0)
		error(document.Form1.TxtPrivacy,"Sie müssen die Bedingungen des Gesetzes 675/96\nüber die Behandlung der persönlichen Daten\nzustimmen.");
	if (errfound == false)
		{
			document.Form1.BtnSend.disabled = true;
			document.Form1.BtnSend.value = '.................';
			document.Form1.submit();
		}
}

function sendform_it()
{	
	errfound = false;
	
	if (!ValidLength(document.Form1.TxtNome.value,3))
		error(document.Form1.TxtNome,"Inserire il proprio nome.");
	if (!ValidEmail(document.Form1.TxtMail.value))
		error(document.Form1.TxtMail, "Inserire il proprio indirizzo e-mail.");
	if (document.Form1.TxtPrivacy.checked == 0)
		error(document.Form1.TxtPrivacy,"Per proseguire è necessario acconsentire il trattamento dei dati personali.");
	if (errfound == false)
		{
			document.Form1.BtnSend.disabled = true;
			document.Form1.BtnSend.value = '.................';
			document.Form1.submit();
		}
}

function sendform_en()
{	
	errfound = false;
	
	if (!ValidLength(document.Form1.TxtNome.value,3))
		error(document.Form1.TxtNome,"Please enter your first name.");
	if (!ValidEmail(document.Form1.TxtMail.value))
		error(document.Form1.TxtMail, "Please enter your e-mail address.");
	if (document.Form1.TxtPrivacy.checked == 0)
		error(document.Form1.TxtPrivacy,"To continue you must agree the privacy statement.");
	if (errfound == false)
		{
			document.Form1.BtnSend.disabled = true;
			document.Form1.BtnSend.value = '.................';
			document.Form1.submit();
		}
}

function sendform_fr()
{	
	errfound = false;
	
	if (!ValidLength(document.Form1.TxtNome.value,3))
		error(document.Form1.TxtNome,"Insérer le propre prénom.");
	if (!ValidEmail(document.Form1.TxtMail.value))
		error(document.Form1.TxtMail, "Insérer le propre e-mail.");
	if (document.Form1.TxtPrivacy.checked == 0)
		error(document.Form1.TxtPrivacy,"Pour continuer est nécessaire consentir le traitement des données personnelles.");
	if (errfound == false)
		{
			document.Form1.BtnSend.disabled = true;
			document.Form1.BtnSend.value = '.................';
			document.Form1.submit();
		}
}

function error(elem, text)
{	
	if (errfound) return;
	window.alert(text)
	elem.select();
	elem.focus;
	errfound = true;
}
