// fill the month table with column headings
function day_title(day_name){
     document.write("<TD ALIGN=center WIDTH=35>"+day_name+"</TD>")
}

// fills the month table with numbers
function fill_table(month,month_length)
{ 
  day=1
  // begin the new month table
  document.write("<TABLE BORDER=3 BGCOLOR=#BDC68C CELLSPACING=3 CELLPADDING=%3 ALIGN=center><TR>")
  document.write("<TD COLSPAN=7 ALIGN=center><B>"+month+"   "+year+"</B><TR>")
  // column headings
  day_title("Dim")
  day_title("Lun")
  day_title("Mar")
  day_title("Mer")
  day_title("Jeu")
  day_title("Ven")
  day_title("Sam")
  // pad cells before first day of month
  document.write("</TR><TR>")
  for (var i=1;i<start_day;i++){
        document.write("<TD>")
  }
  // fill the first week of days
  for (var i=start_day;i<8;i++){
        document.write("<TD ALIGN=center>"+day+"</TD>")
        day++
  }
  document.write("<TR>")
  // fill the remaining weeks
  while (day <= month_length) {
     for (var i=1;i<=7 && day<=month_length;i++){
         document.write("<TD ALIGN=center>"+day+"</TD>")
         day++
     }
     document.write("</TR><TR>")
     // the first day of the next month
     start_day=i
  }
  document.write("</TR></TABLE><BR>")
}
// end hiding -->

// set current year
var now = new Date()
var year = now.getYear()
if (year < 1000)
year+=1900
now = null

function leapYear(year) {
if (year % 4 == 0) // basic rule
return true // is leap year
/* else */ // else not needed when statement is "return"
return false // is not leap year
}

// first day of the week of the new year
today= new Date("January 1, "+year)
start_day = today.getDay() + 1   // starts with 0
fill_table("Janvier",31)
fill_table("Février",(leapYear(year)) ? 29 : 28)
fill_table("Mars",31)
fill_table("Avril",30)
fill_table("Mai",31)
fill_table("Juin",30)
fill_table("Juillet",31)
fill_table("Août",31)
fill_table("Septembre",30)
fill_table("Octobre",31)
fill_table("Novembre",30)
fill_table("Décembre",31)

