function Calendar(dM,dMA){
document.getElementById("Calendar").innerHTML="";
var month="";
var monthA="";
var alldate=new Date();
if((dM==0)&&(dMA==0)){
month=alldate.getMonth();
}else{
monthA=alldate.getMonth();
month=dMA+dM;
}
var year=alldate.getYear();
if (year<2000)
year=year+1900;
var dm=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var dName=new Array("อาทิตย์","จันทร์","อังคาร","พุธ","พฤหัสฯ","ศุกร์","เสาร์");
var dayName=dName[alldate.getDay()];
var thmon=new Array('มกราคม','กุมภาพันธ์','มีนาคม','เมษายน','พฤษภาคม','มิถุนายน','กรกฎาคม','สิงหาคม','กันยายน','ตุลาคม','พฤศจิกายน','ธันวาคม');
if((year%4==0)&&(year%100!=0)){
dm[1]=29;
}
var stopmon=new Array(1,1,1,1,1,1,1,1,1,1,1,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]="วันขึ้นปีใหม่";
	stopday[1]=2;
	stopdes[1]="วันหยุดชดเชย วันขึ้นปีใหม่";
	stopday[2]=9;
	stopdes[2]="กำหนดยื่นแบบ ภายในวันที่ 7 มกราคม ยื่นแบบ ภงด. 1, ภงด. 2, ภงด. 3, ภงด. 53 0 ซึ่งตรงกับวันหยุดราชการ ให้เลื่อนเป็นวันที่ 9 มกราคม";
	stopday[3]=14;
	stopdes[3]="วันเด็ก";
	stopday[4]=16;
	stopdes[4]="กำหนดยื่นแบบ ภายในวันที่ 15 มกราคม ยื่นแบบ ภพ. 30, ภธ.40 ซึ่งตรงกับวันหยุดราชการ ให้เลื่อนเป็นวันที่ 16 มกราคม และ วันครู";
	stopday[5]=23;
	stopdes[5]="วันตรุษจีน";
	stopday[6]=31;
	stopdes[6]="กำหนดยื่นแบบ ภายในวันที่ 31 มกราคม ยื่นแบบ ภงด. 2ก , ภงด. 3ก";
	var stop=0;
	}else if(month==1){
	stopday[0]=7;
	stopdes[0]="กำหนดยื่นแบบ ภายในวันที่ 7 กุมภาพันธ์ ยื่นแบบ ภงด. 1, ภงด. 2, ภงด. 3, ภงด. 53";
	stopday[1]=14;
	stopdes[1]="วันวาเลนไทน์";
	stopday[2]=15;
	stopdes[2]="กำหนดยื่นแบบ ภายในวันที่ 15 มกราคม ยื่นแบบ ภพ. 30, ภธ.40";
	stopday[3]=29;
	stopdes[3]="กำหนดยื่นแบบ   ภายในสิ้นเดือนกุมภาพันธ์ ยื่นแบบ ภงด. 1ก , ภงด. 1ก พิเศษ";
	var stop=0;
	}else if(month==2){
	stopday[0]=7;
	stopdes[0]="กำหนดยื่นแบบ   ภายในวันที่ 7 มีนาคม ยื่นแบบ ภงด. 1, ภงด. 2, ภงด. 3, ภงด. 53 และ วันมาฆบูชา";
	stopday[1]=15;
	stopdes[1]="กำหนดยื่นแบบ    ภายในวันที่ 15 มีนาคม ยื่นแบบ ภพ. 30 , ภธ. 40";
	stopday[2]=31;
	stopdes[2]="กำหนดยื่นแบบ ภายในวันที่ 31 มีนาคม  สิ้นสุดการยื่นแบบ ภงด. 90, ภงด. 91 ซึ่งตรงกับวันหยุดราชการ ให้เลื่อนเป็นวันที่ 2 เมษายน";
	var stop=0;
	}else if(month==3){
	stopday[0]=2;
	stopdes[0]="กำหนดยื่นแบบ ภายในวันที่ 31 มีนาคม  สิ้นสุดการยื่นแบบ ภงด. 90, ภงด. 91 ซึ่งตรงกับวันหยุดราชการ ให้เลื่อนเป็นวันที่ 2 เมษายน";
	stopday[1]=6;
	stopdes[1]="วันจักรี";
	stopday[2]=9;
	stopdes[2]="กำหนดยื่นแบบ ภายในวันที่ 7 เมษายน ยื่นแบบ ภงด. 1, ภงด. 2, ภงด. 3, ภงด. 53 ซึ่งตรงกับวันหยุดราชการ ให้เลื่อนเป็นวันที่ 9 เมษายน";
	stopday[3]=13;
	stopdes[3]="วันสงกรานต์";
	stopday[4]=14;
	stopdes[4]="วันสงกรานต์";
	stopday[5]=15;
	stopdes[5]="วันสงกรานต์";
	stopday[6]=16;
	stopdes[6]="วันสงกรานต์";
	stopday[7]=17;
	stopdes[7]="วันสงกรานต์";
	stopday[8]=18;
	stopdes[8]="กำหนดยื่นแบบ   ภายในวันที่ 15 เมษายน ยื่นแบบ ภพ. 30 , ภธ.40 ซึ่งตรงกับวันหยุดราชการ ให้เลื่อนเป็นวันที่ 18 เมษายน";
	var stop=0;
	}else if(month==4){
	stopday[0]=1;
	stopdes[0]="วันแรงงานแห่งชาติ";
	stopday[1]=5;
	stopdes[1]="วันฉัตรมงคล";
	stopday[2]=7;
	stopdes[2]="วันหยุดชดเชย วันฉัตรมงคล";
	stopday[3]=8;
	stopdes[3]="กำหนดยื่นแบบ ภายในวันที่ 7 พฤษภาคม ยื่นแบบ ภงด. 1, ภงด. 2, ภงด. 3, ภงด. 53 ซึ่งตรงกับวันหยุดราชการ ให้เลื่อนเป็นวันที่ 8 พฤษภาคม";
	stopday[4]=9;
	stopdes[4]="วัน พืชมงคลจรดพระนังคัลแรกนาขวัญ";
	stopday[5]=15;
	stopdes[5]="กำหนดยื่นแบบ ภายในวันที่ 15 พฤษภาคม ยื่นแบบ ภพ. 30, ภธ. 40";
	stopday[6]=29;
	stopdes[6]="กำหนดยื่นแบบ ภายในวันที่ 29 พฤษภาคม (150 วันนับแต่วันสุดท้ายของรอบระยะเวลาบัญชี) ยื่นแบบ ภงด. 50 , ภงด. 52 , ภงด. 55 (สำหรับนิติบุคคลที่มีรอบระยะเวลาบัญชีเริ่มต้น และสิ้นสุด 1 ม.ค.-31 ธ.ค.)";
	var stop=0;
	}else if(month==5){
	stopday[0]=4;
	stopdes[0]="วันวิสาขบูชา";
	stopday[1]=7;
	stopdes[1]="กำหนดยื่นแบบ ภายในวันที่ 7 มิถุนายน ยื่นแบบ ภงด. 1, ภงด. 2, ภงด. 3, ภงด. 53";
	stopday[2]=15;
	stopdes[2]="กำหนดยื่นแบบ ภายในวันที่ 15 มิถุนายน ยื่นแบบ ภพ. 30, ภธ. 40";
	var stop=0;
	}else if(month==6){
	stopday[0]=1;
	stopdes[0]="วันหยุดครึ่งปีธนาคาร";
	stopday[1]=9;
	stopdes[1]="กำหนดยื่นแบบ ภายในวันที่ 7 กรกฎาคม ยื่นแบบ ภงด. 1, ภงด. 2, ภงด. 3, ภงด. 53 ซึ่งตรงกับวันหยุดราชการ ให้เลื่อนเป็นวันที่ 9 กรกฎาคม";
	stopday[2]=16;
	stopdes[2]="กำหนดยื่นแบบ ภายในวันที่ 15 กรกฎาคม ยื่นแบบ ภพ. 30, ภธ.40 ซึ่งตรงกับวันหยุดราชการ ให้เลื่อนเป็นวันที่ 16 กรกฎาคม";
	var stop=0;
	}else if(month==7){
	stopday[0]=2;
	stopdes[0]="วันอาสาฬหบูชา";
	stopday[1]=3;
	stopdes[1]="วันเข้าพรรษา";
	stopday[2]=7;
	stopdes[2]="กำหนดยื่นแบบ ภายในวันที่ 7 สิงหาคม ยื่นแบบ ภงด. 1, ภงด. 2, ภงด. 3, ภงด. 53";
	stopday[3]=12;
	stopdes[3]="วันเฉลิมพระชนมพรรษา สมเด็จพระนางเจ้าฯ พระบรมราชินีนาถ";
	stopday[4]=13;
	stopdes[4]="วันหยุดชดเชย วันเฉลิมพระชนมพรรษา สมเด็จพระนางเจ้าฯ พระบรมราชินีนาถ";
	stopday[5]=15;
	stopdes[5]="กำหนดยื่นแบบ ภายในวันที่ 15 สิงหาคม ยื่นแบบ ภพ. 30, ภธ. 40";
	stopday[6]=31;
	stopdes[6]="กำหนดยื่นแบบ   ภายในวันที่ 31 สิงหาคมยื่นแบบ ภงด. 51 (สำหรับนิติบุคคลที่มีรอบระยะเวลาบัญชีเริ่มต้น และสิ้นสุด 1 ม.ค.-31 ธ.ค.)";
	var stop=0;
	}else if(month==8){
	stopday[0]=7;
	stopdes[0]="กำหนดยื่นแบบ ภายในวันที่ 7 กันยายน ยื่นแบบ ภงด. 1, ภงด. 2, ภงด. 3, ภงด. 53";
	stopday[1]=17;
	stopdes[1]="กำหนดยื่นแบบ ภายในวันที่ 15 กันยายน ยื่นแบบ ภพ. 30, ภธ.40 ซึ่งตรงกับวันหยุดราชการ ให้เลื่อนเป็นวันที่ 17 กันยายน";
	stopday[2]=30;
	stopdes[2]="กำหนดยื่นแบบ ภายในวันที่ 30 กันยายน ยื่นแบบ ภงด.94  ซึ่งตรงกับวันหยุดราชการ ให้เลื่อนเป็นวันที่ 1 ตุลาคม";
	var stop=0;
	}else if(month==9){
	stopday[0]=1;
	stopdes[0]="กำหนดยื่นแบบ ภายในวันที่ 30 กันยายน ยื่นแบบ ภงด.94  ซึ่งตรงกับวันหยุดราชการ ให้เลื่อนเป็นวันที่ 1 ตุลาคม";
	stopday[1]=8;
	stopdes[1]="กำหนดยื่นแบบ ภายในวันที่ 7 ตุลาคม ยื่นแบบ ภงด. 1, ภงด. 2, ภงด. 3, ภงด. 53 ซึ่งตรงกับวันหยุดราชการ ให้เลื่อนเป็นวันที่ 8 ตุลาคม";
	stopday[2]=15;
	stopdes[2]="กำหนดยื่นแบบ ภายในวันที่ 15 ตุลาคม ยื่นแบบ ภพ. 30,  ภธ. 40";
	stopday[3]=23;
	stopdes[3]="วันปิยะมหาราช";
	stopday[4]=30;
	stopdes[4]="วันปวารณาออกพรรษา";
	var stop=0;
	}else if(month==10){
	stopday[0]=7;
	stopdes[0]="กำหนดยื่นแบบ  ภายในวันที่ 7 พฤศจิกายน ยื่นแบบ ภงด. 1, ภงด. 2, ภงด. 3, ภงด. 53";
	stopday[1]=15;
	stopdes[1]="กำหนดยื่นแบบ   ภายในวันที่ 15 พฤศจิกายน ยื่นแบบ ภพ. 30 , ภธ. 40";
	stopday[2]=28;
	stopdes[2]="วันลอยกระทง";
	var stop=0;
	}else if(month==11){
	stopday[0]=5;
	stopdes[0]="วันเฉลิมพระชนมพรรษา พระบาทสมเด็จพระเจ้าอยู่หัว";
	stopday[1]=7;
	stopdes[1]="กำหนดยื่นแบบ ภายในวันที่ 7 ธันวาคม ยื่นแบบ ภงด. 1, ภงด. 2, ภงด. 3, ภงด. 53";
	stopday[2]=10;
	stopdes[2]="วันพระราชทานรัฐธรรมนูญ";
	stopday[3]=17;
	stopdes[3]="กำหนดยื่นแบบ ภายในวันที่ 15 ธันวาคม ยื่นแบบ ภพ.30, ภธ.40 ซึ่งตรงกับวันหยุดราชการ ให้เลื่อนเป็นวันที่ 17 ธันวาคม";
	stopday[4]=31;
	stopdes[4]="วันสิ้นปี";
	var stop=0;
	}
}
var form="";
/*if(((dMA==0)&&(month==0))||((month==0)&&(month==monthA))){
form="<table width=215 border=0 align='left' style='margin-top:15;font-family:Arial,Helvetica,sans-serif;font-size:11px;border-style:solid;border-width:0;'><tr align='center'><td colspan=7 bgcolor='#ff99cc' width='100%'><b><font color='#000000'>วัน"+dayName+"<br />"+today+" "+thmon[month]+" "+(year+543)+"</font>&nbsp;<button onclick='Calendar(1,"+month+");'>&gt;&gt;</button></b></td></tr>";
}else if(((dMA==0)&&(month==11))||((month==11)&&(month==monthA))){
form="<table width=215 border=0 align='left' style='margin-top:15;font-family:Arial,Helvetica,sans-serif;font-size:11px;border-style:solid;border-width:0;'><tr align='center'><td colspan=7 bgcolor='#ff99cc' width='100%'><b><font color='#000000'>วัน"+dayName+"<br /><button onclick='Calendar(-1,"+month+");'>&lt;&lt;</button>&nbsp;"+today+" "+thmon[month]+" "+(year+543)+"</font></b></td></tr>";
}else if(((dM==0)&&(dMA==0)&&(month!=0)&&(month!=11))||((month!=0)&&(month!=11)&&(month==monthA))){
form="<table width=215 border=0 align='left' style='margin-top:15;font-family:Arial,Helvetica,sans-serif;font-size:11px;border-style:solid;border-width:0;'><tr align='center'><td colspan=7 bgcolor='#ff99cc' width='100%'><b><font color='#000000'>วัน"+dayName+"<br /><button onclick='Calendar(-1,"+month+");'>&lt;&lt;</button>&nbsp;"+today+" "+thmon[month]+" "+(year+543)+"</font>&nbsp;<button onclick='Calendar(1,"+month+");'>&gt;&gt;</button></b></td></tr>";
}else if((dM!=0)&&(dMA==0)&&(month!=0)&&(month!=11)){
form="<table width=215 border=0 align='left' style='margin-top:15;font-family:Arial,Helvetica,sans-serif;font-size:11px;border-style:solid;border-width:0;'><tr align='center'><td colspan=7 bgcolor='#ff99cc' width='100%'><b><button onclick='Calendar(-1,"+month+");'>&lt;&lt;</button>&nbsp;<font color='#000000'>"+thmon[month]+" "+(year+543)+"</font>&nbsp;<button onclick='Calendar(1,"+month+");'>&gt;&gt;</button></b></td></tr>";
}else if((dMA!=0)&&(month==0)){
form="<table width=215 border=0 align='left' style='margin-top:15;font-family:Arial,Helvetica,sans-serif;font-size:11px;border-style:solid;border-width:0;'><tr align='center'><td colspan=7 bgcolor='#ff99cc' width='100%'><b><font color='#000000'>"+thmon[month]+" "+(year+543)+"</font>&nbsp;<button onclick='Calendar(1,"+month+");'>&gt;&gt;</button></b></td></tr>";
}else if((dMA!=0)&&(month==11)){
form="<table width=215 border=0 align='left' style='margin-top:15;font-family:Arial,Helvetica,sans-serif;font-size:11px;border-style:solid;border-width:0;'><tr align='center'><td colspan=7 bgcolor='#ff99cc' width='100%'><b><button onclick='Calendar(-1,"+month+");'>&lt;&lt;</button>&nbsp;<font color='#000000'>"+thmon[month]+" "+(year+543)+"</font></b></td></tr>";
}else if((dMA!=0)&&(month!=0)&&(month!=11)){
form="<table width=215 border=0 align='left' style='margin-top:15;font-family:Arial,Helvetica,sans-serif;font-size:11px;border-style:solid;border-width:0;'><tr align='center'><td colspan=7 bgcolor='#ff99cc' width='100%'><b><button onclick='Calendar(-1,"+month+");'>&lt;&lt;</button>&nbsp;<font color='#000000'>"+thmon[month]+" "+(year+543)+"</font>&nbsp;<button onclick='Calendar(1,"+month+");'>&gt;&gt;</button></b></td></tr>";
}*/

