var Days = new MakeArray(7);
var Months = new MakeArray(12);

Days[1]="Sunday";
Days[2]="Monday";
Days[3]="Tuesday";
Days[4]="Wednesday";
Days[5]="Thursday";
Days[6]="Friday";
Days[7]="Saturday";

Months[1]="January";
Months[2]="February";
Months[3]="March";
Months[4]="April";
Months[5]="May";
Months[6]="June";
Months[7]="July";
Months[8]="August";
Months[9]="September";
Months[10]="October";
Months[11]="November";
Months[12]="December";

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;
}

function getNiceDate(theDate)
{
   return Months[theDate.getMonth()+1] + " " + theDate.getFullYear();
}

function calendar(days)
{

   today = new Date();
   var thisDay;
   var monthNames = "JanFebMarAprMayJunJulAugSepOctNovDec";
   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;
   thisDay = today.getDate();
   if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
      monthDays[1] = 29;

   nDays = monthDays[today.getMonth()];
   firstDay = today;
   firstDay.setDate(1);
   var lastMod = new Date();
   startDay = firstDay.getDay();

   var thisMonth = today.getMonth() + 1;
   if (thisMonth < 10)
      thisMonth = '0' + thisMonth;
      
   document.write("<fieldset>");
   document.write("<legend>");
   document.write(getNiceDate(lastMod));
   document.write("</legend><table class='block' cellspacing='1' cellpadding='3' align='center' style='margin:3px;'><TR class='calendar-head'><TH>Sun<TH>Mon<TH>Tue<TH>Wed<TH>Thu<TH>Fri<TH>Sat");
   document.write("<TR class='calendar-body'>");
   column = 0;
   for (i=0; i<startDay; i++)
   {

      document.write("<td>");
      document.write("<center>");
      document.write(" ");
      column++;
   }

   for (i=1; i<=nDays; i++)
   {
      var day = i;
      if (day < 10)
         day = '0' + day;

      document.write("<td>");


      if (i == thisDay)
         document.write("<b>");

      if (days.match(":" + i + ":"))
         document.write("<center><a href='index.php?sfd=" + today.getFullYear() + "-" + thisMonth + "-" + day + "'>");
      else
         document.write("<center>");

      document.write(i);
      document.write("</center");

      if (i == thisDay)
         document.write("</b>")

      column++;

      document.write("</td>");

      if (column == 7)
      {

         document.write("</tr><tr class='calendar-body'>");
         column = 0;

      }
   }

   document.write("</tr></table></fieldset>");
}


