function show_calendar() {
	var v_month_names = ['January','February','March','April','May','June','July','August','September','October','November','December'];
	var v_month_lengths = [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	var v_day_names = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];

	var v_actual_date = new Date();
	if (((v_actual_date.getFullYear() % 100 != 0) && (v_actual_date.getFullYear() % 4 == 0))||(v_actual_date.getFullYear() % 400 == 0)) {
		v_month_lengths[1] = 29;
	}
	else {
		v_month_lengths[1] = 28;
	}

	var v_day = v_actual_date.getDate();

	var v_first_day_of_month = new Date(v_actual_date.getFullYear(), v_actual_date.getMonth(), 1);
	var v_first_day_of_month_week = v_first_day_of_month.getDay();

	var v_string = '<table cols="7" width="95%" class="solid_border">';

	v_string += '<tr>';
	v_string += '<td colspan="7" class="centered">';
	v_string += v_month_names[v_actual_date.getMonth()] + ' ' + v_actual_date.getFullYear();
	v_string += '</td>';
	v_string += '</tr>';

	v_string += '<tr>';
	for (v_cols = 0; v_cols < 7; v_cols++) {
		v_string += '<td class="small_centered">';
		v_string += v_day_names[v_cols];
		v_string += '</td>';
	}
	v_string += '</tr>';

	var v_counter = 0;

	for (v_rows = 0; v_rows < 6; v_rows++) {
		if (v_counter <= v_month_lengths[v_actual_date.getMonth()]) {
			v_string += '<tr>';

			if (v_rows == 0) {
				if (v_first_day_of_month_week == 0) {
					v_blank_v_cols = v_first_day_of_month_week = 6;
				}
				else {
					v_blank_v_cols = v_first_day_of_month_week - 1;
				}

				for (v_cols = 0; v_cols < v_blank_v_cols; v_cols++) {
					v_string += '<td class="small_bg_white">&nbsp</td>';
				}
			}
			else {
				v_blank_v_cols = 0;
			}

			for (v_cols = v_blank_v_cols; v_cols < 7; v_cols++) {
				v_counter += 1;

				if (v_counter <= v_month_lengths[v_actual_date.getMonth()]) {
					if (v_cols < 5) {
						if (v_counter == v_day) {
							v_string += '<td class="small_colored">' + v_counter + '</td>';
						}
						else {
							v_string += '<td class="small_bg_white">' + v_counter + '</td>';
						}
					}
					else {
						if (v_counter == v_day) {
							v_string += '<td class="small_colored_fill_red">' + v_counter + '</td>';
						}
						else {
							v_string += '<td class="small_bg_white_fill_red">' + v_counter + '</td>';
						}
					}
				}
				else {
					v_string += '<td class="small_bg_white">&nbsp</td>';
				}
			}

			v_string += '</tr>';
		}
	}

	v_string += '</table>';

	document.getElementById("div_calendar").innerHTML = v_string;

	return (v_actual_date.getFullYear()+"/"+v_actual_date.getMonth()+"/"+v_actual_date.getDay());
}

function expect_day_change() {
	var v_actual_date = new Date();

	if (v_date_shown != (v_actual_date.getFullYear()+"/"+v_actual_date.getMonth()+"/"+v_actual_date.getDay())) {
		alert (v_date_shown + " " + v_actual_date);
		v_date_shown = show_calendar();
	}
	setTimeout("expect_day_change()", 1000);
}

v_date_shown = show_calendar();

expect_day_change();
