// JavaScript Document

function visualizza(id){
	var myMenu = document.getElementById( id );

	if (myMenu.style.display == "none"){
		myMenu.style.display = "block";   
	}else{
		myMenu.style.display = "none";   
	}
}

function ctrMailing(){
	var email = document.mailing.email.value;
	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
           alert("Inserire un indirizzo e-mail corretto");
           document.mailing.email.select();
           return false;
        }
	else {
           return true;
        }


}



function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function alternate(id){ 
 if(document.getElementsByTagName){  
   var table = document.getElementById(id);   
   var rows = table.getElementsByTagName("tr");   
   for(i = 0; i < rows.length; i++){           
 //manipulate rows 
     if(i % 2 == 0){ 
       rows[i].className = "even"; 
     }else{ 
       rows[i].className = "odd"; 
     }       
   } 
 } 
}

function fuoco() {
	
	document.modulo.nome.focus();

}

function Modulo() {

     // Variabili associate ai campi del modulo
     
     var nome = document.modulo.nome.value;
     var cognome = document.modulo.cognome.value;
     var telefono = document.modulo.telefono.value;
     var email = document.modulo.email.value;
	 var richiesta = document.modulo.richiesta.value;
     
	 
     // Espressione regolare dell'email
     var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
        
        if ((nome == "") || (nome == "undefined")) {
           alert("Il campo NOME è obbligatorio");
           document.modulo.nome.focus();
           return false;
        }
        else if ((cognome == "") || (cognome == "undefined")) {
           alert("Il campo COGNOME è obbligatorio");
           document.modulo.cognome.focus();
           return false;
        }
		else if ((telefono == "") || (telefono == "undefined")) {
           alert("Il campo TELEFONO è obbligatorio");
           document.modulo.telefono.focus();
           return false;
        }
		else if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
           alert("Inserire un indirizzo E-MAIL valido");
           document.modulo.email.select();
           return false;
        }
		
		else if ((richiesta == "") || (richiesta == "undefined")) {
           alert("Il campo RICHIESTA è obbligatorio");
           document.modulo.richiesta.focus();
           return false;
        }
        
		        
           else if (document.modulo.accetto.checked == false){
	alert("Non è stata autorizzato il Trattamento dei dati Personali");
	return false;
	}	
        //INVIA IL MODULO
        else {
           return true;
        }
  }
  
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function finestra(img,title,w,h){

	Fin=open('','','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,screenX=300,screenY=200,width='+w+',height='+h+'');
	
	Fin.document.open();
	
	Fin.document.write("<html><head><title>");
	
	Fin.document.write(title);
	
	Fin.document.write("</title></head><body style='margin:0px'>");
	
	Fin.document.write("<a href='javascript:self.close()'>");
	
	Fin.document.write("<img src=\""+img+"\" style='border:0px' title='Clicca per chiudere'>");
	
	Fin.document.write("</a>");
	
	Fin.document.write("</body></html>");
	
	Fin.document.close();

}

function ctrLogin() {

     // Variabili associate ai campi del modulo
     
     var cognome = document.login.cognome.value;
	 var ntessera = document.login.ntessera.value;
    	if ((cognome == "") || (cognome == "undefined")) {
           alert("Il campo COGNOME è obbligatorio");
           document.login.cognome.focus();
           return false;
        }
        else if ((ntessera == "") || (ntessera == "undefined")) {
           alert("Inserire il numero della tessera");
           document.login.ntessera.focus();
           return false;
        } 
        //INVIA IL MODULO
        else {
           return true;
        }
  }
