/*******************************************************
CALENDAR 1.2
Last Modified September 16, 2003
Use either the XML or JavaScript versions to load event data.

All code by Ryan Parman, unless otherwise noted.
(c) 1997-2003, Ryan Parman
http://www.skyzyx.com
Distributed according to SkyGPL 2.1, http://www.skyzyx.com/license/
*******************************************************/


/*******************************************************
DRAW AND POPULATE THE CALENDAR
Use calendar() to draw the current month.  Use calendar(1) to draw 
January of the current year.  Use calendar(1, 2003) to draw January 
of 2003.  For the next month, use calendar(dateObj.getMonth()+2).
*******************************************************/
var calQTY=0;

function calendar(whatMonth, whatYear)
{
	// INITIALIZATION!  DO NOT EDIT!
	calQTY++;
	var allDay = new Array('zo', 'ma', 'di', 'wo', 'do', 'vr', 'za');
	var allMonth = new Array('januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december');
	var allMonthDays= new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	var cal=new Date();
	var thisDay=cal.getDay();
	var thisDate=cal.getDate();

	// HANDLE MONTH FOR ROLLOVER (FOR MULTIPLE MONTHS)
	if (!whatMonth) thisMonth=cal.getMonth();
	else
	{
		if (whatMonth > 12)
		{
			thisMonth=whatMonth-13;
			whatYear=cal.getFullYear()+1;
		}
		else thisMonth=whatMonth-1;
	}

	var thisYear=(!whatYear) ? cal.getFullYear():whatYear;
	var theFirst=new Date(thisYear, thisMonth, 1);
	if (((thisYear%4 == 0) && !(thisYear%100 == 0)) || (thisYear%400 == 0)) allMonthDays[1] = 29;

	ct1=0;

	// DRAW THE CALENDAR (XHTML-COMPLIANT)
	document.write('<table class="calendar">');
	document.write('<tr>');
	document.write('<td colspan="7" class="month"><div align="center" id="MMYY'+calQTY+'">&nbsp;</div></td>');
	document.write('</tr>');

	// FILL DAYS
	document.write('<tr>');
	for (w=0; w<=6; w++)
	{
		document.write('<td class="daysofweek" id="'+allDay[w]+calQTY+'"><div align="center">'+allDay[w]+'</div></td>');
	}
	document.write('</tr>');

	// HOW MANY ROWS?
	if (theFirst.getDay() == 6 && allMonthDays[thisMonth] >29) weeks=6;
	else if (theFirst.getDay() >= 5 && allMonthDays[thisMonth] >30) weeks=6;
	else if (theFirst.getDay() == 0 && allMonthDays[thisMonth] < 29) weeks=4;
	else weeks=5;

	// DRAW THE "DAY" CELLS
	for (x=1; x<=weeks; x++)
	{
		document.write('<tr>');

		for (y=1; y<=7; y++)
		{
			ct2=(ct1*7)+y;
			document.write('<td class="empty" id="'+ct2+'_'+calQTY+'" valign="top" align="right">&nbsp;</td>');
		}
		document.write('</tr>');
		ct1++;
	}
	document.write('</tr>');
	document.write('</table>');

	// MONTH AND YEAR
	document.getElementById('MMYY'+calQTY).innerHTML=allMonth[thisMonth]+' '+thisYear;

	// FILL NUMBERS IN CELLS AND CHANGE CLASSNAME TO "DATE"
	thisBegin=theFirst.getDay();
	for (z=1; z<=allMonthDays[thisMonth]; z++)
	{
		// Date Numbers
		document.getElementById(thisBegin+z+'_'+calQTY).innerHTML=z;
		document.getElementById(thisBegin+z+'_'+calQTY).className='date';
	}

	// HIGHLIGHT CURRENT DAY AND DATE
	if (!whatMonth && !whatYear)
	{
		document.getElementById((thisDate+thisBegin)+'_'+calQTY).className='highlight';
		document.getElementById(allDay[thisDay]+calQTY).className='highlight';
	}
}

