
var ids=new Array('banner','preventivo');

function switchid(id){	
	hideallids();
    showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
        
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

  function Modulo() {
     // Variabili associate ai campi del modulo
     var nome = document.modulo.nome.value;
     var cognome = document.modulo.cognome.value;
	 var email = document.modulo.email.value;
     var telefono = document.modulo.telefono.value;
	 
     // Espressione regolare dell'email
     var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
        //Effettua il controllo sul campo NOME
        if ((nome == "") || (nome == "Nome")) {
           alert("Il campo Nome e' obbligatorio.");
           document.modulo.nome.focus();
           return false;
        }
        //Effettua il controllo sul campo COGNOME
        else if ((cognome == "") || (cognome == "Cognome")) {
           alert("Il campo Cognome e' obbligatorio.");
           document.modulo.cognome.focus();
           return false;
        }
		
		 else if (!email_reg_exp.test(email) || (email == "") || (email == "Indirizzo Email")) {
           alert("Inserire un indirizzo email corretto.");
           document.modulo.email.select();
           return false;
        }
		
		//Effettua il controllo sul campo TELEFONO
        else if ((isNaN(telefono)) || (telefono == "") || (telefono == "Recapito Telefonico")) {
           alert("Il campo Recapito Telefonico è numerico ed e' obbligatorio.");
           document.modulo.telefono.value = "";
           document.modulo.telefono.focus();
           return false;
        }
		

		//Effettua il controllo sul campo privacy
		else if(document.modulo.trattamento.checked==false){
			alert("Accettare il trattamento dei dati personali.");
			return false;
		}

        //INVIA IL MODULO
        else {
           document.modulo.action = "wp-content/themes/mutui-inpdap/form-contatti/sendmail-contatti.php";
           document.modulo.submit();
        }
  }


function open_popup(url) {
	window.open(url, 'bmpp', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=300,left=570,top=300');
	return false;
}
