var cSplit = "-";
var target; // È£ÃâÇÑ ObjectÀÇ ÀúÀå
var stime;


var bf = "" ;
bf += "<style type='text/css'>\n" ;
//bf += "#minical table, td, th { font-family:'µ¸¿ò' ; font-size:11px ; color:#666666 ; letter-spacing:0 ; text-decoration:none ; }\n" ;
bf += "#minical table { font-family:'µ¸¿ò' ; font-size:11px ; color:#666666 ; letter-spacing:0 ; text-decoration:none ; }\n" ;
bf += "#minical img { border:0px ; }\n" ;

bf += "#minical .week { font-size:11px ; color:#FFFFFF ; text-align:center ; padding:2 0 0 0 ; }\n" ;

bf += "#minical .day { cursor:hand ; padding:2 0 1 0 ; }\n" ;
bf += "#minical .day a:link {}\n" ;
bf += "#minical .day a:visited {}\n" ;
bf += "#minical .day a:hover { text-decoration:underline ; }\n" ;

bf += "#minical .sun { cursor:hand ; padding:2 0 1 0 ; color:#E47E00 ; }\n" ;
bf += "#minical .sun a:link { color:#F35E48 ; }\n" ;
bf += "#minical .sun a:visited { color:#F35E48 ; }\n" ;
bf += "#minical .sun a:hover { color:#F35E48 ; text-decoration:underline ; }\n" ;

bf += "#minical .sat { cursor:hand ; padding:2 0 1 0 ; color:#5893C5 ; }\n" ;
bf += "#minical .sat a:link { color:#5893C5 ; }\n" ;
bf += "#minical .sat a:visited { color:#5893C5 ; }\n" ;
bf += "#minical .sat a:hover { color:#5893C5 ; text-decoration:underline ; }\n" ;

bf += ".calendar { width:189px ; display:none ; position:absolute ; z-index:70 ; }\n" ;
bf += "</style>\n" ;
bf += "<div id='minical' oncontextmenu='return false' ondragstart='return false' onselectstart='return false' class='calendar'></div>\n" ;
document.write(bf) ;
document.close();


function callMiniCalendar(obj)
{														// jucke
	var now = obj.value.split(cSplit);

	if(now[0]=="1900"){											// ³¯ÀÚ°¡ ''ÀÏ¶§ ===>1900 ====> ¿ÃÇØ·Î ¼ÂÆÃ
		var today = new Date()
		now[0]=today.getYear();
	}

	target = obj;																// Object ÀúÀå;
	var point = get_objxy(obj);

	with (minical.style) {
		left = point.x;
		top  = point.y+target.offsetHeight+1;
		visibility = 'visible';
	}

	minical.style.display = (minical.style.display == "block") ? "none" : "block";

	if (now.length == 3) {														// Á¤È®ÇÑÁö °Ë»ç
		Show_cal(now[0],now[1],now[2]);											// ³Ñ¾î¿Â °ªÀ» ³â¿ùÀÏ·Î ºÐ¸®
	} else {
		now = new Date();
		Show_cal(now.getFullYear(), now.getMonth()+1, now.getDate());			// ÇöÀç ³â/¿ù/ÀÏÀ» ¼³Á¤ÇÏ¿© ³Ñ±è.
	}
}

function doOver() {																// ¸¶¿ì½º°¡ Ä®·»´ÙÀ§¿¡ ÀÖÀ¸¸é
	var el = window.event.srcElement;
	cal_Day = el.title;

	if (cal_Day.length > 7) {													// ³¯ÀÚ °ªÀÌ ÀÖÀ¸¸é.
		el.style.borderTopColor = el.style.borderLeftColor = "buttonhighlight";
		el.style.borderRightColor = el.style.borderBottomColor = "buttonshadow";
	}
	window.clearTimeout(stime) ;													// Clear
}

function doClick() {															// ³¯ÀÚ¸¦ ¼±ÅÃÇÏ¿´À» °æ¿ì
	cal_Day = window.event.srcElement.title;
	window.event.srcElement.style.borderColor = "red";							// Å×µÎ¸® »öÀ» »¡°£»öÀ¸·Î
	if (cal_Day.length > 7) {													// ³¯ÀÚ °ªÀÌÀÖÀ¸¸é
		target.value=cal_Day													// °ª ¼³Á¤
	}
	minical.style.display='none';												// È­¸é¿¡¼­ Áö¿ò
	return ;
}

function doOut() {
	var el = window.event.fromElement;
	cal_Day = el.title;

	if (cal_Day.length > 7) {
		el.style.borderColor = "white";
	}
}

