

      var bSubmit = false;


      function addEmail(){
         if(destinatari==maxDestinatari)
            return alert('Superato il numero di destinario consentito');

       if( !checkEmail(txt.value))
         alert("Email non valida");
       else if( !isNew(txt.value))
          alert("Email già presente");
       else{
         lb.options[lb.options.length] = new Option(txt.value, txt.value);
         txt.value = '';
         destinatari++;
       }

      }

      function removeEmail(){
         lb.options[lb.options.selectedIndex] = null;
         destinatari--;
         return false;
      }


      function pageCheckVal(){
         mitt = false;
         if(document.getElementById("txtMittente"))
            mitt = (document.getElementById("txtMittente").value.length==0)? true:false;

         if(lb.options.length == 0 || ta.value.length==0 || mitt){
            alert("Tutti i campi sono obbligatori.");

            return false;
         }else{
           for(i=0;i<lb.options.length;i++){
            hf.value += lb.options[i].value+";";
           }
           return true;
         }

      }

      function photoCheckVal(elToCheck){
         objRadio = document.forms["frmEcards"].elements[elToCheck];
         for(j=0; j<objRadio.length; j++)
            if(objRadio[j].checked) return true;

         alert("Devi selezionare una foto da spedire come ecard");
         return false;
      }

      function isNew(email){
         for(i=0; i<lb.options.length; i++)
            if( lb.options[i].value == email )
               return false;

         return true;
      }
