
<!-- Begin
function calendar()
{
// ชื่อเดือน ตอนใช้จะตัดไปใช้เฉพาะบางส่วน
var monthNames = "January  February March    April    May      June     July     August   SeptemberOctober  November December ";//รับค่าวันปัจจุบัน
var today = new Date();
var thisDay;
//กำหนดจำนวนวันในแต่ละเดือน
var monthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
//กำหนดค่าปี
year = today.getYear() + 0;
// กำหนดค่าวัน
thisDay = today.getDate();
// คำนวนปีอธิกสุรธิน
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) 
monthDays[1] = 29;
// หาวันแรกที่แสดงในปฏิทิน
nDays = monthDays[today.getMonth()];
firstDay = today;
firstDay.setDate(1); 
testMe = firstDay.getDate();
if (testMe == 2)
firstDay.setDate(0); 
startDay = firstDay.getDay();
document.writeln("<CENTER>");
document.write("<TABLE width='100%' border='1' cellpadding='0' cellspacing='0'  bgcolor='#0079C0' >");
document.write("<TR  ><TH COLSPAN=7 > <font size='-5' face='Arial' color='#FFFFFF'>");
document.write(monthNames.substring(today.getMonth() * 9,
(today.getMonth() + 1) * 9));
document.write("   ");
document.write(year);
// แสดงชื่อวัน
document.write("<TR  class='CobaltFieldCaptionTD'><TH ><font size='-5' color='#FFFFFF'>SU</font><TH ><font color='#FFFFFF' size='-5'>M<TH ><font size='-5' color='#FFFFFF'>T<TH ><font size='-5' color='#FFFFFF'>W</font><TH ><font size='-5' color='#FFFFFF'>TH</font><TH ><font size='-5' color='#FFFFFF'>F</font><TH ><font size='-5' color='#FFFFFF'>S</font>");
// เข้าสู่ลูปเพื่อแสดงเลขวันที่ 
document.write("<TR >");
column = 0;
for (i=0; i<startDay; i++) {
document.write("<TD>");
column++;
}
for (i=1; i<=nDays; i++) {
document.write("<TD class='CobaltFieldCaptionTD'><strong><font face='Arial' color='#FFFFFF'> ");
// ถ้าเป็นวันนี้ ให้ทำเป็นสี Yellow
if (i == thisDay)
document.write("<strong><FONT COLOR=\"#FFFF00\" > <blink>")
document.write(i);
if (i == thisDay)
document.write("</blink></FONT></strong>")
column++;
if (column == 7) {
document.write("  </font ><TR>"); 
column = 0;
}
}
// ปิดตาราง
document.write("</TABLE>");
document.writeln("</CENTER>");
}
// End -->





