var months = new Array(12);
months[0] = "Jan.";
months[1] = "Feb.";
months[2] = "Mar.";
months[3] = "Apr.";
months[4] = "May";
months[5] = "Jun.";
months[6] = "Jul.";
months[7] = "Aug.";
months[8] = "Sep.";
months[9] = "Oct.";
months[10] = "Nov.";
months[11] = "Dec.";

var days = new Array(7);
days[0] = "S";
days[1] = "M";
days[2] = "T";
days[3] = "W";
days[4] = "T";
days[5] = "F";
days[6] = "S";

var today = new Date();
var firstday = new Date(today.getFullYear(), today.getMonth(), 1);
var theday;
document.open();
document.write("<table>");
document.write("<caption>" + months[today.getMonth()] + "<\/caption>");
document.write("<tr>");
for(i = 0; i < 7; i ++){
	if(i == 0){
		document.write("<td class='sunday'>" + days[i] + "<\/td>");
	}else if(i == 6){
		document.write("<td class='saturday'>" + days[i] + "<\/td>");
	}else{
		document.write("<td>" + days[i] + "<\/td>");
	}
}
var match_date = false;
document.write("<\/tr>");
for(i = 0; i < 6; i ++){
	document.write("<tr>");
	for(j = 0; j < 7; j ++){
		theday = new Date(today.getFullYear(), today.getMonth(), i * 7 + j - firstday.getDay() + 1);
		if(theday.getMonth() == today.getMonth()){
			for(k = 0, match_date = false; k < update_date.length; k ++){
				if(theday.getFullYear() == update_date[k].getFullYear() && theday.getMonth() == update_date[k].getMonth() && theday.getDate() == update_date[k].getDate()){
					match_date = true;
				}
			}
			if(match_date){
				document.write("<td class='update'>");
			}else if(j == 0){
				document.write("<td class='sunday'>");
			}else if(j == 6){
				document.write("<td class='saturday'>");
			}else{
				document.write("<td>");
			}
			document.write(i * 7 + j - firstday.getDay() + 1);
		}else{
			document.write("<td>");
		}
		document.write("<\/td>");
	}
	document.write("<\/tr>");
}
document.write("<\/table>");
document.close();