/*///////////////////////DATA - Tempo//////////////////////////////////////////

function OpenCalendar(textdateField)
{
 ReturnObjTxt=(textdateField ?  "opener."+textdateField : "document.calControl.year");
 DateSet=(textdateField ? eval(textdateField).value : getDataDD_MM_YYYY(day,month,year));
 if(!DateSet || DateSet==""  || DateSet.indexOf("/")==-1)
 DateSet=getDataDD_MM_YYYY(day,month,year)
 txt="";
 if(document.all)
  txt+="<style TYPE=\"text/css\">.Giorno {WIDTH:25px; HEIGHT:25px; text-align: center;}</style>";
 txt+="\n<SC"+"RIPT LANGUAGE=\"javascript\">\n";
 txt+="\n var inDate=0;\n function setDate(inDate) {\n this.document.calControl.ToDay.click(); now=new Date();\n day = inDate.substring(0, inDate.indexOf(\"/\"));";
 txt+="\n if (day.substring(0,1) == \"0\" && day.length > 1)\n day = parseInt(day.substring(1,day.length));";
 txt+="\n day = parseInt(day)? parseInt(day) : now.getDate() ;\n month = inDate.substring(inDate.indexOf(\"/\") + 1, inDate.lastIndexOf(\"/\"));";
 txt+="\n if (month.substring(0,1) == \"0\" && month.length > 1)\n month = month.substring(1,month.length);";
 txt+="\n month = parseInt(month)? parseInt(month)-1 : now.getMonth();\n year = parseInt(inDate.substring(inDate.lastIndexOf(\"/\") + 1, inDate.length));";
 txt+="\n year = parseInt(year)? parseInt(year) : now.getYear()<100 ? now.getYear()+1900  : now.getYear()+2000;";
 txt+="\n this.document.calControl.month.selectedIndex=month;\n this.document.calControl.year.value=year;\n displayCalendar(day, month, year);}";
 txt+="\n var DaySel=0;\n function displayCalendar(day, month, year) {";
 txt+="\n if (day != 0) DaySel=day;month=month+1; days=(month==4||month==6||month==9||month==11)? 30 : (month==2) ? (((year % 4)==0)&&((year % 100)!=0)||((year % 400)==0))? 29 : 28 : 31;";
 txt+="\n g=new Date (year, month-1, 1);\n startPos= g.getDay(); \n  for (i = 0; i < 42; i++)\n this.document.calButtons.elements[i].value = \"   \";";
 txt+="\n for (i = startPos; i < days+startPos; i++)\n this.document.calButtons.elements[i].value = i-startPos+1;\n this.document.calButtons.elements[DaySel+startPos-1].focus();}";
 txt+="\n function returnDate(inDay){if (inDay != \"   \") {"+ReturnObjTxt+".value=((inDay.length==1) ? \"0\"+inDay : inDay) + \"/\" + ((this.document.calControl.month.selectedIndex<9) ? \"0\"+(this.document.calControl.month.selectedIndex+1) : (this.document.calControl.month.selectedIndex+1)) + \"/\" + this.document.calControl.year.value;"+ReturnObjTxt+".blur();this.close();}}";
 txt+="\n</S"+"CRIPT>\n";
 txt+="\n<BODY BGCOLOR=\"#FFFFFF\" onblur=\"self.focus();\">";
 txt+="\n<CENTER><FORM NAME=\"calControl\" onSubmit=\"return false;\"><TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0><TR><TD COLSPAN=7><CENTER><SELECT NAME=\"month\" onChange='displayCalendar(0, this.form.month.selectedIndex, this.form.year.value)'>";
 for(i=0;i<Vg_Mese_Ar.length;i++){
  txt+="\n<OPTION>"+Vg_Mese_Ar[i];
 }
 txt+="\n</SELECT><INPUT NAME=\"year\" TYPE=TEXT SIZE=4 MAXLENGTH=4 onChange=\"if(this.form.year.value.length != 4){now=new Date(); this.form.year.value=now.getYear()<100 ? now.getYear()+1900  : now.getYear()+2000 ;this.select();this.focus()}displayCalendar(0, this.form.month.selectedIndex, this.form.year.value);\">";
 txt+="\n</CENTER></TD></TR><TR><TD COLSPAN=7><CENTER>";
 txt+="\n<INPUT TYPE=BUTTON NAME=\"previousYear\" VALUE=\"<<\"    onClick=\"--this.form.year.value;displayCalendar(0, this.form.month.selectedIndex, this.form.year.value)\">";
 txt+="\n<INPUT TYPE=BUTTON NAME=\"previousMonth\" VALUE=\" < \"   onClick=\"if(this.form.month.selectedIndex>0){--this.form.month.selectedIndex;}else{this.form.month.selectedIndex=this.form.month.length-1;--this.form.year.value;}displayCalendar(0, this.form.month.selectedIndex, this.form.year.value);\">";
 txt+="\n<INPUT TYPE=BUTTON NAME=\"ToDay\" VALUE=\"Oggi\"  onClick=\"now=new Date();this.form.month.selectedIndex=now.getMonth();this.form.year.value=now.getYear()<100 ? now.getYear()+1900  : now.getYear()+2000;displayCalendar(now.getDate(), this.form.month.selectedIndex, this.form.year.value);\">"; 
 txt+="\n<INPUT TYPE=BUTTON NAME=\"NextMonth\" VALUE=\" > \"   onClick=\"if(this.form.month.selectedIndex<this.form.month.length-1){++this.form.month.selectedIndex;}else{this.form.month.selectedIndex=0;++this.form.year.value;}displayCalendar(0, this.form.month.selectedIndex, this.form.year.value);\">";
 txt+="\n<INPUT TYPE=BUTTON NAME=\"NextYear\" VALUE=\">>\"    onClick=\"++this.form.year.value;displayCalendar(0, this.form.month.selectedIndex, this.form.year.value)\">";
 txt+="\n</CENTER></TD></TR></FORM>";
 txt+="\n<FORM NAME=\"calButtons\"><TR HEIGHT=10><TD></TD></TR>";
 txt+="<TR>";
 for(i=0;i<Vg_Giorno_Ar.length;i++){
  txt+="\n<TD><CENTER><FONT SIZE=-1 FACE=\"Arial,Helv,Helvetica\"><B>"+Vg_Giorno_Ar[i].substring(0, 2)+"</B></FONT></CENTER></TD>";
 }
 txt+="</TR>"
 for(i=0;i<42;i++){
  if(i==0)
   txt+="<TR>";
  if((i==7)||(i==14)||(i==21)||(i==28)||(i==35))
   txt+="</TR><TR>";
  txt+="\n<TD><INPUT TYPE=\"button\" NAME=\"but"+i+"\" CLASS='Giorno'  value=\"    \" onClick=\"returnDate(this.value)\"></TD>";
 }
 txt+="</TR></TABLE>";
 txt+="</FORM></BODY>";
 txt+="\n<SC"+"RIPT LANGUAGE=\"javascript\">\n setDate(\""+DateSet+"\");\n</SC"+"RIPT>";
 
 nw=open("about:blank","nw","HEIGHT=250,WIDTH=200,location=no");
 nw.document.write(txt);
 nw.document.close();
 nw.focus()
 if(textdateField)eval(textdateField).form.elements[eval(textdateField).form.elements.length-2].focus();
}
*/

 var Vg_Giorno_Ar = new Array("Domenica","Lunedi'","Martedi'","Mercoledi'","Giovedi'","Venerdi'","Sabato");
 var Vg_Mese_Ar = new Array("Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre");

 
