// <!-- Begin 

/* --------------------------------------------------------- */
 function popupPage(URL,w,h) {
   var windowprops =
   "location=no, scrollbars=yes, menubars=no,toolbars=no,resizable=yes" +
   ",left=" + 100 + ",top=" + 100 + ",width=" + w + ",height=" + h;
   popup = window.open(URL,"popup",windowprops);
 }
                                                                  

/* --------------------------------------------------------- */
function chklength(textarea,counter) {
 var nchar = textarea.value.length;
 var maxchar = 1000;

  if (nchar > maxchar ) {
    textarea.value = textarea.value.substring(0,maxchar);
   charfree = 0;
   } else {
    charfree = maxchar-nchar;
   }
  counter.value = charfree;

}

/* --------------------------------------------------------- */
function UserInfo() {
 document.PIC.BName.value=navigator.appName;
 document.PIC.Version.value=navigator.appVersion;
 document.PIC.Code.value=navigator.appCodeName;
 document.PIC.Agent.value=navigator.userAgent;
 document.PIC.Platform.value=navigator.platform;
 document.PIC.Java.value=navigator.javaEnabled();
 document.PIC.Resolution.value=window.screen.width+" x "+window.screen.height;
}


/* --------------------------------------------------------- */
function FormValidator(theForm)
{

 if (theForm.Nome.value == "" )
  {
    alert("Inserire un nome in \"Nome e Cognome o Nikname:\"");
    theForm.Nome.focus();
    return (false);
  }

 if (theForm.City.value == "" )
  {
    alert("Inserire una localita' in \"Citta':\"");
    theForm.City.focus();
    return (false);
  }

 if (theForm.MSGtxt.value == "" )
  {
    alert("Inserire un testo  in \"PIC:\"");
    theForm.MSGtxt.focus();
    return (false);
  }

}


GiorniSett = new Array();

 GiorniSett['0']="domenica";
 GiorniSett['1']="lunedi";
 GiorniSett['2']="martedi";
 GiorniSett['3']="mercoledi";
 GiorniSett['4']="giovedi";
 GiorniSett['5']="venerdi";
 GiorniSett['6']="sabato";

 
Giorni=new Array();

 Giorni['01']='01';
 Giorni['02']='02';
 Giorni['03']='03';
 Giorni['04']='04';
 Giorni['05']='05';
 Giorni['06']='06';
 Giorni['07']='07';
 Giorni['08']='08';
 Giorni['09']='09';
 Giorni['10']='10';
 Giorni['11']='11';
 Giorni['12']='12';
 Giorni['13']='13';
 Giorni['14']='14';
 Giorni['15']='15';
 Giorni['16']='16';
 Giorni['17']='17';
 Giorni['18']='18';
 Giorni['19']='19';
 Giorni['20']='20';
 Giorni['21']='21';
 Giorni['22']='22';
 Giorni['23']='23';
 Giorni['24']='24';
 Giorni['25']='25';
 Giorni['26']='26';
 Giorni['27']='27';
 Giorni['28']='28';
 Giorni['29']='29';
 Giorni['30']='30';
 Giorni['31']='31';
 
Mesi=new Array();

 Mesi['Gennaio']='00';
 Mesi['Febbraio']='01';
 Mesi['Marzo']='02';
 Mesi['Aprile']='03';
 Mesi['Maggio']='04';
 Mesi['Giugno']='05';
 Mesi['Luglio']='06';
 Mesi['Agosto']='07';
 Mesi['Settembre']='08';
 Mesi['Ottobre']='09'; 
 Mesi['Novembre']='10';
 Mesi['Dicembre']='11';


Anni = new Array();

 Anni['2000']='2000';
 Anni['2001']='2001';
 Anni['2002']='2002';
 Anni['2003']='2003';
 Anni['2004']='2004';
 Anni['2005']='2005';
 Anni['2006']='2006';
 Anni['2007']='2007';
 Anni['2008']='2008';
 Anni['2009']='2009';
 Anni['2010']='2010';
 Anni['2011']='2011';
 Anni['2012']='2012';
 Anni['2013']='2013';
 Anni['2014']='2014';


