
// Nota Bene: Inserire questo controllo sia sull'onSubmit della FORM (x IE) che nell'onSubmit del pulsante di submit (x Mozilla)
function check_mail(address, msg_txt)
  {
  if (msg_txt == null)
    msg_txt = "Attenzione, indirizzo di e-mail non corretto.";
  re = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
  if (!re.test(address))
    {
    if (msg_txt != "")
      alert(msg_txt);
    return false;
    }
  else
    return true;
  }

// controlla che dato sia un numero
function controlla_numero(dato)
  {
  if (isNaN(dato))
    alert("ATTENZIONE sono stati inseriti dei caratteri non validi! \n le Q.tà devono essere un numero");
  }


  // controlla che i campi obbligatori nella form non siano vuoti
function controlla_form(nome_form)
  {
  if (nome_form.cognome.value=="" || nome_form.cognome.value==" " || nome_form.cognome.value==null)
    {
    alert("ATTENZIONE! \n Il campo COGNOME non è stato compilato");
    nome_form.cognome.focus();
    return false;
    }
  if (nome_form.nome.value=="" || nome_form.nome.value==" " || nome_form.nome.value==null)
    {
    alert("ATTENZIONE! \n Il campo NOME non è stato compilato");
     nome_form.nome.focus();
    return false;
    }

  //è obbligatorio inserire il C.F 
  if (nome_form.cf.value=="" || nome_form.cf.value==" " || nome_form.cf.value==null)
    {
    alert("ATTENZIONE! \n E' obbligatorio indicare il Codice fiscale");
     nome_form.cf.focus();
    return false;
    }

  if (nome_form.indirizzo.value=="" || nome_form.indirizzo.value==" " || nome_form.indirizzo.value==null)
    {
    alert("ATTENZIONE! \n Il campo INDIRIZZO non è stato compilato");
     nome_form.indirizzo.focus();
    return false;
    }
  if (nome_form.citta.value=="" || nome_form.citta.value==" " || nome_form.citta.value==null)
    {
    alert("ATTENZIONE! \n Il campo Città non è stato compilato");
     nome_form.citta.focus();
    return false;
    }
  if (nome_form.prov.value=="" || nome_form.prov.value==" " || nome_form.prov.value==null)
    {
    alert("ATTENZIONE! \n Il campo PROVINCIA non è stato compilato");
     nome_form.prov.focus();
    return false;
    }
  if (nome_form.cap.value=="" || nome_form.cap.value==" " || nome_form.cap.value==null)
    {
    alert("ATTENZIONE! \n Il campo CAP non è stato compilato");
     nome_form.cap.focus();
    return false;
    }
  if (nome_form.tel.value=="" || nome_form.tel.value==" " || nome_form.tel.value==null)
    {
    alert("ATTENZIONE! \n Il campo TELEFONO non è stato compilato");
     nome_form.tel.focus();
    return false;
    }
  if (nome_form.e_mail.value=="" || nome_form.e_mail.value==" " || nome_form.e_mail.value==null)
    {
    alert("ATTENZIONE! \n Il campo E_MAIL non è stato compilato");
     nome_form.e_mail.focus();
    return false;
    }
  else if(nome_form.e_mail.value) // la mail deve essere valida
    {
    re = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
    if (!re.test(nome_form.e_mail.value))
      {
      alert("ATTENZIONE! \n  E_MAIL non valida");
      nome_form.e_mail.focus();
      return false;
      }
    }

  else
    return true;
  }


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_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_findObj(n, d)
      { //v4.01
      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 && d.getElementById) x=d.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];}
      }
