<!-- calendario-data-ora  -->
function showFilled(Value) {
  return (Value > 9) ? "" + Value : "0" + Value;
}
function StartClock24() {
  TheTime = new Date;
  document.clock.showTime.value = showFilled(TheTime.getHours()) + ":" + showFilled(TheTime.getMinutes()) + ":" + showFilled(TheTime.getSeconds());
  setTimeout("StartClock24()",1000)
}
window.onload=StartClock24
//--> inizio calendario

function Is() {
    agent  = navigator.userAgent.toLowerCase();
    plat = navigator.platform.toLowerCase();
    this.mac   = (plat.indexOf('mac')   !=   -1);
    this.win   = (plat.indexOf('win')   !=   -1);
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns    = ((agent.indexOf('mozilla')   !=   -1) &&
                 ((agent.indexOf('spoofer')   ==   -1) &&
                 (agent.indexOf('compatible') ==   -1)));
    this.ns4   = (this.ns && (this.major      ==    4));
    this.ns6   = (this.ns && (this.major      >=    5));
    this.ie    = (agent.indexOf("msie")       !=   -1);
    this.ie3   = (this.ie && (this.major      < 4));
    this.ie4   = (this.ie && (this.major      ==    4) &&
                 (agent.indexOf("msie 5.0")   ==   -1));
    this.ie5   = (this.ie && (this.major      ==    4) &&
                 (agent.indexOf("msie 5.0")   !=   -1));
    this.ie55  = (this.ie && (this.major      ==    4) &&
                 (agent.indexOf("msie 5.5")   !=   -1));
    this.ie6   = (this.ie && (agent.indexOf("msie 6.0")!=-1) );
}
/* ---------------------------------------------------------------------- */
// Global variables
var is = new Is();
/* ---------------------------------------------------------------------- */

function drawCalendar() {
var shell,ls,eC,iS;
iS='style="border-width:2px;border-style:inset;border-color:#ffffff"';
iaS='style="border-width:2px;border-style:inset;border-color:#ffffff"';
ls='style="font-size:12px;text-align:center;background-color:#fff;lineheight:10px;height:5px"'; eC='<td '+ls+'></td>';// cella superiore
shell=
'<form name="HBcalForm">'
+'<table cellpadding="0" cellspacing="0" border="0" width="160" bgcolor="#ffffff">' // tabella esterna calendario


+'<tr><td '+ls+' width="3"> </td><td '+ls+' width="154"> </td><td '+ls+' width="3"> </td></tr>'
+'<tr>'+eC+'<td '+iaS+'><div id="cselHolder">&nbsp;</div></td>'+eC+'</tr>'
+'<tr>'+eC+eC+eC+'</tr>'
+'<tr align="center"><td>&nbsp;</td>'
+'<td bgcolor="#FFFFFF" '+iS+'>'
+'<div id="calHolder">&nbsp;</div></td><td>&nbsp;</td></tr>'
+'</table>'
+'</form>';
document.write(shell);
setCalendar();
}

 /* ---------------------------------------------------------------------- */
 function calChange(myEl,mode){
var myForm,yb,ms,yval,mval; myForm=myEl.form;
yb=myForm.elements["ybox"];yval=eval(yb.value);
ms=myForm.msel;mval=eval(ms.value);
if(mode==1){yval++;yb.value=yval;} if(mode==2){yval--;yb.value=yval;}
if(yval<2000 && !is.ns){var s=yval+'';  yval=eval(s.substring(s.length - 2)); }
setCalendar(mval,yval); }
 /* ---------------------------------------------------------------------- */
