// JavaScript Document


// Calcola anno corrente per Copyright
function ins_anno_corr() {
    today=new Date();
    y0=today.getFullYear();
    document.write(y0);
}

function indirizzo2() {
          primaparte="intemperafo";
          secondaparte="artolioevin";
          terzaparte="cotelam";
          MyString1=primaparte.replace("tempera","");
          MyString2=secondaparte.replace("olio","");
          MyString3=terzaparte.replace("tela","");
          document.write("<a href=\"mailto:");
          document.write(MyString1);
          document.write("@");
          document.write(MyString2);
          document.write(".");
          document.write(MyString3);
          document.write("\">");
          document.write('<img border="0" src="immagini/email7.gif" width="60" height="30">');
          document.write("</a>");
}

!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");

function validateEmail(elementValue){   
   var emailPattern = /^.+@.+(\.[a-zA-Z0-9]{2,})$/;   
   return emailPattern.test(elementValue);   
}  

function valida_form_segnala() {
    if (document.segnalaform.nomemitt.value == "") {
        alert("Immettere il nome del mittente!");
        return false;    
    }
    if (!validateEmail(document.segnalaform.email.value)) {
        alert("Indirizzo email mittente non valido!");
        return false;    
    }
    if (document.segnalaform.nomeamico.value == "") {
        alert("Immettere il nome del destinatario!");
        return false;    
    }
    if (!validateEmail(document.segnalaform.emailamico.value)) {
        alert("Indirizzo email destinatario non valido!");
        return false;    
    }
    if (document.segnalaform.testo.value == "") {
        alert("Immettere un testo da inviare!");
        return false;    
    }
}

function valida_form_commenti() {
    if (!(document.commentoform.utile[0].checked || document.commentoform.utile[1].checked || document.commentoform.voto[0].checked || document.commentoform.voto[1].checked || document.commentoform.voto[2].checked || document.commentoform.voto[3].checked || document.commentoform.voto[4].checked || document.commentoform.commento.value != "")) {
            alert("Compilare almeno una voce del form!");
            return false;    
    }
    if (document.commentoform.email.value != "") {
        if (!validateEmail(document.commentoform.email.value)) {
            alert("L'indirizzo email è facoltativo,\nma quello immesso non è valido!");
            return false;    
        }
    }
}





