

/******************FUNZIONI DI CONTROLLO**********************

//***************************************************/
/******************Confronta due orari**************
//****************************************************/

function confronta_orari(pOra1, pOra2, pMin1, pMin2, pCampo){
var vOra1, vOra2, vMin1, vMin2
        vOra1 = pOra1.value;
        vOra2 = pOra2.value;
        vMin1 = pMin1.value;
        vMin2 = pMin2.value;
        //        verifico che le select siano state tutte valorizzate
        if(vOra1 == ""|| vOra2 == ""||  vMin1 == ""|| vMin2 == ""){
                alert("Selezionare correttamente gli orari.");
                return false;
        }
        //        verifico che l'ora d'inizio sia inferiore a quella di fine
        if (Number(vOra1) > Number(vOra2)){
                        vTxtMsg = genera_msg(pCampo, "21", "orario di fine.");
                        alert(vTxtMsg);
                        //alert("Orario non corretto.");
                        return false;
        }
        //        verifico che l'ora d'inizio e fine
        else if (Number(vOra1) == Number(vOra2) && Number(vMin1) >= Number(vMin2)){
                vTxtMsg = genera_msg(pCampo, "21", "orario di fine.");
                alert(vTxtMsg);
                //alert("Orario non corretto.");
                return false;
                } else{
                   return true;
                }
}
/********************************************************************************************
/*********verifica che la data di un campo non sia inf. a quella odierna *********************
/*********************************************************************************************/
function controlla_maggiore_oggi(pData, pCampo){
        var vTxtMsg;
        var vDataOdierna;
        var vMese;
        var vGiorno;
        var vAnnoData;
        var vMeseData;
        var vGiornoData;
        var vAnno;

        vGiorno      = new Date()
		vMese        = new Date()
		vAnno        = new Date()
        vGiorno      = String(vGiorno.getDate())
        vMese        = String(vMese.getMonth()+1)
        vAnno        = String(vAnno.getYear())
        pData                = String(pData.value);
        vAnnoData   = pData.substring(6,10);
        vMeseData   = pData.substring(3,5);
        vGiornoData = pData.substring(0,2);
        pData                = vAnnoData + "" + vMeseData + "" + vGiornoData

        if (vGiorno.length==1){vGiorno="0"+vGiorno}
        if (vMese.length==1){vMese="0"+vMese}

        vDataOdierna =  vAnno+""+vMese+""+vGiorno
        if (Number(pData) < Number(vDataOdierna)){
                vTxtMsg = genera_msg(pCampo, "6", "odierna");
                alert(vTxtMsg);
                return false;
        } else{
                return true;
        }

}

/********************************************************************************************
/*********verifica che la data di un campo non sia maggiore a quella odierna *********************
/*********************************************************************************************/
function controlla_minore_oggi(pData, pCampo){

        var vTxtMsg;
        var vDataOdierna;
        var vMese;
        var vGiorno;
        var vAnnoData;
        var vMeseData;
        var vGiornoData;
        var vAnno;

        vGiorno      = new Date()
		vMese        = new Date()
		vAnno        = new Date()
        vGiorno      = String(vGiorno.getDate())
        vMese        = String(vMese.getMonth()+1)
        vAnno        = String(vAnno.getYear()) 
        pData        = String(pData.value);
        vAnnoData   = pData.substring(6,10);
        vMeseData   = pData.substring(3,5);
        vGiornoData = pData.substring(0,2);
        pData       = vAnnoData + "" + vMeseData + "" + vGiornoData


        if (vGiorno.length==1){vGiorno="0"+vGiorno}
        if (vMese.length==1){vMese="0"+vMese}

        vDataOdierna =  vAnno+""+vMese+""+vGiorno
		
        if (Number(pData) > Number(vDataOdierna)){
                vTxtMsg = genera_msg(pCampo, "61", "odierna");
                alert(vTxtMsg);
                return false;
        }else{
		 return true;
        }

}

