function montharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11) 
{
	this[0] = m0;
	this[1] = m1;
	this[2] = m2;
	this[3] = m3;
	this[4] = m4;
	this[5] = m5;
	this[6] = m6;
	this[7] = m7;
	this[8] = m8;
	this[9] = m9;
	this[10] = m10;
	this[11] = m11;
}

function calendar() {

	var months = new Array("มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฏาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม"); 
	var nYear = new Array("ชวด","ฉลู","ชาล","เถาะ","มะโรง","มะเส็ง","มะเมีย","มะแม","วอก","ระกา","จอ","กุน");
	var tMonth = new Array("อ้าย","ยี่","สาม","สี่","ห้า","หก","เจ็ด","แปด","เก้า","สิบ","สิบเอ็ด","สิบสอง");
	var dName = new Array("จันทร์","อังคาร","พุธ","พฤหัสฯ","ศุกร์","เสาร์","อาทิตย์");

	var today = new Date();
	var thisDay;
	var monthDays = new montharr(31, 28, 31, 30, 31, 30, 31, 31, 30,31, 30, 31);
	var thisMonth    = months[today.getMonth()];
	var dayName    = dName[today.getDay()];
	
	year = 543+ today.getYear() + 0;

	yName = nYear[year % 10];
	mthaiMth  = tMonth[today.getMonth()+1];
	
	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.write("<TABLE BORDER=1 BGCOLOR=#F1F1F1 WIDTH=140>");

	document.write("<TR BGCOLOR=#336600><TH COLSPAN=7>");
                //document.write("<IMG SRC="+mImgDir+mImage+" BORDER=0></TH></TR>");
                document.write("<FONT FACE=MS Sans Serif COLOR=#FFFFFF>"+thisMonth+" "+year+"</FONT></TH></TR>");

//	document.write("<TR bgcolor=#FFFF99><TD CLASS=thaifont COLSPAN=7 ALIGN=CENTER><FONT COLOR=#FF0000><B>");
 //    document.write("เดือน"+mthaiMth+"&nbsp;  ปี"+yName+" "+year);
//	document.write("</B></FONT></TD></TR>");

	document.write("<TR>");
	document.write("<TD CLASS=thaifont BGCOLOR=#FF0000 ALIGN=center><FONT  COLOR=#FFFFFF>อา</FOTN></TD>");
	document.write("<TD CLASS=thaifont BGCOLOR=#FFFF00 ALIGN=center><FONT COLOR=#000000>จ.</FOTN></TD>");
	document.write("<TD CLASS=thaifont BGCOLOR=#FF0099 ALIGN=center><FONT  COLOR=#FFFFFF>อ.</FOTN></TD>");
	document.write("<TD CLASS=thaifont BGCOLOR=#99FF66 ALIGN=center><FONT  COLOR=#000000>พ.</FOTN></TD>");
	document.write("<TD CLASS=thaifont BGCOLOR=#FF9999 ALIGN=center><FONT  COLOR=#FFFFFF>พฤ</FOTN></TD>");
	document.write("<TD CLASS=thaifont BGCOLOR=#99CCFF ALIGN=center><FONT COLOR=#000000>ศ.</FOTN></TD>");
	document.write("<TD CLASS=thaifont BGCOLOR=#CC99FF ALIGN=center><FONT COLOR=#FFFFFF>ส.</FOTN></TD>");
	document.write("</TR>");

	document.write("<TR>");

	column = 0;
	for (i=0; i<startDay; i++) {
	document.write("<TD></TD>");
	column++;
	}

	for (i=1; i<=nDays; i++) {
	document.write("<TD ALIGN=RIGHT>");

	if (i == thisDay) 
	   document.write("<FONT COLOR=RED><B>")
	   document.write(i);
	   document.write("</B></FONT>")
	   column++;

	if (column == 7) {
	   document.write("</TD></TR><TR>"); 
	   column = 0;
	}

	}

	document.write("</TABLE>");

}

calendar();
document.write("");