/* --------------------------------------------------------- */
function LoadSelect(MySelect,MyData)
       {

        var List=MySelect.options ;
        MySelect.length = 0;
   
        for ( key in MyData ) {
         List[List.length] = new Option(key,MyData[key]);
        }

       MySelect.selectedIndex = -1 ; 

       }



/* --------------------------------------------------------- */
function SelectTodayDate(DaySelect,MonthSelect,YearSelect)
       {

        var DSelect=DaySelect;
        var MSelect=MonthSelect;
        var YSelect=YearSelect;

        Today = new Date();
        ThisYear=Today.getFullYear();
        ThisMonth=Today.getMonth();
        ThisDay=Today.getDate();
        ThisWeekDay=GiorniSett[Today.getDay()];
        //alert (ThisDay + " " +ThisMonth + " " + ThisYear);

        document.PIC.GiornoSett.value = ThisWeekDay;

        i = 0;
        for ( key in Giorni ) {
         if ( key == ThisDay ) {
           DSelect.selectedIndex=i;
          }
         i++;
         }

        i = 0;
        for ( key in Mesi ) {
         if ( Mesi[key] == ThisMonth ) {
           MSelect.selectedIndex=i;
          }
         i++;
         }

        i = 0;
        for ( key in Anni ) {
         if ( key == ThisYear ) {
           YSelect.selectedIndex=i;
          }
         i++;
         }

       }



/* --------------------------------------------------------- */
function GetGiornoSett() 
       {
           
         var DSelect = document.PIC.Giorno;
         var MSelect = document.PIC.Mese;
         var YSelect = document.PIC.Anno;
          
         Giorno = DSelect.options[DSelect.selectedIndex].value;
         Mese = MSelect.options[MSelect.selectedIndex].value;
         Anno = YSelect.options[YSelect.selectedIndex].text;
  
         //alert (Giorno + Mese + Anno);
         Theday = new Date(Anno,Mese,Giorno);
         ThisWeekDay=GiorniSett[Theday.getDay()];
         document.PIC.GiornoSett.value = ThisWeekDay;
         
       }


/* --------------------------------------------------------- */
function InitForm(theForm)
   { 

    LoadSelect(theForm.Giorno,Giorni);
    LoadSelect(theForm.Mese,Mesi);
    LoadSelect(theForm.Anno,Anni);

    SelectTodayDate(theForm.Giorno,theForm.Mese,theForm.Anno)

   }

/* --------------------------------------------------------- */
function FormValidator(theForm)
{

 if (theForm.Giorno.selectedIndex < 0 || theForm.Mese.selectedIndex < 0 || theForm.Anno.selectedIndex < 0)
  {
    alert("Selezionare un giorno/mese/anno in \"Data di rilevamento\"");
    theForm.Giorno.focus();
    return (false);
  }
 else
  {
   data = new Date(theForm.Anno.options[theForm.Anno.selectedIndex].value,theForm.Mese.options[theForm.Mese.selectedIndex].value,theForm.Giorno.options[theForm.Giorno.selectedIndex].value);

   //Assegno data assoluta in formato interno al campo hidden "Data"
   //posso cosi' poi utilizzarlo nel CGI di commit nel modo piu'
   //flesibile possibile.
   theForm.Data.value=data.getTime();

   if (theForm.Giorno.options[theForm.Giorno.selectedIndex].value != data.getDate() ) 
    {
     alert("Data selezionata inesistente in \"Data di rilevamento.\"");
     theForm.Giorno.focus();
     return (false);
    }
   
   Today = new Date() 
   if ( data.getTime() > Today.getTime() )    
    {
     alert("Non si puo' selezionare una data futura in \"Data di rilevamento.\"");
     theForm.Giorno.focus();
     return (false);
    }

  }



// Definizione finestra di accettazione.

 //   var AcceptWindow =open("/cgi-bin/accept.cgi","main","toolbar=no,scrollbars=yes,resizable=yes,width=600,height=400");

    return (true);
}
// End validator.


// End -->