/*********************************************************************************************
/********** controlla che un campo num. non contenga caratteri non validi *********************
/*********************************************************************************************/
function controlla_numerico(pNr, pCampo){
        var vSpazio;
        var vStringa;
        var vTxtMsg;
        vSpazio = pNr.value.indexOf(" ");
        if(isNaN(pNr.value) || (pNr.value=="") || vSpazio>=0){
                vTxtMsg = genera_msg(pCampo, "1");
                alert(vTxtMsg);
                //alert("Errore nel campo "+ pCampo + ":\n sono ammessi solo valori numerici.");
                pNr.select();
                return false;
        } else{
                return true;
        }
}

function controlla_numerico_intero(pNr, pCampo){
        var vSpazio;
        var vStringa;
        var vTxtMsg;

        vSpazio = pNr.value.indexOf(" ");
		vPunto= pNr.value.indexOf(".");
		vVirgola= pNr.value.indexOf(",");
        if(isNaN(pNr.value) || (pNr.value=="") || vSpazio>=0 || vPunto>=0 || vVirgola>=0) {
                vTxtMsg = genera_msg(pCampo, "22");
                alert(vTxtMsg);
                //alert("Errore nel campo "+ pCampo + ":\n sono ammessi solo valori numerici.");
                pNr.select();
                return false;
        } else{
                return true;
        }

}

/*****************************************************************************
/*********controllo la validità delle date e che siano all'interno del range temporale 1900 ~ 2037                                =
******************************************************************************************************/
function controlla_data(pData, pCampo){
    var vForm = pData;
    var vGiorno;
    var vMese;
    var vAnno;
    var vSlash1;
    var vSlash2;
    var vSpazio;
    var k;
    var vTxtMsg;
    var vUltDue;
    var PrimeDue;

    vGiorno      = Number(vForm.value.substring(0,2));
    vSlash1      = vForm.value.substring(2,3);
    vMese        = Number(vForm.value.substring(3,5));
    vSlash2      = vForm.value.substring(5,6);
    vAnno        = Number(vForm.value.substring(6,10));
    vSpazio      = vForm.value.indexOf(" ");
    vUltDue      = Number(vForm.value.substring(2,4));
    PrimeDue     = Number(vForm.value.substring(0,2));


    if(vGiorno>31||vMese>12){
                vTxtMsg = genera_msg(pCampo, "18");
                alert(vTxtMsg);
                vForm.select();
                return false;
    }

        if(vSlash1!="/" || vSlash2!="/" || vSpazio>=0 ||vGiorno=="00"||vMese=="00"||vAnno=="00" || vGiorno.length<=1 || vMese.length<=1 || vAnno.length<=3){
            vTxtMsg = genera_msg(pCampo, "2", " (es.:01/01/2002)");
            alert(vTxtMsg);
            //alert("Errore nel campo " + pCampo +":\n formattazione non valida (es.:01/01/2002)");
            vForm.select();
            return false;
        }


    if (isNaN(vGiorno)||isNaN(vMese)||isNaN(vAnno)){
        vTxtMsg = genera_msg(pCampo, "18");
        alert(vTxtMsg);
        //alert("Caratteri non ammessi nel campo " + pCampo);
        vForm.select();
        return false;
    }

    if(vGiorno == 31 && (vMese == 11 || vMese == 04 || vMese == 06 || vMese == 9 || vMese==02 )) {
        vTxtMsg = genera_msg(pCampo, "4", vGiorno);
        alert(vTxtMsg);
        //alert("Il giorno [ " + vGiorno + " ] non è valido per il mese inserito.");
        vForm.select();
        return false;
    }  else {
                if(vGiorno == 29 && vMese == 02 && vUltDue == 00 && (PrimeDue % 4 != 0)) {

                    vTxtMsg = genera_msg(pCampo, "5", vAnno);
                    alert(vTxtMsg);
                    vForm.select();
                    //alert("L'anno [ " + vAnno + " ] non è bisestile.");
                    return false;
                } else if(vAnno%4 != 0 && vGiorno == 29 && vMese == 02){
                    vTxtMsg = genera_msg(pCampo, "5", vAnno);
                    alert(vTxtMsg);
                    vForm.select();
                    return false;
                }
        }
        if (vAnno < 1900 || vAnno > 2037){
                vTxtMsg = genera_msg(pCampo, "18");
                alert(vTxtMsg);
                vForm.select();
                return false;
        } else {
            return true;
    }
}

