// JavaScript Document
function visualizzaNews(questo){
	if(questo=="ita"){
		document.getElementById("layerNewsIta").style.display="block";
		document.getElementById("layerNewsWorld").style.display="none";
	}else if(questo=="world"){
		document.getElementById("layerNewsIta").style.display="none";
		document.getElementById("layerNewsWorld").style.display="block";
	}
}

function visualizzaFoto(quale){
	for(i=1; i<=9;i++){
		document.getElementById("layerFoto"+i).style.display="none";
	}
	document.getElementById("layerFoto"+quale).style.display="block";
}

function indirizzoEmailValido(indirizzo) {
  if (window.RegExp) {
    var nonvalido = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var valido = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
    var regnv = new RegExp(nonvalido);
    var regv = new RegExp(valido);
    if (!regnv.test(indirizzo) && regv.test(indirizzo))
      return true;
    return false;
	}
  else {
    if(indirizzo.indexOf("@") >= 0)
      return true;
    return false;
  	}
  };
  
function submitFormMMS(){	
	var Completo=true;
	var msg="Devi compilare correttamente i seguenti campi:\n";
	if(document.theForm.Cognome.value==""){
		Completo=false;
		msg+="Cognome\n";
	}
	if(document.theForm.Nome.value==""){
		Completo=false;
		msg+="Nome\n";		
	}
	if(document.theForm.Indirizzo.value==""){
		Completo=false;
		msg+="Indirizzo\n";		
	}
	if(document.theForm.Civico.value==""){
		Completo=false;
		msg+="Civico\n";		
	}
	if (!indirizzoEmailValido(document.theForm.Email.value)){
		Completo=false;
		msg+="Email\n";		
	}
	if(Completo==false){
		alert(msg);
		return false;
	}else{
		msg="Devi acconsentire il trattamento per:\n";
		Completo=true;
		if(!document.theForm.Immagine.checked){
			msg	+= "L'immagine\n";
			Completo=false;
		}
		if(!document.theForm.DatiPersonali.checked){
			msg	+= "I tuoi dati personali";
			Completo=false;
		}
		if(Completo==false){
			alert(msg);	
			return false;
		}else{
			document.theForm.submit();
		}
	}
}

function submitFormPosta(){	

	var Completo=true;
	var msg="Devi compilare correttamente i seguenti campi:\n";
	if(document.theForm.Cognome.value==""){
		Completo=false;
		msg+="Cognome\n";
	}
	if(document.theForm.Nome.value==""){
		Completo=false;
		msg+="Nome\n";		
	}
	if(document.theForm.Indirizzo.value==""){
		Completo=false;
		msg+="Indirizzo\n";		
	}
	if(document.theForm.Civico.value==""){
		Completo=false;
		msg+="Civico\n";		
	}
	if (!indirizzoEmailValido(document.theForm.Email.value)){
		Completo=false;
		msg+="Email\n";		
	}
	if(Completo==false){
		alert(msg);
		return false;
	}else{
		msg="Devi acconsentire il trattamento per:\n";
		Completo=true;
		if(!document.theForm.Immagine.checked){
			msg	+= "L'immagine\n";
			Completo=false;
		}
		if(!document.theForm.DatiPersonali.checked){
			msg	+= "I tuoi dati personali";
			Completo=false;
		}
		if(Completo==false){
			alert(msg);	
			return false;
		}else{
			document.theForm.submit();
		}
	}
}

function submitFormEmail(){	
	var Completo=true;
	var msg="Devi compilare correttamente i seguenti campi:\n";
	if(document.theForm.Cognome.value==""){
		Completo=false;
		msg+="Cognome\n";
	}
	if(document.theForm.Nome.value==""){
		Completo=false;
		msg+="Nome\n";		
	}
	if(document.theForm.Indirizzo.value==""){
		Completo=false;
		msg+="Indirizzo\n";		
	}
	if(document.theForm.Civico.value==""){
		Completo=false;
		msg+="Civico\n";		
	}
	if (!indirizzoEmailValido(document.theForm.Email.value)){
		Completo=false;
		msg+="Email\n";		
	}
	if(!document.theForm.DatiPersonali.checked){
			msg	+= "Autorizzazione all'uso dei tuoi dati personali";
			Completo=false;
		}
	if(Completo==false){
		alert(msg);
		return false;
	}else{
		document.theForm.submit();
	}
}