<!--
// dwcalandar version :: 1.05
// โปรแกรมนี้เขียนโดย :: นายสิทธิชัย  รักษาสุข
// พัฒนาจากภาษา :: JavaScript
// แจกฟรี ห้ามนำไปใช้เพื่อหาประโยชน์ใด ๆ ทั้งสิ้น และ ห้ามนำไปวางไว้ใน website เพื่อเปิดให้ผู้อื่นเข้ามาทำการ DownLoad 
// เขียนเมื่อ :: 14 กรกฎาคม 2546
// ติดต่อผู้เขียนโปรแกรม e-mail :: dwthai@hotmail.com หรือที่หน้า webboard ของเว็บไซต์ http://www.dwthai.com
// เพิ่มความสามารถจากเวอร์ชั่นเดิม คือ เพิ่มรายงานวันสำคัญประจำเดือนนั้น ๆ 
// version ต่อไปเพิ่มการเรียกดูปฏิทินได้ตลอดปี และทุก ๆ เดือนตามต้องการ โปรดติดตามได้จาก website :: http://www.dwthai.com/
function Calendar(elementid){
var alldate=new Date();
var month=alldate.getMonth();
var year=alldate.getYear();
var dm=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var thdweek=new Array('อา','จ.','อ.','พ.','พฤ','ศ.','ส.');
var thmon=new Array('มกราคม','กุมภาพันธ์','มีนาคม','เมษายน','พฤษภาคม','มิถุนายน','กรกฎาคม','สิงหาคม','กันยายน','ตุลาคม','พฤศจิกายน','ธันวาคม');
var strCal,elementid;
if(year%4==0){
dm[1]=29;
}

var stopmon=new Array(1,0,0,1,1,0,0,1,0,1,0,1); // เลือกว่าเดือนใดมีวันสำคัญบ้าง
var stopday=new Array();
alldate.setMonth(month);
var today=alldate.getDate();
alldate.setDate(1);	
var oneday=alldate.getDate();
if(stopmon[month]==1){ // หาวันหยุดครับ
var stopdes=new Array();
	if(month==0){
	stopday[0]=1;
	stopdes[0]="วันขึ้นปีใหม่";
	var stop=0;
	}else if(month==3){
	stopday[0]=6;
	stopdes[0]="วันจักรี";
	stopday[1]=13;
	stopdes[1]="วันสงกรานต์";
	var stop=0;
	}else if(month==4){
	stopday[0]=5;
	stopdes[0]="วันฉัตรมงคล";
	var stop=0;
	}else if(month==7){
	stopday[0]=12;
	stopdes[0]="วันเฉลิมพระชนมพรรษา สมเด็จพระนางเจ้าฯ พระบรมราชินีนาถ";
	var stop=0;
	}else if(month==9){
	stopday[0]=23;
	stopdes[0]="วันปิยะมหาราช";
	var stop=0;
	}else if(month==11){
	stopday[0]=5;
	stopdes[0]="วันเฉลิมพระชนมพรรษา พระบาทสมเด็จพระเจ้าอยู่หัว";
	stopday[1]=10;
	stopdes[1]="วันพระราชทานรัฐธรรมนูญ";
	stopday[2]=31;
	stopdes[2]="วันสิ้นปี";
	var stop=0;
	}
}
strCal="<table width='180' border='0' align='center' style='background-color: #000000;color: #BF9C5A;border-style: solid;border-width: 2px;border-color: #BF9C5A;'><tr align='center' height='20'><td colspan='7' style='color:#330099;font-size: 12px;font-family: Ms Sans Serif;color:#BF9C5A;font-weight: bold;'>"+thmon[month]+" "+(year+543)+"</td></tr><tr align='center'>";
for(i=0;i<7;i++){
	strCal+="<td align='center' style='font-weight:bold;font-size: 12px;font-family: Ms Sans Serif;height: 20px;'>"+thdweek[i]+"</td>";
}
strCal+="</tr><tr><td colspan='7' style='background-color:#D8C6A2;height: 1px;'></td></tr><tr align='center' style='font-size: 12px;font-family: Ms Sans Serif;height: 18px;'>";
var start=1;
for(i=1;start<=dm[month];i++){
	if((i-1)<alldate.getDay()){
		strCal+="<td style='color:#CCCCCC;'>-</td>";
	}else{
	if(start==today){
	strCal+="<td style='cursor: pointer;border: 1px solid;color: #FFFFFF;font-weight: bold;' title='วันนี้'>"+start+"</td>";
	}else if(start==stopday[stop]){
		strCal+="<td style='border: 1px solid #CCCCCC;cursor: pointer;' title='"+stopdes[stop]+"'>"+start+"</td>";
		stop++;
	}else{
		strCal+="<td>"+start+"</td>";
	}
		start++;
	}
	if((i %7)==0){
		strCal+="</tr><tr align='center' style='font-size: 12px;font-family: Ms Sans Serif;height:18px;'>";
	}

}
strCal+="</tr></table>";
	document.getElementById(elementid).innerHTML=strCal;
}
//-->