/***************************************************************************
/******************** Confronto tra le date *******************************
/**************************************************************************/
function confronto_date(pData1, pData2, pCampo1, pCampo2){

    var datainizio        = pData1.value;
    arraydatainizio        = datainizio.split("/");

    var datafine        = pData2.value;
    arraydatafine        = datafine.split("/");

    var Anno1        =  arraydatainizio[2];
    var Mese1        =  arraydatainizio[1];
    var Giorno1 =  arraydatainizio[0];

    var Anno2        = arraydatafine[2];
    var Mese2        = arraydatafine[1] ;
    var Giorno2 = arraydatafine[0];

        var valore = "true";
        var vTxtMsg;

    if (Anno2 < Anno1){
        vTxtMsg = genera_msg(pCampo2, "6", "del campo "+pCampo1);
        alert(vTxtMsg);
        //alert("Errore nel campo " + pCampo2 + ": la data indicata non può essere antecedente alla data del campo " + pCampo1 + ".");
        pData1.select();
        valore="false";
    }


    if (Anno2 == Anno1){
        if (Mese2 < Mese1){
            vTxtMsg = genera_msg(pCampo2, "6", pCampo1);
            alert(vTxtMsg);
             //alert("Errore nel campo " + pCampo2 + ": la data indicata non può essere antecedente alla data del campo " + pCampo1 + ".");
             pData1.select();
            valore="false";
        }
    }

    if (Anno2==Anno1) {
        if (Mese2==Mese1)         {
            if (Giorno2 < Giorno1){
                vTxtMsg = genera_msg(pCampo2, "6", pCampo1);
                alert(vTxtMsg);
                //alert("Errore nel campo " + pCampo2 + ": la data indicata non può essere antecedente alla data del campo " + pCampo1 + ".");
                pData1.select();
                valore="false";
            }
        }
    }

     if (valore=="false"){
          return false;
     }else{
          return true;
      }
}

/**************************************************************************
/*************** Controlla che un campo obbligatorio non sia vuoto**********
/***************************************************************************/
function controlla_campo_obbligatorio(pTesto, pCampo){
     if ((pTesto.value=="")||(pTesto.value==" ")){
                vTxtMsg = genera_msg(pCampo, "7");
                alert(vTxtMsg);
                //alert("Errore nel campo " + pCampo + ":\n dato obbligatorio.");
                pTesto.select();
                return false;
     } else{
                return true;
         }

}

/**************************************************************************
/*************** Controlla che un campo obbligatorio select multiple**********
/***************************************************************************/
function controlla_campo_obbligatorio_s(pTesto, pCampo){
     if ((pTesto.value=="")||(pTesto.value==" ")){
                vTxtMsg = genera_msg(pCampo, "7");
                alert(vTxtMsg);
                return false;
     } else{
                return true;
         }

}

/**************************************************************************
/*************** Consente lettere, nr e alcuni caratteri di punteggiatura**********
/***************************************************************************/
function controlla_testo(pTesto, pCampo){
        var i, valore;
        var vTxtMsg;
        valore = "true"
    for (i=0; i<=(pTesto.value.length); i++){

                if(pTesto.value.charCodeAt(i)>32    &&
                        pTesto.value.charCodeAt(i)<=38  ||
                        pTesto.value.charCodeAt(i)>=40  &&
                        pTesto.value.charCodeAt(i)<=43  ||
                        pTesto.value.charCodeAt(i)>=58  &&
                        pTesto.value.charCodeAt(i)<=64  ||
                        pTesto.value.charCodeAt(i)>90   &&
                        pTesto.value.charCodeAt(i)<97   ||
                        pTesto.value.charCodeAt(i)>122  &&
                        pTesto.value.charCodeAt(i)!=224 &&
                        pTesto.value.charCodeAt(i)!=232 &&
                        pTesto.value.charCodeAt(i)!=233 &&
                        pTesto.value.charCodeAt(i)!=236 &&
                        pTesto.value.charCodeAt(i)!=242 &&
                        pTesto.value.charCodeAt(i)!=249){

                                vTxtMsg = genera_msg(pCampo, "3", pTesto.value.substring(i,i+1));
                                alert(vTxtMsg);
                        //alert("Errore nel campo " + pCampo +":\n carattere ["+pTesto.value.substring(i,i+1)+"] non consentito.");
                pTesto.select();
                valore = "false";
                break
            }
    }

    if (valore == "false"){
            return false;
    } else{
             return true;
    }

}

