var _months = ["January","February","March","April","May","June","July","August","September","October","November","December"];

var daycounts2004 = [31,29,31,30,31,30,31,31,30,31,30,31]; //for leap years, remember to set february to 29 days
var daycounts2005 = [31,28,31,30,31,30,31,31,30,31,30,31]; //for leap years, remember to set february to 28 days
var daycounts2006 = [31,28,31,30,31,30,31,31,30,31,30,31]; //for leap years, remember to set february to 28 days
var daycounts2007 = [31,28,31,30,31,30,31,31,30,31,30,31]; //for leap years, remember to set february to 28 days

var firstdays2004 = [3,6,7,3,5,1,3,6,2,4,0,2]; //count 'Monday' as day 0 and and up to first day of week; so if january 1 was a Saturday, the the vector should start with '5,...'
var firstdays2005 = [5,1,1,4,7,2,4,0,3,5,1,3];
var firstdays2006 = [6,2,2,5,0,3,5,1,4,6,2,4];
var firstdays2007 = [0,3,3,6,1,4,6,2,5,0,3,5];




// This is where you put in the appointments. follow pattern [fromday,frommonth,today,tomonth,message,relative link]

var apps2004 = [ 

[8,3,10,3,"Lebanese Cultural Week in Lobby 10, MIT", "previous/CulturalWeek04"],

[12,3,12,3,"Libanissimo IV in Lobdell Court", "previous/LibanissimoIV"],

[21,4,21,4,"Lebanese Ambassador, Farid Abboud, at MIT - April 21, 2004", "previous/AmbassadorTalk"],

[10,5,10,5,"George Kassas at MIT (ALES/LCM Seminar Series) - May 10, 2004", "previous/GeorgeKassasTalk"],

[18,9,18,9,"Michel El-Achkar in A Child of Life, a theatrical dramatization of the life of Khalil Gibran - September 18, 2004", "previous/AChildOfLife04"],

[6,11,6,11,"Counterpoint International Conference: The Role of the Arts in Deepening Christian-Muslim Dialogue - November 6th, 2004", "previous/CounterPoint04"]

];



var apps2005 = [ 

[8,2,8,2,"Dean Philip Khoury: 1st Lecture on Lebanese Syrian Relations - Feb 8, 2005", "previous/LS_PhilipKhoury05"],
[15,2,15,2," Prof. Noam Chomsky: 2nd Lecture on Lebanese Syrian Relations - Feb 15, 2005", "previous/LS_NoamChomsky05"],
[22,2,22,2,"Advisor Adib Farha: 3rd Lecture on Lebanese Syrian Relations - Feb 22, 2005", "previous/LS_AdibFarha05"],

[21,3,21,3,"LCM President in a Special Episode of Kalam El Nas - March 21, 2005", "previous/KalamElNas05"],

[13,4,13,4,"April 13 Unity Dinner", "previous/UnityDinner05"],
[14,4,14,4,"Lebanese Awareness Week - April 13 & 14, 2005", "previous/AwarenessWeek05"],
[22,4,22,4,"End of Semester BBQ - April 22, 2005", "previous/BBQ0505"],

[7,5,7,5,"Conference: Transforming Conflict and Deepening Interfaith Dialogue through Arts, Music, & Ritual at Harvard University - May 7, 2005", "previous/CounterPoint05"],
[27,6,29,6,"Conference: NGOs, Governance, & Sustainable Development Conference in Kaslik, Lebanon - June 26-28, 2005", "previous/CLEHR05"],

[2,10,2,10,"End of Summer BBQ - October 2, 2005", "previous/BBQ1005"],

[5,11,5,11,"Shopping Trip to Watertown - November 5, 2005", "previous/Watertown05"],

[19,11,19,11,"Independence Day Dinner - November 19, 2005", "previous/IndependenceDinner05"],

[20,11,20,11,"LATT Workshop on National Leadership - November 20, 2005", "previous/LATT1105"],

[7,12,7,12,"Tribute to Moustapha Akkad - December 7, 2005","previous/Akkad06/index.html"]
];