//2ÀÚ¸® ¼ýÀÚ·Î º¯°æ
function day2(d)
{
	var str = new String() ;

	if (parseInt(d) < 10) {
		str = "0" + parseInt(d) ;
	} else {
		str = "" + parseInt(d) ;
	}
	return str ;
}


function Show_cal(sYear, sMonth, sDay) {
	var Months_day = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31)
	var Weekday_name = new Array("ÀÏ", "¿ù", "È­", "¼ö", "¸ñ", "±Ý", "Åä");
	var intThisYear = new Number(), intThisMonth = new Number(), intThisDay = new Number();
	document.all.minical.innerHTML = "";
	datToday = new Date();													// ÇöÀç ³¯ÀÚ ¼³Á¤

	tDate = get_objdate(target.value);

	intThisYear = Number(sYear);
	intThisMonth = Number(sMonth);
	intThisDay = Number(sDay);

	//alert(sYear + "/" + sMonth + "/" + sDay + "++" + intThisYear + "/" + intThisMonth + "/" + intThisDay) ;

	if (intThisYear == 0) intThisYear = datToday.getFullYear();				// °ªÀÌ ¾øÀ» °æ¿ì
	if (intThisMonth == 0) intThisMonth = parseInt(datToday.getMonth())+1;	// ¿ù °ªÀº ½ÇÁ¦°ª º¸´Ù -1 ÇÑ °ªÀÌ µÅµ¹·Á Áø´Ù.
	if (intThisDay == 0) intThisDay = datToday.getDate();

	switch(intThisMonth) {
	case 1:
		intPrevYear = intThisYear -1;
		intPrevMonth = 12;
		intNextYear = intThisYear;
		intNextMonth = 2;
		break;
	case 12:
		intPrevYear = intThisYear;
		intPrevMonth = 11;
		intNextYear = intThisYear + 1;
		intNextMonth = 1;
		break;
	default:
		intPrevYear = intThisYear;
		intPrevMonth = parseInt(intThisMonth) - 1;
		intNextYear = intThisYear;
		intNextMonth = parseInt(intThisMonth) + 1;
		break;
	}

	nDate = get_objdate();	//ÇöÀç³â¿ùÀÏ

	datFirstDay = new Date(intThisYear, intThisMonth-1, 1);						// ÇöÀç ´ÞÀÇ 1ÀÏ·Î ³¯ÀÚ °´Ã¼ »ý¼º(¿ùÀº 0ºÎÅÍ 11±îÁöÀÇ Á¤¼ö(1¿ùºÎÅÍ 12¿ù))
	intFirstWeekday = datFirstDay.getDay();										// ÇöÀç ´Þ 1ÀÏÀÇ ¿äÀÏÀ» ±¸ÇÔ (0:ÀÏ¿äÀÏ, 1:¿ù¿äÀÏ)

	intSecondWeekday = intFirstWeekday;
	intThirdWeekday = intFirstWeekday;

	datThisDay = new Date(intThisYear, intThisMonth, intThisDay);				// ³Ñ¾î¿Â °ªÀÇ ³¯ÀÚ »ý¼º
	intThisWeekday = datThisDay.getDay();										// ³Ñ¾î¿Â ³¯ÀÚÀÇ ÁÖ ¿äÀÏ

	varThisWeekday = Weekday_name[intThisWeekday];								// ÇöÀç ¿äÀÏ ÀúÀå

	intPrintDay = 1																// ´ÞÀÇ ½ÃÀÛ ÀÏÀÚ
	secondPrintDay = 1
	thirdPrintDay = 1

	Stop_Flag = 0

	if ((intThisYear % 4)==0) {													// 4³â¸¶´Ù 1¹øÀÌ¸é (»ç·Î³ª´©¾î ¶³¾îÁö¸é)
		if ((intThisYear % 100) == 0) {
			if ((intThisYear % 400) == 0) {
				Months_day[2] = 29;
			}
		} else {
			Months_day[2] = 29;
		}
	}
	intLastDay = Months_day[intThisMonth];										// ¸¶Áö¸· ÀÏÀÚ ±¸ÇÔ
	Stop_flag = 0



	var bf = ""
	bf += "<table width=189 border=0 cellpadding=0 cellspacing=0 onMouseOver='javascript:doOver();' onMouseOut='javascript:doOut();'>\n" ;
	bf += "<tr>\n" ;
	bf += "	<td><img src='/fw/js/calendar/calendar_top.gif' width=189 height=15></td>\n" ;
	bf += "</tr>\n" ;
	bf += "<tr>\n" ;
	bf += "	<td align=center background='/fw/js/calendar/calendar_bg.gif'>\n" ;
	bf += "		<table border=0 cellspacing=0 cellpadding=0 style='margin:5 0 1 0;'>\n" ;
	bf += "		<tr>\n" ;
	bf += "			<td style='padding:0 5 2 0;'><a href='javascript:;' onClick='javascript:Show_cal(" + intPrevYear + "," + intPrevMonth + "," + intThisDay + ");'><img src='/fw/js/calendar/calendar_prev.gif' width=13 height=11></a></td>\n" ;
	bf += "			<td align=center><b>"+ get_Yearinfo(intThisYear,intThisMonth,intThisDay) + "." + get_Monthinfo(intThisYear,intThisMonth,intThisDay) + "</b></td>\n" ;
	bf += "			<td style='padding:0 0 2 5;'><a href='javascript:;' onClick='javascript:Show_cal(" + intNextYear + "," + intNextMonth + "," + intThisDay + ");'><img src='/fw/js/calendar/calendar_next.gif' width=13 height=11></a></td>\n" ;
	bf += "		</tr>\n" ;
	bf += "		</table>\n" ;

	bf += "		<div style='width:175px; height:16px; margin:0 0 3 0 ; background-image:url(/fw/js/calendar/calendar_week_bg.gif); background-repeat:no-repeat;'>\n" ;
	bf += "			<table width=175 border=0 cellspacing=0 cellpadding=0>\n" ;
	bf += "			<tr>\n" ;
	bf += "				<td class='week' width=25>ÀÏ</td>\n" ;
	bf += "				<td class='week' width=25>¿ù</td>\n" ;
	bf += "				<td class='week' width=25>È­</td>\n" ;
	bf += "				<td class='week' width=25>¼ö</td>\n" ;
	bf += "				<td class='week' width=25>¸ñ</td>\n" ;
	bf += "				<td class='week' width=25>±Ý</td>\n" ;
	bf += "				<td class='week' width=25>Åä</td>\n" ;
	bf += "			</tr>\n" ;
	bf += "			</table>\n" ;
	bf += "		</div>\n" ;

	bf += "		<table width=175 border=0 cellspacing=0 cellpadding=0>\n" ;
	bf += "		<col width=25 align=center>\n" ;
	bf += "		<col width=25 align=center>\n" ;
	bf += "		<col width=25 align=center>\n" ;
	bf += "		<col width=25 align=center>\n" ;
	bf += "		<col width=25 align=center>\n" ;
	bf += "		<col width=25 align=center>\n" ;
	bf += "		<col width=25 align=center>\n" ;