/*********************************************************************************
/********* Verifica che un testo non presenti caratteri non ammessi in base al tipo
/********************di dato che deve contenere ***********************************/
function controlla_caratteri(pTesto, pCampo, pCase){      
  return true;
}

/*********************************************************
/*****Controllo che un testo contenga solo lettere*********
/*********************************************************/
function controlla_solo_lettere(pTesto, pCampo){
var i, valore;
valore = "true"
        for(i=0;i < pTesto.value.length;i++){
        if( pTesto.value.charCodeAt(i)!=32 &&
                        pTesto.value.charCodeAt(i)!=39 &&
                        pTesto.value.charCodeAt(i)!=46 &&
                        pTesto.value.charCodeAt(i)< 65 ||
                        pTesto.value.charCodeAt(i)>90  &&
                        pTesto.value.charCodeAt(i)<97  ||
                        pTesto.value.charCodeAt(i)>122 &&
                        pTesto.value.charCodeAt(i)!=224 &&
                        pTesto.value.charCodeAt(i)!=232 &&
                        pTesto.value.charCodeAt(i)!=233 &&
                        pTesto.value.charCodeAt(i)!=236 &&
                        pTesto.value.charCodeAt(i)!=242 &&
                        pTesto.value.charCodeAt(i)!=249){

                                vTxtMsg = genera_msg(pCampo,"3", pTesto.value.substring(i,i+1));
                                alert(vTxtMsg);
                                //alert("Errore nel campo " + pCampo +":\n carattere["+pTesto.value.substring(i,i+1)+"] non consentito.");
                                pTesto.select();
                                valore = "false";
                                break
                }
    }

    if (valore == "false"){
                return false;
    } else{
                return true;
    }
}

/*********************************************************
/*****controlla la formattazione di un nr teleFONO*********
/*********************************************************/
function controlla_tel(pTel, pCampo){
       /* if (pTel.value!=""){

                var tel=pTel.value;
                var lung=tel.length;
                var slash=tel.indexOf("-");
                var prefisso=tel.substring(-1,slash);
                var numero=tel.substring((slash+1),lung);

                if (prefisso.indexOf("+")<0){
                        if (isNaN(prefisso) || slash >7){
                        //alert ("Errore nel campo "+pCampo+": prefisso non valido.");
                        pTel.focus()
                        return false;
                        }
                }  else {
                                        if (slash >7 || prefisso.substring(0,1)!="+"){
                          alert ("Errore nel campo "+pCampo+": prefisso non valido.");
                          pTel.focus()
                          return false;
                  }
                }

                for(i=0;i< numero.length;i++){
                        if(numero.charCodeAt(i)<48||numero.charCodeAt(i)>57){
                                //alert ("Errore nel campo "+pCampo+": contiene caratteri non ammessi.");
                                alert ("Errore nel campo "+pCampo+": carattere ["+numero.substring(i,i+1)+"] non ammesso.");
                                pTel.focus()
                                return false;
                        }
                }
        }*/
        return true;
}

/*****************************************************************************************************/
//************************ Controllo per verificare le dimensioni del campo ***************************
/*****************************************************************************************************/
function controllodimcampo(nomecampo,desc,dimcampo){

 // DISABILITATA

   var vTxtMsg;
     if(dimcampo == 0){
       if(nomecampo.value.length <2){
          vTxtMsg = genera_msg(desc, "8", "2");
          alert(vTxtMsg);
                  //alert("Errore nel campo "+desc+":\n il numero di caratteri minimi è due.");
           return false;
      }   else  {
             return true;
      }
    } else  {
        if(nomecampo.value.length < dimcampo){
           vTxtMsg = genera_msg(desc, "8", dimcampo);
           alert(vTxtMsg);
           //alert("Errore nel campo "+desc+":\n il numero di caratteri minimi è " + dimcampo + ".");
            return false;
         } else {
            return true;
         }
      }    
      return true;
 }