var apps2006 = [ 

[4,2,4,2,"ALES Annual Dinner - February 4, 2006","previous/ALESDinner020406/index.html"],
[22,2,22,2,"Lebanese Awareness Week - February 22-23, 2006","previous/AwarenessWeek06/index.html"],
[24,2,24,2,"Libanissimo V - February 24, 2006","previous/LibanissimoV/index.html"],
[2,3,2,3,"Bernard Khoury Lecture - March 2, 2006","previous/BernardKhoury030206/index.html"],
[10,3,10,3,"Man'oushe Gathering - March 10, 2006","previous/Manoushe031006/index.html"],
[24,3,24,3,"Lebanese Campus Link Convention - March 24, 2006","previous/LCL032406/index.html"],
[10,4,10,4,"LCM at the Muddy Charles - April 10, 2006","previous/MuddyMonday041006/index.html"],
[30,4,30,4,"End of Year BBQ - April 30, 2006","previous/BBQ0406/index.html"],
[20,5,21,5,"Selections from TECHLEB|06 - May 20-21, 2006","previous/TECHLEB06/index.html"],
[2,6,2,6,"TECHLEB|06 Celebration Dinner - June 2, 2006","previous/TECHLEB06CelebrationDinner060206/index.html"],
[12,7,31,7,"From Justice for Lebanon Campaign - July, 2006","previous/JusticeforLebanon0706/index.html"],
[10,9,10,9,"A Child of Life by Michel El Ashkar - Sep 10, 2006","previous/AChildOfLife06/index.html"],
[17,9,17,9,"End of Summer BBQ - September 17, 2006","previous/BBQ0906/index.html"],
[15,11,15,11,"Bosta Film Screening - November 15, 2006","previous/Bosta06/index.html"],
[17,11,17,11,"Members Independence Day Dinner - November 17, 2006","previous/IndependenceDinner06/index.html"],
[21,11,21,11,"Lebanese Cuisine 101 Lecture - November 21, 2006","previous/LebaneseCuisine1106/index.html"],
[29,11,29,11,"Lebanese Coffee Hour @ S&P - November 29, 2006","previous/CoffeeHourDabkeSP1106/index.html"],
[7,12,7,12,"Emergency to Emergence (postponed) - December 7, 2006","previous/E2EBenefitDinner1206/index.html"]

];

var apps2007 = [ 

[15,2,15,2,"With Director Omar Naim - Grand Theatre & Final Cut - February 15, 2007","previous/naim06/index.html"],
[2,3,2,3,"Libanissimo VI - March 2, 2007","previous/LibanissimoVI/index.html"],
[23,3,23,3,"LCM Delegation to 2nd LCL Convention - March 23, 2007","previous/LCLII032307/index.html"],
[16,4,16,4,"Rami Khalifé & Kinan Azmeh in Concert - April 16, 2007","previous/SonicDialogues07/index.html"],
[8,5,8,5,"Bassam Saba Ensemble - May 8, 2007","previous/SabaConcert0507/index.html"],
[10,5,10,5,"Book Reading with Evelyn Shakir - May 10, 2007","previous/EvelynShakir0507/index.html"],
[13,5,13,5,"Lamb Roasting LIVE @ End of Year BBQ - May 13, 2007","previous/BBQ0507/index.html"],
[21,5,21,5,"LCM wins Agent of Change Award! - May 21, 2007","previous/AgentOfChangeAward0507/index.html"]

];


function CheckDate2004(month,dayno)