//	Cal_HTML = "<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 ONMOUSEOVER=doOver(); ONMOUSEOUT=doOut(); STYLE='font-size:8pt;font-family:Tahoma;'>"
//			+ "<TR ALIGN=CENTER><TD COLSPAN=7 nowrap=nowrap ALIGN=CENTER><SPAN TITLE='ÀÌÀü´Þ' STYLE=cursor:hand; onClick='Show_cal("+intPrevYear+","+intPrevMonth+","+intThisDay+");'><FONT COLOR=Navy>¢¸</FONT></SPAN> "
//			+ "<B STYLE=color:red>"+get_Yearinfo(intThisYear,intThisMonth,intThisDay)+"³â"+get_Monthinfo(intThisYear,intThisMonth,intThisDay)+"¿ù</B>"
//			+ " <SPAN TITLE='´ÙÀ½´Þ' STYLE=cursor:hand; onClick='Show_cal("+intNextYear+","+intNextMonth+","+intThisDay+");'><FONT COLOR=Navy>¢º</FONT></SPAN></TD></TR>"
//			+ "<TR ALIGN=CENTER BGCOLOR=ThreedFace STYLE='color:White;font-weight:bold;'><TD>ÀÏ</TD><TD>¿ù</TD><TD>È­</TD><TD>¼ö</TD><TD>¸ñ</TD><TD>±Ý</TD><TD>Åä</TD></TR>";

	for (intLoopWeek=1; intLoopWeek < 7; intLoopWeek++) {						// ÁÖ´ÜÀ§ ·çÇÁ ½ÃÀÛ, ÃÖ´ë 6ÁÖ
		bf += "<tr>"
		for (intLoopDay=1; intLoopDay <= 7; intLoopDay++) {						// ¿äÀÏ´ÜÀ§ ·çÇÁ ½ÃÀÛ, ÀÏ¿äÀÏ ºÎÅÍ
			if (intThirdWeekday > 0) {											// Ã¹ÁÖ ½ÃÀÛÀÏÀÌ 1º¸´Ù Å©¸é
				bf += "<td class='day' onClick=doClick();>";
				intThirdWeekday--;
			}
			else {
				if (thirdPrintDay > intLastDay) {								// ÀÔ·Â ³¯Â¦ ¿ù¸»º¸´Ù Å©´Ù¸é
					bf += "<td class='day' onClick=doClick();>";
				}
				else {														// ÀÔ·Â³¯Â¥°¡ ÇöÀç¿ù¿¡ ÇØ´ç µÇ¸é
					//¼¿ÀÇ ³¯Â¥..
					var celDate = intThisYear+cSplit+day2(intThisMonth).toString()+cSplit+day2(thirdPrintDay).toString();

					switch(intLoopDay) {
						case 1 : css = "sun" ; break ;  //ÀÏ¿äÀÏÀÌ¸é »¡°£ »öÀ¸·Î
						case 7 : css = "sat" ; break ;
						default : css = "day" ; break ;
					}

					bf += "<td class='" + css + "' onClick='javascript:doClick();' title="+celDate+" style=\"";
					if (intThisYear == tDate.y && intThisMonth == tDate.m && thirdPrintDay==intThisDay) {
						bf += "color:#000000 ; font-weight:bold ; background-color:#BBFFBB ;" ;
					}
					if (intThisYear == nDate.y && intThisMonth == nDate.m && thirdPrintDay==nDate.d) {
						bf += "color:#000000 ; text-decoration:underline ;" ;
					}

					bf += "\">"+thirdPrintDay;
				}
				thirdPrintDay++;

				if (thirdPrintDay > intLastDay) {								// ¸¸¾à ³¯Â¥ °ªÀÌ ¿ù¸» °ªº¸´Ù Å©¸é ·çÇÁ¹® Å»Ãâ
					Stop_Flag = 1;
				}
			}
			bf += "</td>";
		}
		bf += "</tr>";
		if (Stop_Flag==1) break;
	}

	bf += "		</table>\n" ;
	bf += "	</td>\n" ;
	bf += "</tr>\n" ;
	bf += "<tr>\n" ;
	bf += "	<td><img src='/fw/js/calendar/calendar_bottom.gif' width=189 height=7></td>\n" ;
	bf += "</tr>\n" ;
	bf += "</table>\n" ;


	document.all.minical.innerHTML = bf ;
}