/*****************************************************************************************************/
/**********Controllo  verificare che il primo carattere del campo non sia uno spazio o un apice************************/
/*****************************************************************************************************/
 function primo_carattere_nospace_noapice(nomecampo,desc) {
 var vTxtMsg;

    if(nomecampo.value.substring(0).charCodeAt()==32||nomecampo.value.substring(0).charCodeAt()==39) {
                vTxtMsg = genera_msg(desc, "9");
                alert(vTxtMsg);
                //alert("Errore nel campo "+desc+":\n il primo carattere non può essere né uno spazio, né l'apice [']");
                nomecampo.select();
                return false;
                }
        return true;
 }

/*****************************************************************************************************/
/**********Controllo  verificare che la mail per la webmail abbia minimo 5 carrateri************************/
/*****************************************************************************************************/
 function password_min_car(){
    if(document.form.pwd.value.length<5){
          alert("Errore nel campo Password:\n devi inserire al minimo 5 caratteri");
          document.form.pwd.select();
         return false;
    }
  return true;
 }

/*****************************************************************************************************/
/**********Coontrollo PER  verificare che la PRIVACY è stata accettatA************************/
/*****************************************************************************************************/
 function control_privacy(){
    if(document.form.privacy[1].checked){
          alert("Per usufruire del servizio, è necessario che tu accetti la legge sulla privacy L.675/31.12.1996");
         return false;
    }
  return true;
 }

/*****************************************************************************************************/
/********Non consente d'inserire apici consecutivi/***********************/
/*****************************************************************************************************/
function no_apici_consecutivi(nomecampo,desc){
   var vTxtMsg;

    if(nomecampo.value.lastIndexOf("''") > 0){
       vTxtMsg = genera_msg(desc, "10", "''");
           alert(vTxtMsg);
           //alert("Errore nel campo "+desc+":\n apici consecutivi non sono ammessi .");
           nomecampo.select();
           return false;
     }else{
           return true;
    }
}

/*****************************************************************************************************/
/********Controllo che nel campo non vengano inseriti caratteri consecutivi ( " " ) o ("''")***********/
/*****************************************************************************************************/
function no_spazio_apici_consecutivi(nomecampo,desc){
   var vTxtMsg;
    if(nomecampo.value.lastIndexOf("''") > 0)  {
                vTxtMsg = genera_msg(desc, "10", "''");
                alert(vTxtMsg);
                //alert("Errore nel campo "+desc+":\n apici consecutivi non sono ammessi .");
                nomecampo.select();
                return false;
                }

        if (nomecampo.value.lastIndexOf("  ") > 0) {
                vTxtMsg = genera_msg(desc, "10", "spazi");
                alert(vTxtMsg);
                //alert("Errore nel campo "+desc+":\n spazi consecutivi non sono ammessi .");
                nomecampo.select();
                return false;
                }
                
        return true;
  }