{

   var retval = new String(dayno);

   var m = month + 1;

   

   for(var app = 0; app < apps2004.length; app++)

   {

      if(m == apps2004[app][1] ) //first month

      {

         if(apps2004[app][3] - apps2004[app][1] > 0)

         {

            if(dayno >= apps2004[app][0])

            {

               retval = "<div class='hol' title='" + apps2004[app][4] + "'>" + dayno + "</div>";

            }

         }

         else

         {

            if(dayno >= apps2004[app][0] && dayno <= apps2004[app][2])

            {

               retval = "<div class='hol' title='" + apps2004[app][4] + "'><a target='_blank' href='" + apps2004[app][5]+ "'>" + dayno + "</a></div>";

            }

         }

      }

      else if(m == apps2004[app][3]) // second month

      {

         if(dayno <= apps2004[app][2])

         {

            retval = "<div class='hol' title='" + apps2004[app][4] + "'>" + dayno + "</div>";

         }

      }

      else if( m > apps2004[app][1] && m < apps2004[app][3] )

      {    

         retval = "<div class='hol' title='" + apps2004[app][4] + "'>" + dayno + "</div>";

      }

   }



   return retval;

}



function PrintMonth2004(month)

{

   var done = false;

   var day = 0;



   document.write("<table class='inner'><caption><b style='color: #CC3300; font-size: 8pt;'>" + _months[month] + "</b></caption><thead>");

   document.write("<th>Mo</th><th>Tu</th><th>We</th><th>Th</th><th>Fr</th><th>Sa</th><th>Su</th></thead>");

   while(!done)

   {

      document.write("<tr>");

      PrintWeek2004(month,day, firstdays2004[month], daycounts2004[month]);

      document.write("</tr>");

      day = day + 7;

      if( day > daycounts2004[month] + firstdays2004[month])

      {

         done = true;

      }

   }

   document.write("</tbody></table>");

}





function PrintWeek2004(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 = CheckDate2004(monthno,d - min + 1);

         document.write(desc);

      }

      document.write("</td>");

   }

}




///2005.....................



function CheckDate2005(month,dayno)

{

   var retval = new String(dayno);

   var m = month + 1;

   

   for(var app = 0; app < apps2005.length; app++)

   {

      if(m == apps2005[app][1] ) //first month

      {

         if(apps2005[app][3] - apps2005[app][1] > 0)

         {

            if(dayno >= apps2005[app][0])

            {

               retval = "<div class='hol' title='" + apps2005[app][4] + "'>" + dayno + "</div>";

            }

         }

         else

         {

            if(dayno >= apps2005[app][0] && dayno <= apps2005[app][2])

            {

               retval = "<div class='hol' title='" + apps2005[app][4] + "'><a target='_blank' href='" + apps2005[app][5]+ "'>" + dayno + "</a></div>";

            }

         }

      }

      else if(m == apps2005[app][3]) // second month

      {

         if(dayno <= apps2005[app][2])

         {

            retval = "<div class='hol' title='" + apps2005[app][4] + "'>" + dayno + "</div>";

         }

      }

      else if( m > apps2005[app][1] && m < apps2005[app][3] )

      {    

         retval = "<div class='hol' title='" + apps2005[app][4] + "'>" + dayno + "</div>";

      }

   }



   return retval;

}



function PrintMonth2005(month)

{

   var done = false;

   var day = 0;



   document.write("<table class='inner'><caption><b style='color: #CC3300; font-size: 8pt;'>" + _months[month] + "</b></caption><thead>");

   document.write("<th>Mo</th><th>Tu</th><th>We</th><th>Th</th><th>Fr</th><th>Sa</th><th>Su</th></thead>");

   while(!done)

   {

      document.write("<tr>");

      PrintWeek2005(month,day, firstdays2005[month], daycounts2005[month]);

      document.write("</tr>");

      day = day + 7;

      if( day > daycounts2005[month] + firstdays2005[month])

      {

         done = true;

      }

   }

   document.write("</tbody></table>");

}





function PrintWeek2005(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 = CheckDate2005(monthno,d - min + 1);

         document.write(desc);

      }

      document.write("</td>");

   }

}



///2006.....................



function CheckDate2006(month,dayno)

