<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Script was adapted by J.P.Riegel for the website www.familie-riegel.de -->
<!-- Begin
//  SET ARRAYS
var day_of_week = new Array('Mo','Di','Mi','Do','Fr','Sa', 'So');
var month_of_year = new Array('Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember');

//  DECLARE AND INITIALIZE VARIABLES
var calendar = new Date();
var day = calendar.getDate();     // Returns day (1-31)
var txt;
if (day<10)
{
  var month=calendar.getMonth();
  if (month==0)
  {
    calendar.setMonth(11);
    calendar.setYear(calendar.getYear()-1);
  }
  else
  {
    calendar.setMonth(month-1);
  }
  txt=getCalendar(calendar, false);
  document.write(txt);
  document.write("<br>\n");
  calendar = new Date();
}
//  PRINT CALENDAR
txt=getCalendar(calendar, true);
document.write(txt);
document.write("<br>\n");
if (day>20)
{
  calendar = new Date();
  var month=calendar.getMonth();
  if (month==11)
  {
    calendar.setMonth(0);
    calendar.setYear(calendar.getYear()+1);
  }
  else
  {
    calendar.setMonth(month+1);
  }
  txt=getCalendar(calendar, false);
  document.write(txt);
  calendar = new Date();
}

function getCalendar(calendar, highlight)
{
  var year    = calendar.getFullYear(); // Returns year
  var month   = calendar.getMonth();    // Returns month (0-11)
  var today   = calendar.getDate();     // Returns day (1-31)
  var weekday = calendar.getDay()-1;    // Returns day (-1-5)
  if (weekday < 0) weekday=6;           // correction that week starts with monday

  var DAYS_OF_WEEK = 7;      // "constant" for number of days in a week
  var DAYS_OF_MONTH = 31;    // "constant" for number of days in a month
  var cal;    // Used for printing

  calendar.setDate(1);         // Start the calendar day at '1'

  var TR_start = '<TR>';
  var TR_end = '</TR>';
  var highlight_start = '<TABLE CELLSPACING=0 BORDER=1 BGCOLOR=C8C015 BORDERCOLOR=CCCCCC><TR><TD WIDTH=20><B><CENTER>';
  var highlight_end   = '</CENTER></TD></TR></TABLE></B>';
  var TD_start = '<TD WIDTH="30"><CENTER>';
  var TD_start_red = '<TD WIDTH="30" BGCOLOR="#EE1111"><CENTER>';
  var TD_start_lightred = '<TD WIDTH="30" BGCOLOR="#EE6666"><CENTER>';
  var TD_end = '</CENTER></TD>';

  cal =  '<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 BORDERCOLOR=#BBBBBB summary="Calendar"><TR><TD>';
  cal += '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 summary="Calendar">' + TR_start;
  cal += '<TD COLSPAN="' + DAYS_OF_WEEK + '" BGCOLOR="#E8E818"><CENTER><B>';
  cal += month_of_year[month]  + '   ' + year + '</B>' + TD_end + TR_end;
  cal += TR_start;

  var td=TD_start
  // LOOPS FOR EACH DAY OF WEEK
  for(index=0; index < DAYS_OF_WEEK; index++)
  {
    if (index>4) td=TD_start_red;   // mark weekend
    // BOLD TODAY'S DAY OF WEEK
    if((weekday == index) && highlight)
      cal += td + '<B>' + day_of_week[index] + '</B>' + TD_end;  // PRINTS DAY
    else
      cal += td + day_of_week[index] + TD_end;
  }

  cal += TD_end + TR_end;
  cal += TR_start;

  // FILL IN BLANK GAPS UNTIL TODAY'S DAY
  var dday = calendar.getDay()-1;
  if (dday<0) dday=6;
  td=TD_start;
  for(index=0; index < dday; index++)
  {
    if (index>4) td=TD_start_lightred;   // mark weekend
    cal += td + '  ' + TD_end;
  }

  // LOOPS FOR EACH DAY IN CALENDAR
  for(index=0; index < DAYS_OF_MONTH; index++)
  {
    if( calendar.getDate() > index )
    {
      // RETURNS THE NEXT DAY TO PRINT
      week_day = calendar.getDay()-1;
      if (week_day<0)
        week_day=6;

      // START NEW ROW FOR FIRST DAY OF WEEK
      if(week_day == 0)
        cal += TR_start;

      if (week_day>4)
        td=TD_start_lightred;
      else
        td=TD_start;

      if(week_day != DAYS_OF_WEEK)
      {
        // SET VARIABLE INSIDE LOOP FOR INCREMENTING PURPOSES
        var day  = calendar.getDate();

        // HIGHLIGHT TODAY'S DATE
        if( (today==calendar.getDate()) && highlight )
          cal += td + highlight_start + day + highlight_end + TD_end; // PRINTS DAY
        else
          cal += td + day + TD_end;
      }
      // END ROW FOR LAST DAY OF WEEK
      if(week_day == DAYS_OF_WEEK)
        cal += TR_end;
    }

    // INCREMENTS UNTIL END OF THE MONTH
    calendar.setDate(calendar.getDate()+1);
  }// end for loop
  cal += '</TD></TR></TABLE></TABLE>';

  return cal;
}
//  End -->