<!--
setCal();

function esBisiesto(year) {
	if (year % 4 == 0) {
		return true;
	}
	return false;
}

function cuantosDias(month, year) {
	var ar = new Array(12);
	ar[0] = 31; //enero
	ar[1] = (esBisiesto(year)) ? 29 : 28; //febrero
	ar[2] = 31; //marzo
	ar[3] = 30; //abril
	ar[4] = 31; //mayo
	ar[5] = 30; //junio
	ar[6] = 31; //julio
	ar[7] = 31; //agosto
	ar[8] = 30; //septiembre
	ar[9] = 31; //octubre
	ar[10] = 30; //noviembre
	ar[11] = 31; //diciembre

	return ar[month];
}

function nombreMes(month) {
	var ar = new Array(12);
	ar[0] = "enero";
	ar[1] = "febrero";
	ar[2] = "marzo";
	ar[3] = "abril";
	ar[4] = "mayo";
	ar[5] = "junio";
	ar[6] = "julio";
	ar[7] = "agosto";
	ar[8] = "septiembre";
	ar[9] = "octubre";
	ar[10] = "noviembre";
	ar[11] = "diciembre";

	return ar[month];
}

function setCal() {
	// standard time attributes
	var now = new Date();
	var year = now.getFullYear();
	var month = now.getMonth();
	var monthName = nombreMes(month);
	var date = now.getDate();
	now = null;

	// create instance of first day of month, and extract the day on which it occurs
	var firstDayInstance = new Date(year, month, 0);
	var firstDay = firstDayInstance.getDay() ;
	firstDayInstance = null;

	// number of days in current month
	var days = cuantosDias(month, year);

	// call function to draw calendar
	var browserName=navigator.appName; 
		if ((browserName=="Netscape")&&(document.layers))
	{ 
 		drawCal(firstDay + 0, days, date, monthName, + year);
	}
	else
	{
		drawCal(firstDay + 1, days, date, monthName, + year);
	}
}

function drawCal(firstDay, lastDate, date, monthName, year) {
	var text = '';
	text += '<TABLE class="calendario" WIDTH="125" BORDER="0" CELLSPACING="1" CELLPADDING="1">';
	text += '<TH BGCOLOR="#FFFFFF" COLSPAN=7>';
	text += monthName + ' ' + year;
	text += '</TH>';

	// variables to hold constant settings
	var openCol = '<TD>';
	var closeCol = '</FONT></TD>';

	// create array of abbreviated day names
	var weekDay = new Array(6);
	weekDay[0] = "Lu";
	weekDay[1] = "Ma";
	weekDay[2] = "Mi";
	weekDay[3] = "Ju";
	weekDay[4] = "Vi";
	weekDay[5] = "Sa";
	
	text += '<TR BGCOLOR="#EEEEEE">';
	for (var dayNum = 0; dayNum < 6; dayNum++) {
		text += openCol + weekDay[dayNum] + closeCol; 
	}
	text += openCol + '<FONT color="#FF0000">Do</font>' + closeCol ;
	text += '</TR>';
	
	// declaration and initialization of two variables to help with tables
	var digit = 1;
	var curCell = 1;
	
	for (var row = 1; row <= Math.ceil((lastDate + firstDay - 1) / 7); row++) {
		text += '<TR BGCOLOR="#EEEEEE">';
		for (var col = 1; col <= 7; ++col) {
			if (digit > lastDate) //se acabó el calendario
				break;
			if (curCell < firstDay) {
				text += '<TD>&nbsp;</TD>'; //celdas en blanco
				curCell++;
			} else {
				if (digit == date) { //HOY
					text += '<TD>';
					text += '<FONT color="#000000">';
					text += digit;
					text += '</FONT>';
					text += '</TD>';
				}
			else //otros días
				text += '<TD>' + digit + '</TD>';
				digit++;
			}
		}
		text += '</TR>';
	}
	text += '</TABLE>';

	document.write(text);
}
// -->
