var months = ["January","February","March","April","May","June","July","August","September","October","November","December"];

var daycounts = [31,28,31,30,31,30,31,31,30,31,30,31]; //for leap years, remember to set february to 29 days

// 0=Monday,1=Tuesday, ..., 6=Sunday
var firstdays = [4,0,0,3,5,1,3,6,2,4,0,2]; //2010

//2009 var firstdays = [3,6,6,2,4,0,2,5,1,3,6,1]; //2009
//2002 firstdays = [4,0,0,3,5,1,3,6,2,4,0,2];

// This is where you put in the appointments. follow pattern [fromday,frommonth,today,tomonth,message]

var apps = [ 

[13,1,15,1,"Tech Review meeting - Wildlife"],

[20,1,21,1,"Tech Review meeting - IES"],

[6,1,8,1,"Tech Review meeting - Fisheries"],

[29,2,2,3,"HCTF Board Meeting"],

[21,6,21,6,"PCAF Meeting"],

[2,11,2,11,"Deadline: HCTF Project Proposal"],

[17,5,17,5,"PCAF Application Deadline"],

[25,6,27,6,"HCTF Board Meeting"],

[31,8,31,8,"2nd Call for PCAF Applications"],

[16,10,18,10,"HCTF Board Meeting"]
];







function CheckDate(month,dayno)

{

   var retval = new String(dayno);

   var m = month + 1;

   

   for(var app = 0; app < apps.length; app++)

   {

      if(m == apps[app][1] ) //first month

      {

         if(apps[app][3] - apps[app][1] > 0)

         {

            if(dayno >= apps[app][0])

            {

               retval = "<div class='hol' title='" + apps[app][4] + "'>" + dayno + "</div>";

            }

         }

         else

         {

            if(dayno >= apps[app][0] && dayno <= apps[app][2])

            {

               retval = "<div class='hol' title='" + apps[app][4] + "'>" + dayno + "</div>";

            }

         }

      }

      else if(m == apps[app][3]) // second month

      {

         if(dayno <= apps[app][2])

         {

            retval = "<div class='hol' title='" + apps[app][4] + "'>" + dayno + "</div>";

         }

      }

      else if( m > apps[app][1] && m < apps[app][3] )

      {    

         retval = "<div class='hol' title='" + apps[app][4] + "'>" + dayno + "</div>";

      }

   }



   return retval;

}



function PrintMonth(month)

{

   var done = false;

   var day = 0;



   document.write("<table class='inner'><caption><font color='red'><b>" + months[month] + "     2010</b></font></caption><thead>");

   document.write("<th><font color='blue'>Mon</font></th><th><font color='blue'>Tue</font></th><th><font color='blue'>Wed</font></th><th><font color='blue'>Thu</font></th><th><font color='blue'>Fri</font></th><th><font color='red'>Sat</font></th><th><font color='red'>Sun</font></th></thead>");

   while(!done)

   {

      document.write("<tr>");

      PrintWeek(month,day, firstdays[month], daycounts[month]);

      document.write("</tr>");

      day = day + 7;

      if( day > daycounts[month] + firstdays[month])

      {

         done = true;

      }

   }

   document.write("</tbody></table>");

}





function PrintWeek(monthno,start,min,max)

{

   var d;

   var desc;

   for(var j = 0; j < 7; j++)

   {

      document.write("<td>");

      d = start + j;

      if(d >= min && d < max + min)

      {

         desc = CheckDate(monthno,d - min + 1);

         document.write(desc);

      }

      document.write("</td>");

   }

}