function form_Validator(formid){

	var myform = document.getElementById(formid);
	
	//controllo nome
	if (myform.nome.value == ""){
		alert("Input your first name");
		myform.nome.focus();
		return ;
	}	
	//controllo cognome
	if (myform.cognome.value == ""){
		alert("Input your last name");
		myform.cognome.focus();
		return ;
	}
	//controllo testata
	if (myform.testata.value == ""){
		alert("Input a heading");
		myform.testata.focus();
		return ;
	}
	//controllo redazione
	if (myform.redazione.value == ""){
		alert("Input a desk");
		myform.redazione.focus();
		return ;
	}
	//controllo tipologia
	if (myform.tipologia.value == ""){
		alert("Input a type");
		myform.tipologia.focus();
		return ;
	}
	//controllo ruolo
	if (myform.ruolo.value == ""){
		alert("Input your role");
		myform.ruolo.focus();
		return ;
	}
	//controllo nazionalita
	if (myform.nazionalita.value == ""){
		alert("Input your nationality");
		myform.nazionalita.focus();
		return ;
	}
	//controllo telefono
	if (myform.tel.value == ""){
		alert("Input your telephone number");
		myform.tel.focus();
		return ;
	}
	
	//controllo email
	if(myform.email.value == "" || myform.email.value.indexOf('@') < 0 || myform.email.value.indexOf('.') < 0 || myform.email.value.length < 6){
	    alert("Input a valid e-mail address");
	    myform.email.focus();
		return ;
  	}
	//controllo password
	if (myform.pw.value == ""){
		alert("Input a password");
		myform.pw.focus();
		return ;
	}
	//controllo password_2
	if (myform.pw_2.value == ""){
		alert("Confirm password");
		myform.pw_2.focus();
		return ;
	}
	
	//controllo coerenza PW
	if (myform.pw_2.value != myform.pw.value){
		alert("Attention , the two passwords don\'t match!");
		myform.pw_2.value = "";
		myform.pw_2.focus();
		return ;
	}


	myform.submit();

}


function form_Validator_reg_semplice(formid){

	var myform = document.getElementById(formid);
	
	//controllo cognome
	if (myform.cognome.value == ""){
		alert("Input your last name");
		myform.cognome.focus();
		return ;
	}
	//controllo nome
	if (myform.nome.value == ""){
		alert("Input your first name");
		myform.nome.focus();
		return ;
	}	

	//controllo posizione
	if (myform.posizione.value == ""){
		alert("Input your position");
		myform.posizione.focus();
		return ;
	}
	

	//controllo organizzazione
	if (myform.organizzazione.value == ""){
		alert("Input your company");
		myform.organizzazione.focus();
		return ;
	}
	//controllo via
	if (myform.via.value == ""){
		alert("Input your street");
		myform.via.focus();
		return ;
	}
	
	//controllo via
	if (myform.numcivico.value == ""){
		alert("Input a street number");
		myform.numcivico.focus();
		return ;
	}
	

	//controllo cap
	if (myform.cap.value == ""){
		alert("Input a zip code");
		myform.cap.focus();
		return ;
	}
	//controllo citta
	if (myform.citta.value == ""){
		alert("Input your town");
		myform.citta.focus();
		return ;
	}
		
	//controllo stato
	if (myform.stato.value == ""){
		alert("Input your nationality");
		myform.stato.focus();
		return ;
	}
	//controllo telefono
	if (myform.telefono.value == ""){
		alert("Input a telephone number");
		myform.telefono.focus();
		return ;
	}
	
	//controllo email
	if(myform.email.value == "" || myform.email.value.indexOf('@') < 0 || myform.email.value.indexOf('.') < 0 || myform.email.value.length < 6){
	    alert("Input a valid e-mail address");
	    myform.email.focus();
		return ;
  	}
	
	myform.submit();

}




// form questionario ************************************* 

function form_questionario_Validator(formid){

	var myform = document.getElementById(formid);
	
	//controllo sesso
	if (myform.sesso.value == ""){
		alert("Input your gender");
		myform.sesso.focus();
		return ;
	}	
	//controllo eta
	if (myform.eta.value == ""){
		alert("Input the age (given in completed years)");
		myform.eta.focus();
		return ;
	}
	//controllo titolo di studio
	if (myform.titolostudio.value == ""){
		alert("Input the highest level of education you have completed");
		myform.titolostudio.focus();
		return ;
	}
	//controllo professione
	if (myform.professione.value == ""){
		alert("Input the employment status");
		myform.professione.focus();
		return ;
	}
	//controllo citta
	if (myform.citta.value == ""){
		alert("Input in which city do you live");
		myform.citta.focus();
		return ;
	}
	

	//controllo stato
	if (myform.stato.value == ""){
		alert("Input in which country do you live");
		myform.stato.focus();
		return ;
	}
		
	//controllo grandezza citta
	if (myform.grandezzacitta.value == ""){
		alert("Input how is the city in which you live");
		myform.grandezzacitta.focus();
		return ;
	}
	//controllo ricchezza zona
	if (myform.ricchezzazona.value == ""){
		alert("Input how would you define your neighbourhood");
		myform.ricchezzazona.focus();
		return ;
	}
	
	
	//controllo collocazione zona
	if (myform.collocazionezona.value == ""){
		alert("Input how centrally located is the area in which you live");
		myform.collocazionezona.focus();
		return ;
	}

	myform.submit();

}



function form_questionarioSemplificatoValidator(formid){

	var myform = document.getElementById(formid);
	

	//controllo eta
	if (myform.eta.value == ""){
		alert("Input the age (given in completed years)");
		myform.eta.focus();
		return ;
	}


	//controllo citta
	if (myform.citta.value == ""){
		alert("Input in which city do you live");
		myform.citta.focus();
		return ;
	}
	

	//controllo stato
	if (myform.stato.value == ""){
		alert("Input in which country do you live");
		myform.stato.focus();
		return ;
	}
		
	myform.submit();

}


// ricerca per data *************************************
function toDataSerial(fieldid){
	var valoredata = document.getElementById(fieldid).value;
	var pezzidata = valoredata.split("\/");
	var dataserial = pezzidata[2] + pezzidata[1] + pezzidata[0];
	document.getElementById("dataserial").value = dataserial;
	document.getElementById("cercadata").submit();
}