form="<table width=215 border=0 align='left' style='margin-top:15;font-family:Arial,Helvetica,sans-serif;font-size:11px;border-style:solid;border-width:0;'><tr align='center'><td colspan=7 bgcolor='#ff99cc' width='100%'><b><font color='#000000'>วัน"+dayName+"<br />"+today+" "+thmon[month]+" "+(year+543)+"</font></b></td></tr>";

	form+="<tr bgcolor='#99ff66'>";
	form+="<td bgcolor=#ff0000 width='14%' align='center'><font color=#ffffff>อา</font></td>";
	form+="<td bgcolor=#ffff00 width='14%' align='center'><font color=#000000>จ.</font></td>";
	form+="<td bgcolor=#ff0099 width='14%' align='center'><font color=#ffffff>อ.</font></td>";
	form+="<td bgcolor=#99ff66 width='14%' align='center'><font color=#000000>พ.</font></td>";
	form+="<td bgcolor=#ff9999 width='14%' align='center'><font color=#ffffff>พฤ</font></td>";
	form+="<td bgcolor=#99ccff width='14%' align='center'><font color=#000000>ศ.</font></td>";
	form+="<td bgcolor=#cc99ff width='14%' align='center'><font color=#ffffff>ส.</font></td>";
	form+="</tr><tr>";
