//var commValue;
//var daysChkYN;

//var commValue = new StringArray(32)
//var daysChkYN = new ChecksArray(32)

//commValue[1]  = "7±Þ ÇàÁ¤Á÷ ½ÃÇèÀÏ"
//commValue[3]  = "9±Þ °æÂûÁ÷ ½ÃÇèÀÏ"
//commValue[10] = "7±Þ °ËÂûÁ÷ ½ÃÇèÀÏ"
//commValue[21] = "³ªµµ ¸ð¸£´Â³¯^^"
//commValue[31] = "½¬´Â³¯"

//daysChkYN[1]  = 1
//daysChkYN[3]  = 1
//daysChkYN[10] = 1
//daysChkYN[21] = 1
//daysChkYN[31] = 1



function StringArray(textV) {
	this.length = textV;
	for (var i=0;i<textV;i++) {
		this[i] = ''
	}
	return this
}



function ChecksArray(numbV) {
	this.length = numbV;
	for (var i=0;i<numbV;i++) {
		this[i] = 0
	}
	return this
}



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 monthNames = "JanFebMarAprMayJunJulAugSepOctNovDec";
	var today = new Date();
	var thisDay;
	var monthDays = new montharr(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	year = today.getYear();

	if (year < 2000)    // Y2K Fix, Isaac Powell
		year = year + 1900; 

	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("<div align=center><font color=#ffffff><b>");
	document.write(year);
	document.write("³â ");
	document.write(today.getMonth()+1);
	document.write("¿ù");
//	document.write(monthNames.substring(today.getMonth() * 3, (today.getMonth() + 1) * 3));
	document.writeln("</b></font></div>");
	document.writeln("</td>");
	document.writeln("</tr>");
	document.writeln("<tr>");
	document.writeln("<td>");
	document.writeln("<table>");
	document.writeln("<tr bgcolor=#f4f4ff>");
	document.writeln("<td width=18 align=center><font color=#ff0000>ÀÏ</font></td>");
	document.writeln("<td width=18 align=center>¿ù</td>");
	document.writeln("<td width=18 align=center>È­</td>");
	document.writeln("<td width=18 align=center>¼ö</td>");
	document.writeln("<td width=18 align=center>¸ñ</td>");
	document.writeln("<td width=18 align=center>±Ý</td>");
	document.writeln("<td width=18 align=center><font color=#6666cc>Åä</font></td>");
	document.writeln("</tr>");
	document.writeln("<tr bgcolor=#efefef>");

	column = 0;

	for (i=0; i<startDay; i++) {
		document.writeln("<td width=18>&nbsp;</td>");
		column++;
	}

	for (i=1; i<=nDays; i++) {
		
		if (daysChkYN[i]==1) {
			document.write("<td width=18 align=center style=cursor:hand onclick=jsGoCalendar("+i+") onmouseover=Showtxt(commValue["+i+"]) onmouseout=Hidetxt(0)>");
			//document.write("<a href=javascript:void(0) onmouseover=writetxt(commValue["+i+"]) onmouseout=writetxt(0)><font color=#2f9701><b>");
			document.write("<a href=javascript:jsGoCalendar("+i+") ><font color=#FF00FF><b>");
		}
		else {
			document.write("<td width=18 align=center>");

			if (column==0 && i != thisDay)
				document.write("<font color=#ff0000>");
			if (i == thisDay)
				document.write("<font color=#000000><b>");
			if (column==6 && i != thisDay)
				document.write("<font color=#6666cc>");
		}
		document.write(i);
		if (i==thisDay || daysChkYN[i]==1) {
			if (daysChkYN[i]==1)
				document.write("</b></font></a>");
			else
				document.write("</b></font>");
		}
		else {
			if ((column==0 || column==6) && i != thisDay)
				document.write("</font>");
		}
		document.writeln("</td>");

		column++;
		if (column == 7) {
			document.writeln("</tr>");
			document.writeln("<tr bgcolor=#efefef>");
			column = 0;
		}
	}

	if (column!=0) {
		for (i=column; i<7; i++) {
			document.writeln("<td width=18>&nbsp;</td>");
		}
		document.writeln("</tr>");
	}

	document.writeln("</table>");
}

//Ç³¼± µµ¿ò¸» º¸±â
function Showtxt(msg) {

 if (msg != '') {
    
	
  msg = msg.replace(/aR_/g, '<br>');
  msg = msg.replace(/bQ_/g, '\"');
  msg = msg.replace(/nQ_/g, '\'');
  msg = msg.replace(/ /g, '&nbsp;');
  msg = msg.replace(/yQ_/g, '');
  msg = msg.replace(/mQ_/g, '\\');
			
  preview_msg.innerHTML = '<TABLE WIDTH=185 BORDER=0 CELLPADDING=0 CELLSPACING=0 align=center>' +
                          '<TR>' +
                          '    <TD width=6><IMG SRC=/images/img_cal/pung_01.gif WIDTH=6 HEIGHT=11></TD>' +
                          '    <TD background=/images/img_cal/pung_05.gif width=185></TD>' +
                          '    <TD width=10><IMG SRC=/images/img_cal/pung_03.gif WIDTH=7 HEIGHT=11></TD>' +
                          '	</TR>' +
                          '	<TR>' +
                          '    <TD background=/images/img_cal/pung_04.gif style width=6></TD>' +
                          '    <TD bgcolor=#FEF0FA width=185>' + 
                          '      <div>' +msg + '</div>' +
                          '    </TD>' +
                          '    <TD background=/images/img_cal/pung_06.gif style width=7></TD>' +
                          '	</TR>' +
                          '	<TR>' +
                          '    <TD width=6><IMG SRC=/images/img_cal/pung_07.gif WIDTH=6 HEIGHT=7></TD>' +
                          '    <TD background=/images/img_cal/pung_08.gif width=185></TD>' +
                          '    <TD width=10><IMG SRC=/images/img_cal/pung_09.gif WIDTH=7 HEIGHT=7></TD>' +
                          '	</TR>' +
                          '</TABLE>';


  preview_msg.style.top = event.y + document.body.scrollTop + 0;
  if (event.x > 800)
    preview_msg.style.left = event.x + document.body.scrollLeft - 150;
  else
    preview_msg.style.left = event.x + document.body.scrollLeft + 0;
  preview_msg.style.display = 'inline';
 }			
			
}

//Ç³¼± µµ¿ò¸» ´Ý±â
function Hidetxt() {
  preview_msg.innerHTML = '';
  preview_msg.style.top = 0;
  preview_msg.style.left = 0;
  preview_msg.style.display = 'none';
}
