function montharray(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11)
{
   this[0] = m0;
   this[1] = m1;
   this[2] = m2;
   this[3] = m3;
   this[4] = m4;
   this[5] = m5;
   this[6] = m6;
   this[7] = m7;
   this[8] = m8;
   this[9] = m9;
   this[10] = m10;
   this[11] = m11;
}

function MakeArray(n) {this.length = n; return this;}
  var Days = new MakeArray(7);
  var Months = new MakeArray(12);
  Days[1]="Lun"; 
  Days[2]="Mar"; 
  Days[3]="Mer";
  Days[4]="Gio"; 
  Days[5]="Ven"; 
  Days[6]="Sab"; 
  Days[7]="Dom"; 
  Months[1]="Gennaio"; Months[2]="Febbraio"; Months[3]="Marzo";   Months[4]="Aprile"; 
  Months[5]="Maggio"; Months[6]="Giugno"; Months[7]="Luglio";   Months[8]="Agosto"; 
  Months[9]="Settembre"; Months[10]="Ottobre"; Months[11]="Novembre"; 
  Months[12]="Dicembre";
  function getNiceDate(theDate) {
  	//return Days[theDate.getDay()] + " " + theDate.getDate() + " " +
  	//Months[theDate.getMonth()+1] + " " + theDate.getYear(); } 
	return Months[theDate.getMonth()+1] + " " + theDate.getFullYear(); }
	
function calendar(anno,mese) {
	if (mese==1) {
		annoprima=anno-1;
		meseprima=12;
		annodopo=anno;
		mesedopo=mese+1;
	} else {
		if (mese==12) {
			annoprima=anno;
			meseprima=mese-1;
			annodopo=anno+1;
			mesedopo=1;
		} else {
			annoprima=anno;
			meseprima=mese-1;
			annodopo=anno;
			mesedopo=mese+1;
		}
	}
   //anno=2007;
   //mese=9;
   giorno=1;
   data = new Date(anno, mese-1, giorno);
   var today = new Date();
   var thisDay;
   var monthNames = "GenFebMarAprMagGiuLugAgoSetOttNovDic";
   var monthNames2 = " 1 2 3 4 5 6 7 8 9101112";
   var monthDays = new montharray(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
   //year = today.getYear() + 1900;
   year=anno+1900;
   if (today.getMonth() == data.getMonth())
   	thisDay = today.getDate();
   else
    thisDay = 0;
   if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
      monthDays[1] = 29;

   //nDays = monthDays[today.getMonth()];
   nDays = monthDays[mese-1];
   firstDay=data;
   firstDay.setDate(1);
   //firstDay = today;
   //firstDay.setDate(1);
   var lastMod = new Date();
   startDay = firstDay.getDay();
   if (startDay > 5 && nDays != 29)
    caselle=42;
   else 
    caselle=35;

   document.write("<TABLE WIDTH=\"210\" HEIGHT=\"185\" BORDER=\"0\" BORDERCOLOR=\"#FFFFFF\" CELLSPACING=\"0\" CELLPADDING=\"0\" BGCOLOR=\"#FFFFFF\" class=\"txt11Arial\">");
   document.write("<TR BGCOLOR=\"#FFFFFF\"><TH COLSPAN=7>");
   document.write("<a href=\"calendario_ita.asp?anno="+annoprima+"&mese="+meseprima+"\" class=\"txt11Arial\"><img src=\"images/icona_sx.gif\" border=0></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
   document.write(getNiceDate(data));
   document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"calendario_ita.asp?anno="+annodopo+"&mese="+mesedopo+"\" class=\"txt11Arial\"><img src=\"images/icona_dx.gif\" border=0></a>");
   document.write("<TR bgcolor=\"#FFFFFF\"><TH>D<TH>L<TH>M<TH>M<TH>G<TH>V<TH>S");
   document.write("<TR>");
   column = 0;
   for (i=0; i<startDay; i++)
   {

      document.write("<TD BGCOLOR=\"#FFFFFF\">");
      document.write("<CENTER>");
      document.write("&nbsp; ");
      column++;
   }

   for (i=1; i<=nDays; i++)
   {

	  if (i==thisDay)	
      	document.write("<TD BACKGROUND=\"images/bkg_hp_calendario_giorno_sel.gif\">");
      else
	    document.write("<TD>");
       
	  document.write("<CENTER>");
      if (i==thisDay) {
        document.write("<FONT COLOR=\"#FFFFFF\"><blink>");
	    document.write("<a href=\"calendario_dati_ita.asp?anno="+anno+"&mese="+mese+"&giorno="+i+"\" target=\"calendariodati\" class=\"txt11ArialWhite\">");
		document.write(i);
		document.write("</a>");
	  }
	  else {
		document.write("<a href=\"calendario_dati_ita.asp?anno="+anno+"&mese="+mese+"&giorno="+i+"\" target=\"calendariodati\" class=\"txt11Arial\">");
		document.write(i);
	  	document.write("</a>");
	  }
      document.write("</CENTER>");

      if (i==thisDay) {
         document.write("</blink>");
         document.write("</FONT>");
	  }
	  
      column++;

      if (column == 7)
      {

         document.write("<TR>");
         column = 0;

      }
   }
	
   for (i=0; i<((caselle-nDays)-startDay); i++)
   {

      document.write("<TD BGCOLOR=\"#FFFFFF\">");
      document.write("<CENTER>");
      document.write("&nbsp; ");
      column++;
   }

   document.write("</TABLE>");
}

