var months = ["Janvier 2012","F&eacute;vrier 2012","Mars 2012","Avril 2012","Mai 2012","Juin 2012","Juillet 2012","Ao&ucirc;t 2012","Septembre 2012","Octobre 2012","Novembre 2012","D&eacute;cembre 2012",			"Janvier 2012","F&eacute;vrier 2012","Mars 2012","Avril 2012","Mai 2012","Juin 2012","Juillet 2012","Ao&ucirc;t 2012","Septembre 2012","Octobre 2012","Novembre 2012","D&eacute;cembre 2012",			"Janvier 2012","F&eacute;vrier 2012","Mars 2012","Avril 2012","Mai 2012","Juin 2012","Juillet 2012","Ao&ucirc;t 2012","Septembre 2012","Octobre 2012","Novembre 2012","D&eacute;cembre 2012",			"Janvier 2012","F&eacute;vrier 2012","Mars 2012","Avril 2012","Mai 2012","Juin 2012","Juillet 2012","Ao&ucirc;t 2012","Septembre 2012","Octobre 2012","Novembre 2012","D&eacute;cembre 2012"];


var daycounts = [31,29,31,30,31,30,31,31,30,31,30,31,    31,29,31,30,31,30,31,31,30,31,30,31,  31,29,31,30,31,30,31,31,30,31,30,31,  31,29,31,30,31,30,31,31,30,31,30,31]; //for leap years, remember to set february to 29 days







var firstdays = [6,2,3,6,1,4,6,2,5,0,3,5,   6,2,3,6,1,4,6,2,5,0,3,5,  6,2,3,6,1,4,6,2,5,5,1,3, 6,2,3,6,1,4,6,2,5,0,3,5];

//oct -dec 2012 - 0,3,5
















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 cellpadding='0' cellspacing='0' class='inner'><caption style='background-color : #e0e7c9; padding: 3px 0 3px 0;'><b>" + months[month] + "</b></caption><thead>");



   document.write("<th class='th.inner'>&nbsp;Lun&nbsp;</th><th>&nbsp;Mar&nbsp;</th><th>&nbsp;Mer&nbsp;</th><th>&nbsp;Jeu&nbsp;</th><th>&nbsp;Ven&nbsp;</th><th>&nbsp;Sam&nbsp;</th><th>&nbsp;Dim&nbsp;</th></thead>");



   while(!done)



   {



      document.write("<tr class='tr.inner'>");



      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><p>");



}











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>");



   }



}