var now   = new Date();
var day   = now.getDate();
var month = now.getMonth();
var year  = now.getFullYear();
var hours=(now.getHours().toString().length>1?now.getHours().toString() :"0"+now.getHours().toString());
var minutes=(now.getMinutes().toString().length>1?now.getMinutes().toString() :"0"+now.getMinutes().toString());
var seconds=(now.getSeconds().toString().length>1?now.getSeconds().toString() :"0"+now.getSeconds().toString());

function getDaysInMonth(month,year)  {
 return (month==4||month==6||month==9||month==11)? 30 : (month==2) ? (((year % 4)==0)&&((year % 100)!=0)||((year % 400)==0))? 29 : 28 : 31;
}

function getDataEstesa(day,month,year)  {
    var SetData = new Date (year, month, day);
  return  Vg_Giorno_Ar[SetData.getDay()] + ", " + day + " " + Vg_Mese_Ar[month] + " " + year;
}

function getDataDD_MM_YYYY(day,month,year)  {
  return  ((day.length==1) ? "0"+day : day) + "/" + ((month.length==1) ? "0"+month : month) + "/" +  ((year.length<4) ? (year<100 ? year+1900  : year+2000): year);
}

document.write(getDataEstesa(day,month,year));
document.close();

/* QUESTO E' IL CODICE DA USARE COMPLETO DI ORA
document.write(getDataEstesa(day,month,year)+" -- Ore "+hours+":"+minutes+":"+seconds);  */

/* Questo e' il codice per attivare il calendario
<br><a href="javascript:OpenCalendar();void(0)">Calendario</a> */