/***********************************************************************
/***************Controllo Mail **************************
/************************************************************************/
function chkmail(nomecampo, desc){
        var e_mail;
        e_mail=nomecampo.value;
        var vTxtMsg;

        if(e_mail!=""){
         if (nomecampo.value == "es. mario.rossi@tuoprovider.it") {
                nomecampo.value="";
          }
         if(nomecampo.value.lastIndexOf("@")==0) {
                                vTxtMsg = genera_msg(desc, "13", "@");
                                alert(vTxtMsg);
                                //alert("Errore nel campo "+desc+":\n carattere at [@] mancante.");
                                nomecampo.select();
                                return false;
                        }
                        if(nomecampo.value.lastIndexOf("@")==-1) {
                                vTxtMsg = genera_msg(desc, "12", "@");
                                alert(vTxtMsg);
                                nomecampo.select();
                                return false;
                        }

        if(nomecampo.value.substring(0).charCodeAt()==45||nomecampo.value.substring(0).charCodeAt()==46||nomecampo.value.substring(0).charCodeAt()==64||nomecampo.value.substring(0).charCodeAt()==95) {
                                  //alert(nomecampo.value.substring(0,1))
                                vTxtMsg = genera_msg(desc, "13", nomecampo.value.substring(0,1));
                                alert(vTxtMsg);
                                //alert("Errore nel campo "+desc+":\n il primo carattere non può essere\n punto [.], at [@], trattino [-], underscore [_].");
                                nomecampo.select();
                                return false;
                          }

        for(i=0;i < nomecampo.value.length;i++)  //visualizza l' alert se nel campo sono presenti caratteri non consentiti
                           {
                                if(nomecampo.value.charCodeAt(i)!=32&&nomecampo.value.charCodeAt(i)!=45&&nomecampo.value.charCodeAt(i)!=46&&nomecampo.value.charCodeAt(i)<48|| nomecampo.value.charCodeAt(i)>57&&nomecampo.value.charCodeAt(i)< 64|| nomecampo.value.charCodeAt(i)>90 && nomecampo.value.charCodeAt(i)!=95&&nomecampo.value.charCodeAt(i)<97|| nomecampo.value.charCodeAt(i)>122)
                                 {
                                 vTxtMsg = genera_msg(desc, "3", nomecampo.value.substring(i,i+1));
                                 alert(vTxtMsg);
                                 //alert("Errore nel campo "+desc+":\n carattere ["+nomecampo.value.substring(i,i+1)+"] non consentito.");
                                 nomecampo.select();
                                 return false;
                                 }
                           }

         for(i=0;i < nomecampo.value.length;i++)  //visualizza l' alert se nel campo è presente il carattere (spazio)
                           {
                                if(nomecampo.value.charCodeAt(i)==32){
                                 
                                  vTxtMsg = genera_msg(desc, "3", "spazio");
                                 alert(vTxtMsg);
                                 //alert("Errore nel campo "+desc+":\n spazi non consentiti.");
                                 nomecampo.select();
                                 return false;
                                 }
                           }


                        var chiocciolaCount = 0;
                        var foundatposition = 0;
                        while(foundatposition != -1) {                          
                                foundatposition = e_mail.indexOf("@", foundatposition);
                                if (foundatposition != -1){                                
                                        chiocciolaCount++;
                                        foundatposition++;
                                }
                                }

                if (chiocciolaCount >1){                     
                        vTxtMsg = genera_msg(desc, "14", "@");
                        alert(vTxtMsg);
                        //alert("Errore nel campo "+desc+":\n è ammesso un solo carattere at [@].");
                        nomecampo.select();
                        return false;
                        }

                        var lunghezza_mail;
                        lunghezza_mail = e_mail.length;
                        punto_posizionez=(lunghezza_mail-4);
                        punto_posizione=(lunghezza_mail-3);
                        punto_posizionei=(lunghezza_mail-5);
                        punto_posizionem=(lunghezza_mail-7);
                        puntone =e_mail.substring(punto_posizionez,punto_posizionez+1);
                        punto = e_mail.substring(punto_posizione,punto_posizione+1);
                        puntoinfo=e_mail.substring(punto_posizionei,punto_posizionei+1);
                        puntomuseum=e_mail.substring(punto_posizionem,punto_posizionem+1);

         if (e_mail != "es. mario.rossi@tuoprovider.it" && e_mail == ""){            
                      e_mail = "";
                } else {
                for(i=punto_posizione+1;i < lunghezza_mail;i++){                    
                if (e_mail.charCodeAt(i) < 65 || e_mail.charCodeAt(i) > 90 && e_mail.charCodeAt(i) < 97 || e_mail.charCodeAt(i) > 122)
                   {
                        vTxtMsg = genera_msg(desc, "15");
                        alert(vTxtMsg);
                   //alert("Errore nel campo "+desc+":\n l'estensione (es: .it,.com) non è corretta oppure è mancante.");
                   nomecampo.select();
                   return false;
                   }
                 }
                }

                if (e_mail != "es. mario.rossi@tuoprovider.it" && e_mail == ""){                
                 e_mail = "";
                } else { 
                if(punto != "."&&puntone!="."&&puntoinfo!="."&&puntomuseum!="."){                
                 vTxtMsg = genera_msg(desc, "16");
                 alert(vTxtMsg);
                  //alert("Errore nel campo "+desc+":\n le possibili cause sono\n1. Manca il carattere punto.\n2. L'estensione è troppo lunga");
                  nomecampo.select();
                  return false;
                 }
                }

                 if (e_mail.lastIndexOf("@.") > 0 || e_mail.lastIndexOf(".@") > 0) {
                        vTxtMsg = genera_msg(desc, "17");
                        alert(vTxtMsg);
                        //alert("Errore nel campo "+desc+":\n non sono ammessi i caratteri [@] e/o [.] consecutivamente.");
                        nomecampo.select();
                        return false;
                }

                if (e_mail.lastIndexOf("..") > 0)  {
                        vTxtMsg = genera_msg(desc, "10", ".");
                        alert(vTxtMsg);
                        //alert("Errore nel campo "+desc+":\n non sono ammessi punti consecutivi [..].");
                        nomecampo.select();
                        return false;
                        }
                        return true;
        } else{
                return true;
        }
}

