function validateData (data ){
   //alert(data);
   var mm = data.substring(0,2);
   var gg = data.substring(3,5);
   var aa = data.substring(6);
   //alert(aa);
   //alert(mm);
   //alert(gg);
   var res = 0;
   var mese   = parseInt(mm);
   var giorno = parseInt(gg);
   var anno   = parseInt(aa);
   if (isNaN(anno)){
      return 1; 
   }


   if (gg.length < 2) return 1;
   if (mm.length < 0) return 1;
   if (aa.length < 4) return 1;

   if (mese>12) res = 1;
   switch (mese) {
      case 1:
         if (giorno>31) res = 1;
         break;
      case 2:
         var resto = parseInt(anno%4);
         if (resto>0)
            if (giorno>28) res = 1;
         else
            if (giorno>29) res = 1;
            break;
      case 3:
         if (giorno>31) res = 1;
         break;
      case 4:
         if (giorno>30) res = 1;
         break;
      case 5:
         if (giorno>31) res = 1;
         break;
      case 6:
         if (giorno>30) res = 1;
         break;
      case 7:
         if (giorno>31) res = 1;
         break;
      case 8:
         if (giorno>31) res = 1;
         break;
      case 9:
         if (giorno>30) res = 1;
         break;
      case 10:
         if (giorno>31) res = 1;
         break;
      case 11:
         if (giorno>30) res = 1;
         break;
      case 12:
         if (giorno>31) res = 1;
   }
   return res;
}

function getDateFromCF(CodFisc){
   var BirthDate = "";
   var Tmp = "";
   day = 0;
   day = parseInt(CodFisc.substring(9,11));
   
   //Get Day
   if ((day) > 40)
      day = day - 40;
        
   BirthDate = day + "";
   if (BirthDate.length < 2)
      BirthDate = "0" + BirthDate;
   //get month
   var cc = "";
   cc = CodFisc.substring(8,9);
   if (cc == "A")
      BirthDate = BirthDate + "01";
   else if (cc == "B")
      BirthDate = BirthDate + "02";
   else if (cc == "C")
      BirthDate = BirthDate + "03";
   else if (cc == "D")
      BirthDate = BirthDate + "04";
   else if (cc == "E")
      BirthDate = BirthDate + "05";
   else if (cc == "H")
      BirthDate = BirthDate + "06";
   else if (cc == "L")
      BirthDate = BirthDate + "07";
   else if (cc == "M")
      BirthDate = BirthDate + "08";
   else if (cc == "P")
      BirthDate = BirthDate + "09";
   else if (cc == "R")
      BirthDate = BirthDate + "10";
   else if (cc == "S")
      BirthDate = BirthDate + "11";
   else if (cc == "T")
      BirthDate = BirthDate + "12";

   //get year
   BirthDate = BirthDate + "19" + CodFisc.substring(6,8);
   return BirthDate;
}

function getOggi(){
   oggi = new Date();
   var appolo = "";
   var mamma = oggi.getUTCDay();
   switch (mamma) {
   case 0:
       appolo = "Domenica";  
   case 1:
      appolo = "Lunedì";
   case 2:
      appolo = "Martedì";
   case 3:
      appolo = "Mercoledì";
   case 4:
      appolo = "Giovedì";
   case 5:
      appolo = "Venerdì";
   case 6:
      appolo = "Sabato";
   }
   mamma = oggi.getMonth();
   var appolo2 ="";
   switch (mamma) {
   case 0:
       appolo2 = "Gennaio";  
   case 1:
      appolo2 = "Febbraio";
   case 2:
      appolo2 = "Marzo";
   case 3:
      appolo2 = "Aprile";
   case 4:
      appolo2 = "Maggio";
   case 5:
      appolo2 = "Giugnio";
   case 6:
      appolo2 = "Luglio";
   case 7:  
       appolo2 = "Agosto";  
   case 8:
      appolo2 = "Settembre";
   case 9:
      appolo2 = "Ottobre";
   case 10:
      appolo2 = "Novembre";
   case 11:
      appolo2 = "Dicembre";
   }
   appolo += " " + oggi.getDate() + " " + appolo2 + " " + oggi.getYear();
   return appolo;
}


