 function Modulo2() {
     var titolo = document.modulo.nome.value;
     var messaggio = document.modulo.testo.value;
     var mail = document.modulo.email.value;
     var tel = document.modulo.telefono.value;
     var mail_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

   if ((messaggio == "") || (messaggio == "undefined")) {
           alert("Il campo TESTO DEL MESSAGGIO è obbligatorio.");
           return false;
        }

        else if ((titolo == "") || (titolo == "undefined")) {
           alert("Il campo NOME è obbligatorio.");
           return false;
        }

        else if ((tel == "") || (tel == "undefined")) {
           alert("Il campo TELEFONO è obbligatorio.");
           return false;
        }

        else if (!mail_reg_exp.test(mail) || (mail == "") || (mail == "undefined")) {
           alert("Inserire un indirizzo email corretto.");
           return false;
        }
        //INVIA IL MODULO
        else {
           document.modulo.submit();
        }
     
  }
function centra(pagina, nome,w,h){ 
      // questo è lo script per una popup FISSA 
      x = Math.ceil( (window.screen.width - w) / 2 )-20; 
      y = Math.ceil( (window.screen.height - h) / 2 ); 
      tl = 'top='+y+',left='+x+','; 
      aa = window. open(pagina,nome,tl+'toolbar=no,status=no,scrollbars=yes,resizable=no,width='+w+',height='+h); 
      aa.focus(); 
} 
function PrevFoto(img){
  foto1= new Image();
  foto1.src=(img);
  Controlla(img);
}
function Controlla(img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img);
  }
  else{
    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,100);
  }
}

function viewFoto(img){
largh=foto1.width+20;
  altez=foto1.height+25;
 // questo è lo script per una popup FISSA 
      x = Math.ceil( ((window.screen.width - largh)-40) / 2 ); 
      y = Math.ceil( (window.screen.height - altez) / 2 ); 


  
  stringa="top="+y+",left="+x+",width="+largh+",height="+altez;
  finestra=window.open(img,"",stringa);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function validateForm1(form) {
  if ( (form.codice.value == "") )
	 { alert("Attenzione! Devi inserire il codice di attivazione"); 	form.codice.focus();  return false; }
	 else 

  if ( (form.url.value == "")  )
	 { alert("Attenzione! Devi inserire l indirizzo internet"); form.url.focus();  return false; }
	 else 



if ((form.categoria.selectedIndex == 0))
	 {
    alert("Attenzione! Devi selezionare la categoria");
	form.provincia.focus();
    return false;
  } else 
  
return true;
  
return true;

}

function deptChecked(form) {
  for (i=0; i<form.Reg.length; i++) {
    if (form.Reg[i].checked) {
      return true;
    }
  }
  return false;
}


function validateForm(form) {
  if ( (form.nome.value == "") )
	 { alert("Attenzione! Devi inserire il nome"); 	form.nome.focus();  return false; }
	 else 

  if ( (form.url.value == "")  )
	 { alert("Attenzione! Devi inserire l indirizzo internet"); form.url.focus();  return false; }
	 else 


  if ( (form.email.value == "")  )
	 { alert("Attenzione! Devi inserire la Email"); form.email.focus();  return false; }
	 else 



if ((form.categoria.selectedIndex == 0))
	 {
    alert("Attenzione! Devi selezionare la categoria");
	form.provincia.focus();
    return false;
  } else 
  

  if  ( form.email.value.indexOf( "@") == -1 )
        { alert( "Inserisci un indirizzo valido per la e-mail" ); 
           return false; }
	if ( form.email.value.indexOf( ".") == -1 )
	{ alert( "Inserisci un indirizzo valido per la e-mail" ); 
        return false; }

return true;
  
return true;

  }
 function Modulo3() {
     var contatto  = document.modulo.contatto.value;
     var nome      = document.modulo.nome.value;
     var indirizzo = document.modulo.indirizzo.value;
     var telefono  = document.modulo.telefono.value;
     var cellulare = document.modulo.cellulare.value;
     var email     = document.modulo.email.value;
     
     var mail_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

   if ((contatto == "") || (contatto == "undefined")) {
           alert("Il campo CONTATTO è obbligatorio.");
           return false;        }

        else if ((nome == "") || (nome == "undefined")) {
           alert("Il campo NOME DEL CONTATTO è obbligatorio.");
           return false;
        }
        else if ((indirizzo == "") || (indirizzo == "undefined")) {
           alert("Il campo INDIRIZZO è obbligatorio.");
           return false;
        }
        else if ((telefono == "") || (telefono == "undefined")) {
           alert("Il campo TELEFONO è obbligatorio.");
           return false;
        }
 


        else if (!mail_reg_exp.test(email) || (email == "") || (email == "undefined")) {
           alert("Inserire un indirizzo E-mail corretto.");
           return false;
        }
        //INVIA IL MODULO
        else {
           document.modulo.submit();
        }
     
  }
function riservata() {
     var user = document.modulo.username.value;
     var pass = document.modulo.password.value;
   

   if ((user == "") || (user == "undefined")) {
           alert("Il campo USERNAME è obbligatorio.");
           return false;
        }

        else if ((pass == "") || (pass == "undefined")) {
           alert("Il campo PASSWORD è obbligatorio.");
           return false;
        }

        //INVIA IL MODULO
        else {
           document.modulo.submit();
        }
     
  }

function last_ins() {
     var titolo = document.last.T2.value;
     var messaggio = document.last.s1.value;
     var dal = document.last.T3.value;
     var al = document.last.T4.value;
     var prezzo = document.last.T5.value;          


   if ((messaggio == "") || (messaggio == "undefined")) {
           alert("Il campo TESTO OFFERTA è obbligatorio.");
           return false;
        }
        else if ((titolo == "") || (titolo == "undefined")) {
           alert("Il campo TITOLO OFFERTA è obbligatorio.");
           return false;
        }
        else if ((dal == "") || (dal == "undefined")) {
           alert("Il campo DAL è obbligatorio.");
           return false;
        }
        else if ((al == "") || (al == "undefined")) {
           alert("Il campo AL è obbligatorio.");
           return false;
        }
        else if ((prezzo == "") || (prezzo == "undefined")) {
           alert("Il campo PREZZO è obbligatorio (mettere 0 per non specificare).");
           return false;
        }                
        //INVIA IL MODULO
        else {
           document.last.submit();
        }
     
  }