function get_Yearinfo(year,month,day) {											// ³â Á¤º¸¸¦ ÄÞº¸ ¹Ú½º·Î Ç¥½Ã
	var min = parseInt(year) - 100;
	var max = parseInt(year) + 10;
	var i = new Number();
	var str = new String();
	/*
	str = "<select onChange='Show_cal(this.value,"+month+","+day+");' onmouseover=doOver();>";
	for (i=min; i<=max; i++) {
		if (i == parseInt(year)) {
			str += "<option value="+i+" selected onmouseover=doOver();>"+i+"</option>";
		} else {
			str += "<option value="+i+" onmouseover=doOver();>"+i+"</option>";
		}
	}
	str += "</select>";
	*/
	str = year ;
	return str;
}


function get_Monthinfo(year,month,day) {										// ¿ù Á¤º¸¸¦ ÄÞº¸ ¹Ú½º·Î Ç¥½Ã
	var i = new Number();
	var str = new String();
	/*
	str = "<select onChange='Show_cal("+year+",this.value,"+day+");' onmouseover=doOver();>";
	for (i=1; i<=12; i++) {
		if (i == parseInt(month)) {
			str += "<option value="+i+" selected onmouseover=doOver();>"+i+"</option>";
		} else {
			str += "<option value="+i+" onmouseover=doOver();>"+i+"</option>";
		}
	}
	str += "</SELECT>";
	*/
	str = (month > 9)? month : "0" + month ;
	return str ;
}
function Point(iX, iY){
	this.x	= iX;
	this.y	= iY;
}
function oDate(iY,iM,iD){
	this.y	= iY;
	this.m	= iM;
	this.d	= iD;
}
function get_objdate(sDate){
	if(typeof(sDate) == 'undefined'){
		now = new Date();
		return new oDate(now.getFullYear(), now.getMonth()+1, now.getDate());			// ÇöÀç ³â/¿ù/ÀÏÀ» ¼³Á¤ÇÏ¿© ³Ñ±è.
	} else {
		var now = sDate.split(cSplit);
		return new oDate(now[0],now[1],now[2]);
	}
}
function get_objxy(aTag){
	var oTmp = aTag;
	var pt = new Point(0,0);
	do {
		pt.x += oTmp.offsetLeft - 0 ;
		pt.y += oTmp.offsetTop;
		oTmp = oTmp.offsetParent;
	//} while(oTmp.tagName!="BODY");
	} while(!(oTmp.tagName == "BODY" || oTmp.tagName == "HTML")) ;
	return pt;
}

