fatto=false;
function validazioneCV(){

var msgErr="You must fill the following fields\n"
var msgErr2="";
Nome_V=(document.CV_Form.elements["CVPersona.Nome"])?document.CV_Form.elements["CVPersona.Nome"].value:""
Cognome_V=(document.CV_Form.elements["CVPersona.Cognome"])?document.CV_Form.elements["CVPersona.Cognome"].value:""
DataNascita_V=(document.CV_Form.elements["CVPersona.DataNascita"])?document.CV_Form.elements["CVPersona.DataNascita"].value:""
ComuneNascita_V=(document.CV_Form.elements["CVPersona.ComuneNascita"])?document.CV_Form.elements["CVPersona.ComuneNascita"].value:""
ComuneResidenza_V=(document.CV_Form.elements["CVPersona.ComuneResidenza"])?document.CV_Form.elements["CVPersona.ComuneResidenza"].value:""
Email_V=(document.CV_Form.elements["CVPersona.Email"])?document.CV_Form.elements["CVPersona.Email"].value:""
IdPosizioneMilitare_V=(document.CV_Form.elements["CVPersona.IdPosizioneMilitare"])?document.CV_Form.elements["CVPersona.IdPosizioneMilitare"].value:""


IdUltimoTitolo_V=(document.CV_Form.elements["CVPersona.IdUltimoTitolo"])?document.CV_Form.elements["CVPersona.IdUltimoTitolo"].value:""


    //valido il contenuto  prinma  verifico la privacy
    if(document.CV_Form.elements["CVPrivacy.Check"].checked==true){
       if(document.CV_Form.elements["CVPersona.Nome"]){
         if(Nome_V=="")msgErr2+="Personal data: Name\n"
       }
       if(document.CV_Form.elements["CVPersona.Cognome"]){
            if(Cognome_V=="")msgErr2+="Personal data: Surname \n"
       }
       if(document.CV_Form.elements["CVPersona.DataNascita"]){
            if(DataNascita_V=="")msgErr2+="Personal data: Birth date \n"
            else {
            dateExists=true
            dateExists=ceckDate(DataNascita_V,"CVPersona.DataNascita")
            if(!dateExists)    msgErr2+="Personal data: Birth date \n"
            }
       }
       if(document.CV_Form.elements["CVPersona.ComuneNascita"]){
            if(ComuneNascita_V=="")msgErr2+="Personal data: Birth City  \n"

       }
       if(document.CV_Form.elements["CVPersona.ComuneResidenza"]){
            if(ComuneResidenza_V=="")msgErr2+="Personal data: Residence City  \n"

       }

       // cecco solo  se   versione  italiana
       if(lang=='it'){
          checkCombo('CVPersona.IdProvinciaResidenza')
          //if(valore=="")msgErr2+="Personal data: Residence City - State/Province \n"
          }

        // telefono
       Tel=false;
       isVuoto('CVPersona.TelefonoDomicilio')
       if(fill!='')Tel=true

       isVuoto('CVPersona.TelefonoCellulare')
       if(fill!='')Tel=true
       if(Tel==false)msgErr2+="Personal data: Please enter at least one telephone number \n"

        if(document.CV_Form.elements["CVPersona.Email"]){
            if(Email_V=="")msgErr2+="Personal data : Email \n"

       }

         if(document.CV_Form.elements["CVPersona.IdPosizioneMilitare"] && lang=='it'){
            checkCombo("CVPersona.IdPosizioneMilitare")
             if(valore=="")msgErr2+="Anagrafica: Obbligo  di Leva \n"

       }


       //  in  questo pezzo verifico  se  è stato inserito il titolo di  studio nella  maniera corretta
       if(document.CV_Form.elements["CVPersona.IdUltimoTitolo"]){
            checkRadio("CVPersona.IdUltimoTitolo")
            if(radio_choice!=true)msgErr2+="Education - You have to select your last educational qualification \n"
            else if(lang=='it') {
                  // setto oggetto

                  for (counter = 0; counter < document.CV_Form.elements["CVPersona.IdUltimoTitolo"].length; counter++){
                            if (document.CV_Form.elements["CVPersona.IdUltimoTitolo"][counter].checked){
                             butVal=document.CV_Form.elements["CVPersona.IdUltimoTitolo"][counter].value
                         }
                   }

                 // se ho  scelto la  licenza  media   sgimmo e  non devo compilare niente
                  if(butVal==1) {}
                  else {
                      // se scelgo  la  qualifica il but è5  ma  nella pag è 1
                      if(butVal==5)butVal=1;
                      // se  ho scelta laurea  devo inserire anche il tipo di diploma
                      if(butVal==3 || butVal==4){
                        diploma="CVTitoliDiStudio.IdTipoStudio:2"
                        checkCombo(diploma)
                        if(valore=="")msgErr2+="Education - Inserire anche il tipo di diploma \n"
                      }
                     tipo="CVTitoliDiStudio.IdTipoStudio:"+butVal
                     istituto="CVTitoliDiStudio.Istituto:"+butVal
                     voto="CVTitoliDiStudio.Votazione:"+butVal
                     MaxVoto="CVTitoliDiStudio.MaxVotazione:"+butVal
                     DataStudi="CVTitoliDiStudio.DataStudi:"+butVal

                     checkCombo(tipo)
                     if(valore=="")msgErr2+="Education - Educational qualification \n"

                     isVuoto(istituto,'Studi - Istituto')
                     if(fill=='')msgErr2+='Educationi - Institute\n'
                     isVuoto(DataStudi,"Studi - Data Conseguimento Titolo di Studio")
                     if(fill=='')msgErr2+="Education - Year\n"



                      //isNumero(voto)
                       //if(Numero!=true)msgErr2+="Studi - Votazione (valore Numerico) \n"
                     //isNumero(MaxVoto)
                     //if(Numero!=true)msgErr2+="Studi - Max Votazione (valore Numerico)\n"
                 }

                 }

       }





       //   esperienze  Lavorative
       //  se primo lavoro   viene  saltato il  ceck
       if(document.CV_Form.elements["CVPersona.PrimoLavoro"].checked==false){
          isVuoto('CVEsperienzeLavorative.Azienda:1')
          if(fill=='')msgErr2+='Work experience : Company\n'
          checkCombo('CVEsperienzeLavorative.IdSettoreMerceologico:1')
          if(valore=="")msgErr2+="Work experience:  \n"


          isVuoto('CVEsperienzeLavorative.DataInizio:1')
          ceckDate(fill,"CVEsperienzeLavorative.DataInizio:1")
          if(!dateExists)    msgErr2+="Work experience: Beginning date \n"



       // se  l'ccupazione  è in  corso

           if(document.forms[0].elements['CVEsperienzeLavorative.OccupatoAttualmente:1'].checked==false){
                  isVuoto('CVEsperienzeLavorative.DataFine:1')
               ceckDate(fill,"CVEsperienzeLavorative.DataFine:1")
              if(!dateExists)    msgErr2+="Work experience: Ending date \n"
           }

           checkCombo('CVEsperienzeLavorative.IdSettoreFunzionale:1')
           if(valore=="")msgErr2+="Work experience: Function/Position \n"


           // valido anche le  date precedenti




           if(document.forms[0].elements['CVEsperienzeLavorative.DataInizio:2'].value!=''){
               isVuoto('CVEsperienzeLavorative.DataInizio:2')
               ceckDate(fill,"CVEsperienzeLavorative.DataInizio:2")
               if(!dateExists)    msgErr2+="Previous work experiences 1: Beginning date \n"
           }
            if(document.forms[0].elements['CVEsperienzeLavorative.DataFine:2'].value!=''){
               isVuoto('CVEsperienzeLavorative.DataFine:2')
                  ceckDate(fill,"CVEsperienzeLavorative.DataFine:2")
               if(!dateExists)    msgErr2+="Previous work experiences 1: Ending date \n"
            }

           if(document.forms[0].elements['CVEsperienzeLavorative.DataInizio:3'].value!=''){
              isVuoto('CVEsperienzeLavorative.DataInizio:3')
              ceckDate(fill,"CVEsperienzeLavorative.DataInizio:3")
             if(!dateExists)    msgErr2+="Previous work experiences 2: Beginning date \n"

           }
            if(document.forms[0].elements['CVEsperienzeLavorative.DataFine:3'].value!=''){
                isVuoto('CVEsperienzeLavorative.DataFine:3')
                ceckDate(fill,"CVEsperienzeLavorative.DataFine:3")
                if(!dateExists)    msgErr2+="Previous work experiences 2: Ending date \n"
            }

       }
       // ambizioni e  condizioni
      checkCombo('CVCondizioniLavorative.Interesse1')
      if(valore=="")msgErr2+="Aspirazioni  : Please enter at least one area of interest \n"
      isVuoto('CVCondizioniLavorative.Aspirazioni')
      if(fill=='')msgErr2+='Aspirations  :  Aspirations\n'
      isVuoto('CVCondizioniLavorative.Hobby')
      if(fill=='')msgErr2+='Aspirations  :  Hobbies\n'

     }
     else { msgErr2+="You have to give your consent to use the data you provided us with\n"}
     //creo messaggio di errore
     if(msgErr2!=""){
        alert(msgErr+msgErr2)
     }

// se  vuoto  faccio il subnmit
     if (msgErr2=="" && fatto==false){
	              fatto=true
                  return true

     }
     else {
     //alert(fatto)
     //location.hash='_CVPrivacy'
     return false

     }

}