var start=1;
for(i=1;start<=dm[month];i++){
	if((i-1)<alldate.getDay()){
		form+="<td bgcolor='#afc0d0' style='color:#afc0d0;' align='center'>dw</td>";
	}else{
	if(((start==today)&&(stopday[stop]!=today)&&(dM==0)&&(dMA==0))||((start==today)&&(stopday[stop]!=today)&&(month==monthA))){
		form+="<td bgcolor='#afc0d0' align='center'><b><font color='#FF0000' style='cursor:hand;' title='วันนี้'>"+start+"</font></b></td>";
	}else if((start==stopday[stop]&&(stopday[stop]==today)&&(dM==0)&&(dMA==0))||(start==stopday[stop]&&(stopday[stop]==today)&&(month==monthA))){
		form+="<td bgcolor='#ffff00' align='center'><b><font color='#FF0000' style='cursor:hand;' title='วันนี้ "+stopdes[stop]+"'>"+start+"</font></b></td>";
		var thisday=stopdes[stop];
		stop++;
	}else if(start==stopday[stop]){
		form+="<td bgcolor='#afc0d0' align='center'><font color='#ffff00' style='cursor:hand;' title='"+stopdes[stop]+"'>"+start+"</font></td>";
		stop++;
	}else{
		form+="<td bgcolor='#afc0d0' align='center'><font color='blue'>"+start+"</font></td>";
	}
		start++;
	}
	if((i %7)==0){
		form+="</tr><tr style='color:#330099;'>";
	}
}

if (((thisday!=undefined)&&(dM==0)&&(dMA==0))||((thisday!=undefined)&&(month==monthA)))
{form+="<tr><td align='center' bgcolor='#99ff66' colspan=7 style='font-family:Arial,Helvetica,sans-serif;color:#000000;font-size:11px;' align=center>วันนี้ "+thisday+"</td></tr><tr><td bgcolor='#ff99cc' colspan=7 style='color:#000000;' align=center><b>GK Outsourcing Services</b></td></tr></table><br /><br /><br />";
}else{
form+="</tr><tr><td bgcolor='#ff99cc' colspan=7 style='color:#000000;' align='center'><b>GK Outsourcing Services</b></td></tr></table>";
}
document.getElementById("Calendar").innerHTML=form;
}
