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 sendformDE()
{	
	errfound = false;

	var data_dal = document.Form1.TxtDal.value.split("/");
	var data_al = document.Form1.TxtAl.value.split("/");
	document.Form1.dayFrom.value = data_dal[0];
	document.Form1.monthFrom.value = data_dal[1];
	document.Form1.yearFrom.value = data_dal[2];
	document.Form1.dayTo.value = data_al[0];
	document.Form1.monthTo.value = data_al[1];
	document.Form1.yearTo.value = data_al[2];
	
	if (!ValidLength(document.Form1.firstname.value,3))
		error(document.Form1.firstname,"Bitte geben Sie Ihren Namen ein.");
	if (!ValidLength(document.Form1.lastname.value,3))
		error(document.Form1.lastname,"Bitte geben Sie Ihren Nachnamen ein.");
	if (!ValidLength(document.Form1.street.value,3))
		error(document.Form1.street,"Bitte geben Sie Ihre Adresse ein.");
	if (!ValidLength(document.Form1.zipcode.value,3))
		error(document.Form1.zipcode,"Bitte geben Sie Ihre PLZ ein.");
	if (!ValidLength(document.Form1.city.value,3))
		error(document.Form1.city,"Bitte geben Sie den Namen Ihrer Stadt ein.");
	if (!ValidLength(document.Form1.country.value,3))
		error(document.Form1.country,"Bitte geben Sie Ihr Land ein.");
	if (!ValidEmail(document.Form1.email.value))
		error(document.Form1.email, "Bitte geben Sie Ihre E-Mail Adresse ein.");
	if (document.Form1.TxtAcconsento.checked == 0)
		error(document.Form1.TxtAcconsento,"Sie müssen die Bedingungen des Gesetzes 675/96\nüber die Behandlung der persönlichen Daten\nzustimmen.");
	if (errfound == false)
		{
			document.Form1.TxtCheck03.value = 'validato';
			document.Form1.BtnSend.disabled = true;
			document.Form1.BtnSend.value = 'Ihre Anfrage wird gesendet...';
			document.Form1.submit();
		}
}

function sendformIT()
{	
	errfound = false;

	var data_dal = document.Form1.TxtDal.value.split("/");
	var data_al = document.Form1.TxtAl.value.split("/");
	document.Form1.dayFrom.value = data_dal[0];
	document.Form1.monthFrom.value = data_dal[1];
	document.Form1.yearFrom.value = data_dal[2];
	document.Form1.dayTo.value = data_al[0];
	document.Form1.monthTo.value = data_al[1];
	document.Form1.yearTo.value = data_al[2];
	
	if (!ValidLength(document.Form1.firstname.value,3))
		error(document.Form1.firstname,"Inserire il proprio nome.");
	if (!ValidLength(document.Form1.lastname.value,3))
		error(document.Form1.lastname,"Inserire il proprio cognome.");
	if (!ValidLength(document.Form1.street.value,3))
		error(document.Form1.street,"Inserire il proprio indirizzo.");
	if (!ValidLength(document.Form1.zipcode.value,3))
		error(document.Form1.zipcode,"Inserire il proprio CAP di residenza.");
	if (!ValidLength(document.Form1.city.value,3))
		error(document.Form1.city,"Inserire il nome della città di residenza.");
	if (!ValidLength(document.Form1.country.value,3))
		error(document.Form1.country,"Inserire il nome del paese di residenza.");
	if (!ValidEmail(document.Form1.email.value))
		error(document.Form1.email, "Inserire il proprio indirizzo e-mail.");
	if (document.Form1.TxtAcconsento.checked == 0)
		error(document.Form1.TxtAcconsento,"Per proseguire è necessario acconsentire il trattamento dei dati personali.");
	if (errfound == false)
		{
			document.Form1.TxtCheck03.value = 'validato';
			document.Form1.BtnSend.disabled = true;
			document.Form1.BtnSend.value = 'Invio in corso...';
			document.Form1.submit();
		}
}

function sendformEN()
{	
	errfound = false;

	var data_dal = document.Form1.TxtDal.value.split("/");
	var data_al = document.Form1.TxtAl.value.split("/");
	document.Form1.dayFrom.value = data_dal[0];
	document.Form1.monthFrom.value = data_dal[1];
	document.Form1.yearFrom.value = data_dal[2];
	document.Form1.dayTo.value = data_al[0];
	document.Form1.monthTo.value = data_al[1];
	document.Form1.yearTo.value = data_al[2];
	
	if (!ValidLength(document.Form1.firstname.value,3))
		error(document.Form1.firstname,"Please enter your first name.");
	if (!ValidLength(document.Form1.lastname.value,3))
		error(document.Form1.lastname,"Please enter your last name.");
	if (!ValidLength(document.Form1.street.value,3))
		error(document.Form1.street,"Please enter your address.");
	if (!ValidLength(document.Form1.zipcode.value,3))
		error(document.Form1.zipcode,"Please enter your ZIP code.");
	if (!ValidLength(document.Form1.city.value,3))
		error(document.Form1.city,"Please enter the name of your city.");
	if (!ValidLength(document.Form1.country.value,3))
		error(document.Form1.country,"Please enter the name of your country.");
	if (!ValidEmail(document.Form1.email.value))
		error(document.Form1.email, "Please enter your e-mail address.");
	if (document.Form1.TxtAcconsento.checked == 0)
		error(document.Form1.TxtAcconsento,"To continue you must agree the privacy statement.");
	if (errfound == false)
		{
			document.Form1.TxtCheck03.value = 'validato';
			document.Form1.BtnSend.disabled = true;
			document.Form1.BtnSend.value = 'Sending your request...';
			document.Form1.submit();
		}
}

function sendformFR()
{	
	errfound = false;

	var data_dal = document.Form1.TxtDal.value.split("/");
	var data_al = document.Form1.TxtAl.value.split("/");
	document.Form1.dayFrom.value = data_dal[0];
	document.Form1.monthFrom.value = data_dal[1];
	document.Form1.yearFrom.value = data_dal[2];
	document.Form1.dayTo.value = data_al[0];
	document.Form1.monthTo.value = data_al[1];
	document.Form1.yearTo.value = data_al[2];
	
	if (!ValidLength(document.Form1.firstname.value,3))
		error(document.Form1.firstname,"Insérer le propre prénom.");
	if (!ValidLength(document.Form1.lastname.value,3))
		error(document.Form1.lastname,"Insérer le propre nom.");
	if (!ValidLength(document.Form1.street.value,3))
		error(document.Form1.street,"Insérer le propre adresse.");
	if (!ValidLength(document.Form1.zipcode.value,3))
		error(document.Form1.zipcode,"Insérer le propre CP.");
	if (!ValidLength(document.Form1.city.value,3))
		error(document.Form1.city,"Insérer le propre ville.");
	if (!ValidLength(document.Form1.country.value,3))
		error(document.Form1.country,"Insérer le propre pays.");
	if (!ValidEmail(document.Form1.email.value))
		error(document.Form1.email, "Insérer le propre e-mail.");
	if (document.Form1.TxtAcconsento.checked == 0)
		error(document.Form1.TxtAcconsento,"Pour continuer est nécessaire consentir le traitement des données personnelles.");
	if (errfound == false)
		{
			document.Form1.TxtCheck03.value = 'validato';
			document.Form1.BtnSend.disabled = true;
			document.Form1.BtnSend.value = 'Envoie en cours...';
			document.Form1.submit();
		}
}

function error(elem, text)
{	
	if (errfound) return;
	window.alert(text)
	elem.select();
	elem.focus;
	errfound = true;
}