/**************************************************************************
/*******************fUNZIONE PER IL CONTROLLO NUMERO DI TELEFONO*********************
/**************************************************************************/
function controllo_telefono(nomecampo, desc){


/*
var vTxtMsg;
var tel;
var telCount = 0;
var foundatposition = 0;
var vPosMeno;
var vPref;




tel                 = nomecampo.value;
vPosMeno = tel.lastIndexOf("-");
vPref         = tel.substring(0, vPosMeno);


if (nomecampo.value.length <5)
        {
     
        vTxtMsg = genera_msg(desc, "8", "5");
        alert(vTxtMsg);
        //alert("Inserisci correttamente il tuo numero telefonico (min. 5 cifre)");
        nomecampo.select();
        return false;
        }

if (vPref.length>=7){
         vTxtMsg = genera_msg(desc, "19");
        alert(vTxtMsg);
        nomecampo.select();
        return false;

}

  for(i=0;i< nomecampo.value.length;i++)  {
      if(nomecampo.value.charCodeAt(i)!=32&&nomecampo.value.charCodeAt(i)!=45&&nomecampo.value.charCodeAt(i)<48||nomecampo.value.charCodeAt(i)>57)
            {
                vTxtMsg = genera_msg(desc, "3", nomecampo.value.substring(i,i+1));
                alert(vTxtMsg);
        //alert("Nel campo TELEFONO il carattere [ "+nomecampo.value.substring(i,i+1)+" ] non è consentito.\nSono consentiti solo i caratteri numerici e il carattere trattino [-].");
        nomecampo.select();
            return false;
          }
        }

     for(i=0;i< nomecampo.value.length;i++)  //visualizza l' alert se nel campo è presente il carattere (spazio)
         {
        if(nomecampo.value.charCodeAt(i)==32)
        {
                vTxtMsg = genera_msg(desc, "3", "spazio");
                alert(vTxtMsg);
        //alert("Il carattere [spazio] nel campo TELEFONO non è consentito");
         nomecampo.select();
         return false;
         }
         }
      if(vPosMeno < 0)
                {
                vTxtMsg = genera_msg(desc, "12", "-");
                alert(vTxtMsg);
                //alert("il carattere trattino [ - ] deve essere presente nel campo TELEFONO (es:02-34252299).");
                nomecampo.select();
                return false;
                }

    while(foundatposition != -1)  {
        foundatposition = tel.indexOf("-", foundatposition);
        if (foundatposition != -1) {
                telCount++;
                foundatposition++;
        }
        }

        if (telCount>1) {
                vTxtMsg = genera_msg(desc, "14", "-");
      