function setCalendar(mval,yval){
var dT,msel,ctrl,today,stD,stM,stY,out,shell,mnA,dA,xstyle,ystyle,zstyle,bg,d,x,y,W,cW,cH,ep,a,b,n,m,w,t,s;
var xobj,fnt,sel,tSt, tmpA;
dA1=new Array('Domenica','Lunedi','Martedi','Mercoledi','Giovedi','Venerdi','Sabato');
dA=new Array('Do','Lu','Ma','Me','Gi','Ve','Sa'); W=155;cW=18;cH=18;
mnA=new Array("Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre");
fnt='font-family:Arial,Helvetica,sans-serif;font-size:7pt';
xstyle='style="'+fnt+';color:#FFFFFF"'; ystyle='style="'+fnt+';color:#000000"';
zstyle='style="'+fnt+';color:#FFFFFF;background-color:#33cc66;padding:1px"';
dT = new Date();today=dT.getDate(); dT.setDate(1); dT.setHours(0); dT.setMinutes(0); dT.setSeconds(0);
if(!(isNaN(mval))){dT.setMonth(mval);} if(yval){dT.setYear(yval);}
ep=dT.getTime();stD=dT.getDay(); stM=dT.getMonth(); stY=dT.getYear();stA=dT.getDate()
stY=(is.ns)?(stY+1900):stY;
var g=stY+'';if(g.length<4 && !is.ns){g='19'+g;stY=eval(g);}
msel='<select name="msel" style="'+fnt+';color:navy;width:90px;" onChange="calChange(this,0)">';// settaggio mese
for(x=0;x<12;x++){sel=(x==stM)?' selected':'';
msel+='<option value="'+x+'"'+sel+'>'+mnA[x]+'</option>';}
msel+='</select>';

ctrl='<table background-color="#33cc66" cellpadding="0" cellspacing="0" border="0">'
+'<tr><td>'+msel+'</td></td><td>'
+'<input name="ybox" style="'+fnt+';text-align:center;color:navy;width:40px;border-width:0px;border-style:inset;border-color:#FFFFFF" '// settaggio anno
+'value="'+stY+'" onFocus="this.blur()"></td>'
+'<td>'
+'<input id="clUP" type="button" style="width:18px;color:red;height:10px;" onClick="calChange(this,1)"><br>'
+'<input id="clDN" type="button" style="width:18px;color:red;height:10px;" onClick="calChange(this,2)">'
+'</td>'
+'</tr></table>';


out='<table cellpadding="0" cellspacing="0" border="0" width="'+W+'">'
+'<tr valign="middle" border="0" align="CENTER" bgcolor="#F3F3F3" height="24">'// settaggio mese
+'<td style="'+fnt+';color:red;"> '+today+' '+mnA[stM]+' '+stY+'</td></tr>'// output giorno-mese-anno
+'<tr><td>'
+'<table cellpadding="2" cellspacing="1"  border="0" width="'+W+'">'
+'<tr valign="middle" align="center" bgcolor="#668f66" height="'+cH+'">';// giorni

for(x=0;x<7;x++){out+='<td width="'+cW+'" '+xstyle+'>'+dA[x]+'</td>';}
out+='</tr>';
out+='<tr valign="middle" align="center" bgcolor="#F3F3F3" height="'+cH+'">';


n=ep-(86400000*stD);
nD=new Date(n);

y=0; a=0; t=0;
for(x=1;(x<45 && y<1);x++){d++;
w=nD.getDay();d=nD.getDate(); m=nD.getMonth();

if(m==stM){t=1;} if(t>0 && w==0 && m !=stM){y=1;}
s=(m==stM)?d:'&nbsp;';tSt=(d==today && m==stM)?zstyle:ystyle; // format of cell content
if (isFinite(w) && tmpA != w){
if(y<1){out+='<td width="'+cW+'"><span '+tSt+'>'+s+'</span></td>';
}tmpA = w;
if(w==6&&x>1){out+='</tr><tr valign="middle" align="center" bgcolor="#F3F3F3" height="'+cH+'">';}}
n+=86400000; nD=new Date(n);}
out+='</tr>';
out+='</table>'

+'</tr></table>';

if((xobj=MM_findObj('calHolder'))!=null){ xobj.innerHTML=out;}
if((xobj=MM_findObj('cselHolder'))!=null){ xobj.innerHTML=ctrl;}
//document.write(out);

}
 /* ---------------------------------------------------------------------- */
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
/* ---------------------------------------------------------------------- */
function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
/* ---------------------------------------------------------------------- */