{

   var retval = new String(dayno);

   var m = month + 1;

   

   for(var app = 0; app < apps2006.length; app++)

   {

      if(m == apps2006[app][1] ) //first month

      {

         if(apps2006[app][3] - apps2006[app][1] > 0)

         {

            if(dayno >= apps2006[app][0])

            {

               retval = "<div class='hol' title='" + apps2006[app][4] + "'>" + dayno + "</div>";

            }

         }

         else

         {

            if(dayno >= apps2006[app][0] && dayno <= apps2006[app][2])

            {

               retval = "<div class='hol' title='" + apps2006[app][4] + "'><a target='_blank' href='" + apps2006[app][5]+ "'>" + dayno + "</a></div>";

            }

         }

      }

      else if(m == apps2006[app][3]) // second month

      {

         if(dayno <= apps2006[app][2])

         {

            retval = "<div class='hol' title='" + apps2006[app][4] + "'>" + dayno + "</div>";

         }

      }

      else if( m > apps2006[app][1] && m < apps2006[app][3] )

      {    

         retval = "<div class='hol' title='" + apps2006[app][4] + "'>" + dayno + "</div>";

      }

   }



   return retval;

}



function PrintMonth2006(month)

{

   var done = false;

   var day = 0;



   document.write("<table class='inner'><caption><b style='color: #CC3300; font-size: 8pt;'>" + _months[month] + "</b></caption><thead>");

   document.write("<th>Mo</th><th>Tu</th><th>We</th><th>Th</th><th>Fr</th><th>Sa</th><th>Su</th></thead>");

   while(!done)

   {

      document.write("<tr>");

      PrintWeek2006(month,day, firstdays2006[month], daycounts2006[month]);

      document.write("</tr>");

      day = day + 7;

      if( day > daycounts2006[month] + firstdays2006[month])

      {

         done = true;

      }

   }

   document.write("</tbody></table>");

}





function PrintWeek2006(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 = CheckDate2006(monthno,d - min + 1);

         document.write(desc);

      }

      document.write("</td>");

   }

}



///2007.....................



function CheckDate2007(month,dayno)

{

   var retval = new String(dayno);

   var m = month + 1;

   

   for(var app = 0; app < apps2007.length; app++)

   {

      if(m == apps2007[app][1] ) //first month

      {

         if(apps2007[app][3] - apps2007[app][1] > 0)

         {

            if(dayno >= apps2007[app][0])

            {

               retval = "<div class='hol' title='" + apps2007[app][4] + "'>" + dayno + "</div>";

            }

         }

         else

         {

            if(dayno >= apps2007[app][0] && dayno <= apps2007[app][2])

            {

               retval = "<div class='hol' title='" + apps2007[app][4] + "'><a target='_blank' href='" + apps2007[app][5]+ "'>" + dayno + "</a></div>";

            }

         }

      }

      else if(m == apps2007[app][3]) // second month

      {

         if(dayno <= apps2007[app][2])

         {

            retval = "<div class='hol' title='" + apps2007[app][4] + "'>" + dayno + "</div>";

         }

      }

      else if( m > apps2007[app][1] && m < apps2007[app][3] )

      {    

         retval = "<div class='hol' title='" + apps2007[app][4] + "'>" + dayno + "</div>";

      }

   }



   return retval;

}



function PrintMonth2007(month)

{

   var done = false;

   var day = 0;



   document.write("<table class='inner'><caption><b style='color: #CC3300; font-size: 8pt;'>" + _months[month] + "</b></caption><thead>");

   document.write("<th>Mo</th><th>Tu</th><th>We</th><th>Th</th><th>Fr</th><th>Sa</th><th>Su</th></thead>");

   while(!done)

   {

      document.write("<tr>");

      PrintWeek2007(month,day, firstdays2007[month], daycounts2007[month]);

      document.write("</tr>");

      day = day + 7;

      if( day > daycounts2007[month] + firstdays2007[month])

      {

         done = true;

      }

   }

   document.write("</tbody></table>");

}





function PrintWeek2007(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 = CheckDate2007(monthno,d - min + 1);

         document.write(desc);

      }

      document.write("</td>");

   }

}