 NumGiorni=0
 InizioG=""
 cale=""
anno=""
 fr="" //memorizza il target del collegamento ad Home
fr1="" //memorizza il target del collegamento ad Indietro
nomeG= new Array("Lun", "Mar", "Mer", "Gio", "Ven", "Sab","Dom")
nomeGC= new Array("Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato","Domenica");
function vai(m,a) {
if (m=='Scegli')  {window.alert('Devi scegliere un mese')}
else if (a=='Scegli')  {window.alert('Devi scegliere un anno')}
else {
meseScelto=m;
anno=a;
prepara();
}
}
function prepara() {
var mese=new Array("Gennaio","Febbraio","Marzo","Aprile","Maggio", "Giugno", "Luglio", "Agosto", "Settembre","Ottobre", "novembre", "Dicembre")
if ((anno % 4)==0) {
  if ((anno % 100 )!=0) {
  var f=29
}
}
else {
 var f=28
}
var giorno=new Array("31",f,"31","30","31","30","31","31","30","31","30","31")
Lmese=giorno[meseScelto]
giorno= new Date(anno, meseScelto, 1)
inizio = giorno.getDay()
if (inizio==0) {
inizio=7
}  
InizioG=inizio
var str=mese[meseScelto]
riempiTabella(str,Lmese)
}
<!--
// intestazioni di colonna
function intestazione(){ 
for (conta=0; conta<6; conta++)
  {
     cale=cale+"<TD ALIGN=center WIDTH=35><tt>"+nomeG[conta]+"</tt></TD>"
}
cale=cale+"<TD ALIGN=center WIDTH=35><font color=red><tt>"+nomeG[6]+"</tt></TD>"
}
// inserisce i  giorni
function riempiTabella(str, Lmese)
{ 
  day=1
 cale="<TABLE BORDER=1 CELLSPACING=3 CELLPADDING=%3><TR><td>"
  cale=cale+"<TABLE BORDER=1 CELLSPACING=3 CELLPADDING=%3><TR>"
  cale=cale+"<TD COLSPAN=7 ALIGN=center bgcolor= gold><B>"+str+"   "+anno+"</B><TR>"
    //lascia le celle vuote prima del giorno di inizio del mese
 intestazione()
 cale=cale+"</TR><TR>"
  for (var i=1;i<inizio;i++){
      	cale=cale+"<TD>"
  }
  // riempe la prima settimana
  for (var i=inizio;i<8;i++){
	if (i==7) {
          cale=cale+"<TD ALIGN=center><font color=red><tt>"+day+"</tt></TD>"
 	 }
         else {
	   cale=cale+"<TD ALIGN=center><font color=navy><tt>"+day+"</tt></TD>"
         }
        day++
  }
  cale=cale+"<TR>"
  // completa le rimanenti settimane
  while (day <= Lmese) {
     for (var i=1;i<=7 && day<=Lmese;i++){
          if (i==7) {
          cale=cale+"<TD ALIGN=center><font color=red><tt>"+day+"</tt></TD>"
 	 }
         else {
	  cale=cale+"<TD ALIGN=center><font color=navy><tt>"+day+"</tt></TD>"
         }
 	 day++
     }
    cale=cale+"</TR><TR>"
  }
  cale=cale+"</TR></TABLE></TR></TABLE><BR>"
document.all("qui").innerHTML=cale
NumGiorni=Lmese
}
function crea()
{
var age = "";
age += "<html><head><title>";
age += window.document.MioForm.name.value;
var meseScelto=document.MioForm1.mese.options[window.document.MioForm1.mese.selectedIndex].text;
age += meseScelto;
age += " ";
age+=anno;
age += "</title></head>\n<body bgcolor=\"";
age += window.document.MioForm.color1.value;
age += "\"  background=\""
age += window.document.MioForm.imma.value;
age += "\">\n";
age += "<h1 align=center><font color=\"";
age += window.document.MioForm.color2.value;
age += "\"><tt>";
age += window.document.MioForm.name.value;
age += "<br>\n";
age += meseScelto;
age += " ";
age+=anno;
age += "</h1>\n";
age += "<p align=center><font size=\"3pt\" color=\"";
age += window.document.MioForm.color2.value;
age +=  "\"><a href=\"";
age += window.document.MioForm.sect.value;
age +="\" target= ";
fr=window.document.MioForm.destinazione.options[window.document.MioForm.destinazione.selectedIndex].text;
if ( fr== '(Altro)' ) {
  fr=window.prompt('Inserisci il target della pagina di provenienza con le virgolette')
  }
age+= fr
age+=">Indietro</a>  &nbsp; <a href=\"";
age += window.document.MioForm.home.value;
age +="\" target= ";
fr1=window.document.MioForm.destinazione1.options[window.document.MioForm.destinazione1.selectedIndex].text;
if ( fr1== '(Altro)' ) {
  fr1=window.prompt('Inserisci il target della Home Page con le virgolette')
  }
age+=fr1
age += ">Home</a></tt></p>\n";
age += "</center>\n";
age+="<table width=\"100%\"cellpadding=3 cellspacing=3 border=1 bgcolor=\"";
age += window.document.MioForm.color3.value;
age += "\"  background=\""
age += window.document.MioForm.immaT.value;
age += "\">\n";
var conta = 0;
InizioG=InizioG -1
while(conta<NumGiorni)
{
conta++;
age += "<tr>\n";
age += "<td width=\"165\">";
age+="<table width=\"100%\"cellpadding=3 cellspacing=3 border=0 bgcolor=\"";
age += window.document.MioForm.color3.value;
age += "\">\n";
age += "<tr>\n";
age += "<td width=\"117\">";
age += "<font color=\"";
age += window.document.MioForm.color4.value;
age += "\" size=\"3pt\"><tt>";
age += nomeGC[InizioG];
age += "</td>\n";
age += "<td width=\"21\" ALIGN=right>";
age += "<font color=\"";
age += window.document.MioForm.color4.value;
age += "\" size=\"3pt\"><tt>";
age += conta;
age += "</td>\n";
age += "</tr>\n";
age += "</table>\n";
age += "</td>\n";
age += "<td>";
age += "<font color=\"";
age += window.document.MioForm.color4.value;
age += "\" size=\"3pt\"><p><tt> &nbsp;";
age += window.document.MioForm.elements[conta-1].value;
age += " </font>";
age += "</td>\n";
age += "</tr>\n";
InizioG++;
InizioG= InizioG % 7
}
age += "</table>\n";
age +="<p align=center><tt><b>" + window.document.MioForm.note.value;
age += "</font></p>\n";
age += "</p></body></html>\n";
agenda=window.open("","displayWindow","toolbar=yes,width=640,height=480,directories=no,status=no,scrollbars=yes,resize=yes,menubar=yes");
agenda.document.write(age);
agenda.document.close();
}

