var fixedX = -1          // x position (-1 if to appear below control)
var fixedY = -1          // y position (-1 if to appear below control)
var startAt = 0          // 0 - sunday ; 1 - monday
var showWeekNumber = 0   // 0 - don't show; 1 - show
var showToday = 1        // 0 - don't show; 1 - show
var imgDir = "/img/"     // directory for images ... e.g. var imgDir="/../../img/"
var imgDir = "/img/"     // directory for images ... e.g. var imgDir="/../../img/"

var gotoString = "¿À´Ã ³¯Â¥·Î ÀÌµ¿ÇÕ´Ï´Ù"
var todayString = "¿À´ÃÀº "
var weekString = "Wk"
var scrollLeftMessage = "ÀÌÀü´Þ·Î ÀÌµ¿ÇÕ´Ï´Ù. Å¬¸¯ÇÏ¼¼¿ä."
var scrollRightMessage = "´ÙÀ½´Þ·Î ÀÌµ¿ÇÕ´Ï´Ù. Å¬¸¯ÇÏ¼¼¿ä."
var selectMonthMessage = "¿øÇÏ½Ã´Â ´ÞÀ» ¼±ÅÃÇÏ¼¼¿ä."
var selectYearMessage = "¿øÇÏ½Ã´Â ³âµµ¸¦ ¼±ÅÃÇÏ¼¼¿ä."
var selectDateMessage = "¼±ÅÃÇÏ½Å ³¯Â¥´Â [date] ÀÔ´Ï´Ù." // do not replace [date], it will be replaced by date.

var crossobj, crossMonthObj, crossYearObj, monthSelected, yearSelected, dateSelected, omonthSelected, oyearSelected, odateSelected, monthConstructed, yearConstructed, intervalID1, intervalID2, timeoutID1, timeoutID2, ctlToPlaceValue, ctlNow, dateFormat, nStartingYear
var ctlToPlaceValue1, ctlToPlaceValue2, ctlToPlaceValue3
var bPageLoaded=false
var ie=document.all
var dom=document.getElementById

var ns4=document.layers
var today = new Date()
var dateNow  = today.getDate()
var monthNow = today.getMonth()
var yearNow  = today.getYear()
var imgsrc = new Array("drop2.gif","drop2.gif","cal01.gif","cal01.gif","cal02.gif","cal02.gif")
var img = new Array()

var HolidaysCounter = 0
var Holidays = new Array()
//var viewck = false;

if(viewck != true) var viewck = false;



/*
function HolidayRec (d, m, y, desc)
{
	this.d = d
	this.m = m
	this.y = y
}

function addHoliday (d, m, y, desc)
{
	Holidays[HolidaysCounter++] = new HolidayRec ( d, m, y, desc )
}


function dateCheck(date)
{

	var dlen = date.length;

	if(dlen < 8){
		alert("³¯ÀÚ¿¡ Àß¸øµÈ °ªÀÌ µé¾î°¬½À´Ï´Ù.\n yyyymmddÀÇ Çü½Ä¿¡ ¸ÂÃç¼­ ÀÔ·ÂÇÏ¼ÅÇÕ´Ï´Ù.");
		return false;
	}

	var comp="0123456789";

	for(i=0;i<dlen;i++)
	{
		if(comp.indexOf(date.substring(i,i+1))<0)
		{
			alert("¼ýÀÚ¸¸ ÀÔ·ÂÇÏ¼Å¾ß ÇÕ´Ï´Ù.\n ´Ù½Ã ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À.");
			return false;
		}
	}

	return true;
}
*/





if (dom)
{

	for (i=0;i<imgsrc.length;i++)
	{
		img[i] = new Image
		img[i].src=imgsrc[i]
	}

    /*
	document.write("<link rel='stylesheet' type='text/css' href='/css/style_auto.css'>");
	document.write("<div id='calendar' style='position:absolute;visibility:hidden;'>");
	document.write("<table width="+((showWeekNumber==1)?250:220)+" cellpadding='0' cellspacing='0' bgcolor='#ffffff'>");
	document.write("<tr bgcolor='#F7941D'><td>");
	document.write("<table width='"+((showWeekNumber==1)?248:218)+"'>");
	document.write("<tr><td style='padding:0px;font-family:arial; font-size:12px;'>");
	document.write("<font color='#000000'><span id='caption'></span></font></td><td align=right>");
	document.write("<a href='javascript:hideCalendar()'>X</a></td></tr></table></td></tr>");
	document.write("<tr><td  bgcolor=#E8E8E8 align=center><span id='content'></span></td></tr>");

	if (showToday==1)
	{
		document.write("<tr bgcolor=#FFF799><td style='padding:10 5 5 5;border-style:solid; border-width:1 0 0 0;' align=center>");
		document.write("<span id='lblToday'></span></td></tr>")
	}

	document.write("</table></div><div id='selectMonth' style='position:absolute;visibility:hidden;'></div>");
	document.write("<div id='selectYear' style='position:absolute;visibility:hidden;'></div>");
	*/

	document.write("<link rel='stylesheet' type='text/css' href='/css/style_auto.css'>");
	if(viewck == false) document.write("<div id='calendar' style='position:absolute;visibility:hidden;'>");
	else				document.write("<div id='calendar' style='position:relative;visibility:hidden;'>");
	//document.write("<div id='calendar' style='position:absolute;visibility:hidden;'>");
	document.write("<table width="+((showWeekNumber==1)?280:250)+" cellpadding='0' cellspacing='0' width='250' background='/box/default/calendar_bg.gif'>");
	document.write("<td><!--<img src='/box/default/calendar_top.gif' width='250' height='28' border='0'>--></td>");
	document.write("<tr><td>");
	document.write("<table cellpadding='0' cellspacing='0' border=0 width='100%' height='100%' bordercolordark='black' bordercolorlight='black'>");
	document.write("<tr>");
	document.write("<td>");
	document.write("<table align='center' cellpadding='0' cellspacing='0' border=0 width='85%' height='100%'>");
	document.write("<tr>");
	document.write("<td  class='cal_c' align='center'><span id='caption' align='left'></span></td>");
	document.write("</tr>");
	document.write("<tr><td align=center valign=bottom>");

	if (showToday==1)
	{
		document.write("<span id='lblToday'></span>")
	}
	document.write("</table>");
	document.write("</td>");
	document.write("<td width='180' valign=top>");
	document.write("<span id='content'></span>");
	document.write("</td>");
	document.write("</tr>");
	document.write("</table>");
	document.write("</td>");
	document.write("</tr>");
	document.write("<tr><td><img src='/box/default/calendar_dn.gif' width='250' height='5' border='0'></td> </tr>");
	document.write("</table>");
	document.write("</div><div id='selectMonth' style='position:absolute;visibility:hidden;'></div>");
	document.write("<div id='selectYear' style='position:absolute;visibility:hidden;'></div>");

}



var monthName = new Array("1¿ù","2¿ù","3¿ù","4¿ù","5¿ù","6¿ù","7¿ù","8¿ù","9¿ù","10¿ù","11¿ù","12¿ù") //var monthName = new Array("January","February","March","April","May","June","July","August","September","October","November","December")
if (startAt==0){	
	dayName = new Array ("ÀÏ","¿ù","È­","¼ö","¸ñ","±Ý","Åä")  //dayName = new Array ("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
}
else{	
	dayName = new Array ("¿ù","È­","¼ö","¸ñ","±Ý","Åä","ÀÏ")  //dayName = new Array ("Mon","Tue","Wed","Thu","Fri","Sat","Sun")
}

var styleAnchor="text-decoration:none;color:black;"
var styleLightBorder="border-style:solid;border-width:1px;border-color:#2F2F2F;"




function swapImage(srcImg, destImg)
{
	if (ie) { document.getElementById(srcImg).setAttribute("src",imgDir + destImg) }
}


//ÃÊ±â¼³Á¤--------------------------------------------------------------------------------------------
function init() 
{

	if (!ns4)
	{
		if (!ie) { yearNow += 1900 }


		crossobj = (dom)?document.getElementById("calendar").style : ie? document.all.calendar : document.calendar
		hideCalendar()

		crossMonthObj=(dom)?document.getElementById("selectMonth").style : ie? document.all.selectMonth : document.selectMonth

		crossYearObj=(dom)?document.getElementById("selectYear").style : ie? document.all.selectYear : document.selectYear

		monthConstructed=false;
		yearConstructed=false;

		if (showToday==1)
		{

			//document.getElementById("lblToday").innerHTML = todayString + " <a onmousemove='window.status=\""+gotoString+"\"' onmouseout='window.status=\"\"' title='"+gotoString+"' style='"+styleAnchor+"' href='javascript:monthSelected=monthNow;yearSelected=yearNow;constructCalendar();'>" + yearNow + "³â " + monthName[monthNow].substring(0,3) + dateNow + "ÀÏ " + dayName[(today.getDay()-startAt==-1)?6:(today.getDay()-startAt)] + "¿äÀÏ ÀÔ´Ï´Ù." + "</a>"
			document.getElementById("lblToday").innerHTML = "<table cellpadding=0 cellspacing=0 border=0><tr><td align='center' class='cal_b'>" + (monthNow+1) + "</td></tr><tr><td align='center' height='25' class='cal_c'>(" + (monthNow+1) +"."+ dateNow + ")</td></tr></table>";

		}

		//sHTML1="<span id='spanLeft' style='border-style:solid;border-width:0;border-color:#3366FF;cursor:pointer' onmouseover='swapImage(\"changeLeft\",\"cal01.gif\");this.style.borderColor=\"#737373\";window.status=\""+scrollLeftMessage+"\"' onclick='javascript:decMonth()' onmouseout='clearInterval(intervalID1);swapImage(\"changeLeft\",\"cal01.gif\");this.style.borderColor=\"#3366FF\";window.status=\"\"' onmousedown='clearTimeout(timeoutID1);timeoutID1=setTimeout(\"StartDecMonth()\",500)' onmouseup='clearTimeout(timeoutID1);clearInterval(intervalID1)'><IMG id='changeLeft' SRC='"+imgDir+"cal01.gif'></span>"
		//sHTML1+="<span id='spanRight' style='border-style:solid;border-width:0;border-color:#3366FF;cursor:pointer' onmouseover='swapImage(\"changeRight\",\"cal02.gif\");this.style.borderColor=\"#737373\";window.status=\""+scrollRightMessage+"\"' onmouseout='clearInterval(intervalID1);swapImage(\"changeRight\",\"cal02.gif\");this.style.borderColor=\"#3366FF\";window.status=\"\"' onclick='incMonth()' onmousedown='clearTimeout(timeoutID1);timeoutID1=setTimeout(\"StartIncMonth()\",500)' onmouseup='clearTimeout(timeoutID1);clearInterval(intervalID1)'><IMG id='changeRight' SRC='"+imgDir+"cal02.gif'></span>"
		//sHTML1+="<span id='spanMonth' style='border-style:solid;border-width:1;border-color:#737373;background-color:#FFFFFF;cursor:pointer' onmouseover='swapImage(\"changeMonth\",\"drop2.gif\");this.style.borderColor=\"#737373\";window.status=\""+selectMonthMessage+"\"' onmouseout='swapImage(\"changeMonth\",\"drop2.gif\");this.style.borderColor=\"#737373\";window.status=\"\"' onclick='popUpMonth()'></span>&nbsp;"
		//sHTML1+="<span id='spanYear' style='border-style:solid;border-width:1;border-color:#737373;background-color:#FFFFFF;cursor:pointer' onmouseover='swapImage(\"changeYear\",\"drop2.gif\");this.style.borderColor=\"#737373\";window.status=\""+selectYearMessage+"\"' onmouseout='swapImage(\"changeYear\",\"drop2.gif\");this.style.borderColor=\"#737373\";window.status=\"\"' onclick='popUpYear()'></span>"
		sHTML1 = "<span id='spanYear'></span><br>";	//onclick='popUpYear()'
		sHTML1 +=  "<span id='spanLeft' onmouseover='this.style.borderColor=\"#737373\";window.status=\""+scrollLeftMessage+"\"' onclick='javascript:decMonth()' onmouseout='clearInterval(intervalID1);this.style.borderColor=\"#3366FF\";window.status=\"\"' onmousedown='clearTimeout(timeoutID1);timeoutID1=setTimeout(\"StartDecMonth()\",500)' onmouseup='clearTimeout(timeoutID1);clearInterval(intervalID1)'><img align='absmiddle' src='/box/default/calendar_arrow01.gif' style='cursor:hand' width='3' height='6' border='0' vspace='5' hspace='4'></span>";		
		sHTML1 += "<span id='spanMonth'></span>"; //onclick='popUpMonth()'		
		sHTML1 += "<span id='spanRight' onmouseover='this.style.borderColor=\"#737373\";window.status=\""+scrollRightMessage+"\"' onmouseout='clearInterval(intervalID1);this.style.borderColor=\"#3366FF\";window.status=\"\"' onclick='incMonth()' onmousedown='clearTimeout(timeoutID1);timeoutID1=setTimeout(\"StartIncMonth()\",500)' onmouseup='clearTimeout(timeoutID1);clearInterval(intervalID1)'><img align='absmiddle' src='/box/default/calendar_arrow02.gif' width='3' style='cursor:hand' height='6' border='0' vspace='4' hspace='5'></span>";

		document.getElementById("caption").innerHTML  = sHTML1

		bPageLoaded=true
	}

	if(viewck == true){
		//´Þ·Â Ãâ·Â À§Ä¡Àâ±â
		//crossobj.position = "relative"
		crossobj.left = 0
		crossobj.top = 0

		crossMonthObj.visibility = (dom||ie)? "visible" : "show"
		crossYearObj.visibility = (dom||ie)? "visible" : "show"
		crossobj.visibility = (dom || ie) ? "visible" : "show"

		

		constructCalendar (1, monthSelected, yearSelected);
	}



}


//*´Þ·Â ¼û±â±â--------------------------------------------------------
function hideCalendar() 
{
	crossobj.visibility="hidden"
	if (crossMonthObj != null){crossMonthObj.visibility="hidden"}
	if (crossYearObj != null) {crossYearObj.visibility="hidden"}
}


//*ÇÑÀÚ¸®¼ýÀÚ ¾Õ¿¡ '0'ºÙ¿©ÁÖ±â----------------------------------------
function padZero(num) 
{
	return (num < 10)? '0' + num : num ;
}


//*¼±ÅÃ³¯Â¥ Çü½Ä¿¡ ¸Â°Ô ¸®ÅÏ------------------------------------------
function constructDate(d,m,y)
{
	sTmp = dateFormat	
	sTmp = sTmp.replace ("dd","<e>")
	sTmp = sTmp.replace ("d","<d>")
	sTmp = sTmp.replace ("<e>",padZero(d))
	sTmp = sTmp.replace ("<d>",d)
	sTmp = sTmp.replace ("mmm","<o>")
	sTmp = sTmp.replace ("mm","<n>")
	sTmp = sTmp.replace ("m","<m>")
	sTmp = sTmp.replace ("<o>",monthName[m])
	sTmp = sTmp.replace ("<n>",padZero(m+1))
	sTmp = sTmp.replace ("<m>",m+1)
	return sTmp.replace ("yyyy",y)
}



function constructDate2(d,m,y)
{
	sTmp = y + "-" + padZero(m+1) + "-" + padZero(d)
	return sTmp
}



//*¼±ÅÃ³¯Â¥ ÅØ½ºÆ®¹Ú½º¿¡ »Ñ·ÁÁÖ±â---------------------------------------
function closeCalendar() 
{
	var sTmp

	hideCalendar();


	if(mode == 1){
		ctlToPlaceValue.value = constructDate(dateSelected,monthSelected,yearSelected)
	}else {
		ctlToPlaceValue1.value = yearSelected
		ctlToPlaceValue2.value = padZero(monthSelected+1)
		ctlToPlaceValue3.value = padZero(dateSelected)
	}


}


/* Month Pulldown ************************************************************************************/
function StartDecMonth()
{
	intervalID1=setInterval("decMonth()",80) //1000:1ÃÊ 0.08ÃÊÈÄ  decMonth Àç±ÍÈ£Ãâ
}

function StartIncMonth()
{
	intervalID1=setInterval("incMonth()",80)
}

function decMonth () 
{
	monthSelected--
	if (monthSelected<0) {
		monthSelected=11
		yearSelected--
	}
	constructCalendar()
}


function incMonth () 
{
	monthSelected++
	if (monthSelected>11) {
		monthSelected=0
		yearSelected++
	}
	constructCalendar()
}



//* ´Þ¸®½ºÆ® html --------------------------------------------------
function constructMonth() 
{
	popDownYear()
	if (!monthConstructed) {
		sHTML = ""
		for (i=0; i<12; i++) {
			sName = monthName[i];
			if (i==monthSelected){
				sName = "<B>" + sName + "</B>"
			}
			sHTML += "<tr><td id='m" + i + "' onmouseover='this.style.backgroundColor=\"#FFCC99\"' onmouseout='this.style.backgroundColor=\"\"' style='cursor:pointer' onclick='monthConstructed=false;monthSelected=" + i + ";constructCalendar();popDownMonth();event.cancelBubble=true'>&nbsp;" + sName + "&nbsp;</td></tr>"
		}

		document.getElementById("selectMonth").innerHTML = "<table width=50 style='font-family:arial; font-size:12px; border-width:1; border-style:solid; border-color:#2F2F2F;' bgcolor='#FFFFDD' cellspacing=0 onmouseover='clearTimeout(timeoutID1)' onmouseout='clearTimeout(timeoutID1);timeoutID1=setTimeout(\"popDownMonth()\",100);event.cancelBubble=true'>" + sHTML + "</table>"

		monthConstructed=true
	}
}

//* 1¿ù~12¿ù ´Þ ¸®½ºÆ® Ãâ·Â----------------------------------------
function popUpMonth() 
{
	constructMonth()
	crossMonthObj.visibility = (dom||ie)? "visible" : "show"
	crossMonthObj.left = parseInt(crossobj.left) + 50
	crossMonthObj.top = parseInt(crossobj.top) + 26
}

//* ´Þ¸®½ºÆ® ¼û±â±â-----------------------------------------------
function popDownMonth() 
{
	crossMonthObj.visibility= "hidden"
}

 /* Year Pulldown ************************************************************************************/

function incYear() 
{
	for (i=0; i<7; i++){
		newYear = (i+nStartingYear)+1
		if (newYear==yearSelected){ 
			txtYear = "&nbsp;<B>" + newYear + "</B>&nbsp;" 
		}
		else{ 
			txtYear = "&nbsp;" + newYear + "&nbsp;" 
		}
		document.getElementById("y"+i).innerHTML = txtYear
	}
	nStartingYear ++;
}

function decYear() 
{
	for (i=0; i<7; i++){
		newYear = (i+nStartingYear)-1
		if (newYear==yearSelected){ 
			txtYear = "&nbsp;<B>" + newYear + "</B>&nbsp;" 
		}
		else{ 
			txtYear = "&nbsp;" + newYear + "&nbsp;" 
		}
		document.getElementById("y"+i).innerHTML = txtYear
	}
	nStartingYear --;
}

function selectYear(nYear) 
{
	yearSelected=parseInt(nYear+nStartingYear);
	yearConstructed=false;
	constructCalendar();
	popDownYear();
}

//*³âµµ ¸®½ºÆ® html -------------------------------------------------------------------------
function constructYear() 
{
	popDownMonth()
	sHTML = ""
	if (!yearConstructed){

		sHTML = "<tr><td align='center' onmouseover='this.style.backgroundColor=\"#FFCC99\"' onmouseout='clearInterval(intervalID1);this.style.backgroundColor=\"\"' style='cursor:pointer' onmousedown='clearInterval(intervalID1);intervalID1=setInterval(\"decYear()\",30)' onmouseup='clearInterval(intervalID1)'>-</td></tr>"

		j = 0
		nStartingYear = yearSelected-3
		for (i=(yearSelected-3); i<=(yearSelected+3); i++) {
			sName = i;
			if (i==yearSelected){
				sName = "<B>" + sName + "</B>"
			}

			sHTML += "<tr><td id='y" + j + "' onmouseover='this.style.backgroundColor=\"#FFCC99\"' onmouseout='this.style.backgroundColor=\"\"' style='cursor:pointer' onclick='selectYear("+j+");event.cancelBubble=true'>&nbsp;" + sName + "&nbsp;</td></tr>"
			j ++;
		}

		sHTML += "<tr><td align='center' onmouseover='this.style.backgroundColor=\"#FFCC99\"' onmouseout='clearInterval(intervalID2);this.style.backgroundColor=\"\"' style='cursor:pointer' onmousedown='clearInterval(intervalID2);intervalID2=setInterval(\"incYear()\",30)' onmouseup='clearInterval(intervalID2)'>+</td></tr>"

		document.getElementById("selectYear").innerHTML = "<table width=51 style='font-family:arial; font-size:12px; border-width:1; border-style:solid; border-color:#2F2F2F;' bgcolor='#FFFFDD' onmouseover='clearTimeout(timeoutID2)' onmouseout='clearTimeout(timeoutID2);timeoutID2=setTimeout(\"popDownYear()\",100)' cellspacing=0>" + sHTML + "</table>"

		yearConstructed = true
	}
}



//³âµµ ¸®½ºÆ® Ãâ·Â -----------------------------------------------------------------------
function popUpYear() 
{
	var leftOffset

	constructYear()
	crossYearObj.visibility = (dom||ie)? "visible" : "show"
	leftOffset = parseInt(crossobj.left) + document.getElementById("spanYear").offsetLeft
	if (ie)
	{
		leftOffset += 6
	}
	crossYearObj.left = leftOffset
	crossYearObj.top = parseInt(crossobj.top) + 26
}




//³âµµ ¸®½ºÆ® ¼û±â±â------------------------------------------------------------------------
function popDownYear() 
{
	clearInterval(intervalID1)
	clearTimeout(timeoutID1)
	clearInterval(intervalID2)
	clearTimeout(timeoutID2)
	crossYearObj.visibility= "hidden"
}





/* calendar **************************************************************************/
function WeekNbr(n) 
{
	var P3D=259200000, P7D=604800000, y=n.getYear(), y=(y<1000?1900+y:y);
	var s=Math.floor((Date.UTC(y,n.getMonth(),n.getDate())+P3D)/P7D);
	tmp=new Date(s*P7D); j=tmp.getYear(); j=(j<1000?1900+j:j);
	return 1+s-Math.floor((Date.UTC(j,0,4)+P3D)/P7D)
}


function constructCalendar () 
{

	var dateMessage
	var startDate = new Date (yearSelected,monthSelected,1)
	var endDate = new Date (yearSelected,monthSelected+1,1);
	endDate = new Date (endDate - (24*60*60*1000));
	numDaysInMonth = endDate.getDate() //¸¶Áö¸· ³¯Â¥

	datePointer = 0
	dayPointer = startDate.getDay() - startAt // startDate.getDay() : ½ÃÀÛ¿äÀÏ (¿ù:0,È­:1....)

	if (dayPointer<0)
	{
		dayPointer = 6
	}


    //***¿äÀÏÃâ·Â--------------------------------------
	sHTML = "<table cellpadding='0' cellspacing='0' width='173' bgcolor='white'>";
	sHTML += "<tr><td><img src='/box/default/calendar_intop.gif' width='173' height='6' border='0'></td></tr><tr><td>";                               
	sHTML += "<table align='center' cellspacing='1' width='160' bordercolordark='white' bordercolorlight='white' cellpadding='0'>";

	if (showWeekNumber==1)
	{
		sHTML += "<td width=27><b>" + weekString + "</b></td><td width=1 rowspan=7 bgcolor='#F26522' style='padding:0px'><img src='"+imgDir+"divider.gif' width=1></td>"
	}

    /*
	for (i=0; i<7; i++) {
		sHTML += "<td width='27' align='right'><B>"+ dayName[i]+"</B></td>"
	}//i
   */
	sHTML +="<tr>";
	sHTML += "<td  width='23'><img src='/box/default/calendar_s1.gif' width='22' height='13' border='0'></td>";
	sHTML += "<td  width='23'><img src='/box/default/calendar_m.gif' width='22' height='13' border='0'></td>";
	sHTML += "<td  width='23'><img src='/box/default/calendar_t1.gif' width='22' height='13' border='0'></td>";
	sHTML += "<td  width='23'><img src='/box/default/calendar_w.gif' width='22' height='13' border='0'></td>";
	sHTML += "<td  width='23'><img src='/box/default/calendar_t2.gif' width='22' height='13' border='0'></td>";
	sHTML += "<td  width='23'><img src='/box/default/calendar_f.gif' width='22' height='13' border='0'></td>";
	sHTML += "<td  width='22'><img src='/box/default/calendar_s2.gif' width='22' height='13' border='0'></td>";
	sHTML +="</tr><tr>"



    //***³¯Â¥Ãâ·Â--------------------------------------
	if (showWeekNumber==1)
	{
		sHTML += "<td align=right>" + WeekNbr(startDate) + "&nbsp;</td>"
	}


	for ( var i=1; i<=dayPointer;i++ )
	{
		sHTML += "<td  bgcolor='#E8E8E8'>&nbsp;</td>"
	}


	
	Ttr = Math.ceil((numDaysInMonth + startDate.getDay())/7);


	trcnt=1;
	for ( datePointer=1; datePointer<=numDaysInMonth; datePointer++ )
	{
		dayPointer++;
		sHTML += "<td bgcolor='#E8E8E8' align='center'>"
		sStyle=styleAnchor

        
		if ((datePointer==odateSelected) && (monthSelected==omonthSelected) && (yearSelected==oyearSelected)){ 
			sStyle+=styleLightBorder 
		}

		sHint = ""
		for (k=0;k<HolidaysCounter;k++)
		{
			
			if ((parseInt(Holidays[k].d)==datePointer)&&(parseInt(Holidays[k].m)==(monthSelected+1)))
			{
				if ((parseInt(Holidays[k].y)==0)||((parseInt(Holidays[k].y)==yearSelected)&&(parseInt(Holidays[k].y)!=0))){
					sStyle+="background-color:#FFDDDD;"
					sHint+=sHint==""?Holidays[k].desc:"\n"+Holidays[k].desc
				}
			}
		}//k

		var regexp= /\"/g
		sHint=sHint.replace(regexp,"&quot;")

		if(mode==1) dateMessage = "onmousemove='window.status=\""+selectDateMessage.replace("[date]",constructDate(datePointer,monthSelected,yearSelected))+"\"' onmouseout='window.status=\"\"' "
		else        dateMessage = "onmousemove='window.status=\""+selectDateMessage.replace("[date]",constructDate2(datePointer,monthSelected,yearSelected))+"\"' onmouseout='window.status=\"\"' "

		if(viewck == false)
		{
			if ((datePointer==dateNow)&&(monthSelected==monthNow)&&(yearSelected==yearNow)){ //¿À´Ã³¯Â¥

				sHTML += "<b><a "+dateMessage+" title=\"" + sHint + "\" style='"+sStyle+"' href='javascript:dateSelected="+datePointer+";closeCalendar();'><font color=#ff0000>" + datePointer + "</font></a></b>"
			}
			else if (dayPointer % 7 == (startAt * -1)+1){ //ÀÏ¿äÀÏ³¯Â¥		
				sHTML += "<a "+dateMessage+" title=\"" + sHint + "\" style='"+sStyle+"' href='javascript:dateSelected="+datePointer + ";closeCalendar();'><font color=#B92630><b>" + datePointer + "</b></font></a>" 
			}
			else{ //ÀÏ¹Ý³¯Â¥
				sHTML += "<a "+dateMessage+" title=\"" + sHint + "\" style='"+sStyle+"' href='javascript:dateSelected="+datePointer + ";closeCalendar();'>" + datePointer + "</a>" 
			}
		}else{
			if ((datePointer==dateNow)&&(monthSelected==monthNow)&&(yearSelected==yearNow)){ //¿À´Ã³¯Â¥

				sHTML += "<b><font color=#ff0000>" + datePointer + "</font></b>"
			}
			else if (dayPointer % 7 == (startAt * -1)+1){ //ÀÏ¿äÀÏ³¯Â¥		
				sHTML += "<font color=#B92630><b>" + datePointer + "</b></font>" 
			}
			else{ //ÀÏ¹Ý³¯Â¥
				sHTML +=  datePointer  
			}
		}

		sHTML += ""




		//³²Àº <TD>³Ö±â-----------------------------------------------------------
		if ((dayPointer+startAt) % 7 == startAt){trcnt++;}
        
		if(trcnt == Ttr && datePointer == numDaysInMonth)
		{	

			for(td = 0; td < 7-(dayPointer%7); td++)
			{
				sHTML += "<td bgcolor='#E8E8E8'>";
			}
					
		}
        //<tr>³Ö±â.----------------------------------------------------------------

		if ((dayPointer+startAt) % 7 == startAt){ 			
	       		
			sHTML += "</tr><tr>" 			
			if ((showWeekNumber==1)&&(datePointer<numDaysInMonth))
			{
				sHTML += "<td align=right>" + (WeekNbr(new Date(yearSelected,monthSelected,datePointer+1))) + "&nbsp;</td>"
			}
		}
	}//datePointer
	sHTML += "</table></td></tr>";
	sHTML += "<tr><td><img src='/box/default/calendar_indn.gif' width='173' height='6' border='0'></td></tr></table>";
	


	document.getElementById("content").innerHTML   = sHTML
	//document.getElementById("spanMonth").innerHTML = "&nbsp;" + monthName[monthSelected] + "&nbsp;<IMG id='changeMonth' SRC='"+imgDir+"drop2.gif'>"
	//document.getElementById("spanYear").innerHTML = "&nbsp;" + yearSelected + "&nbsp;<IMG id='changeYear' SRC='"+imgDir+"drop2.gif'>"
	document.getElementById("spanMonth").innerHTML = "&nbsp;" + monthName[monthSelected]
	document.getElementById("spanYear").innerHTML = "&nbsp;" + yearSelected+"³â"
}



var  mode
//¹öÆ° Å¬¸®½º È£Ãâ *******************************************************************
function popUpCalendar(ctl, ctl2, format) 
{	

	mode = 1;
	var leftpos=0
	var toppos=0

	if (bPageLoaded)
	{
        //***----------------------------------
		if (crossobj.visibility == "hidden" ) {
			ctlToPlaceValue = ctl2
			dateFormat=format;

			formatChar = " "
			aFormat = dateFormat.split(formatChar)		

			if (aFormat.length<3){
				 formatChar = "/"
				 aFormat = dateFormat.split(formatChar)
					
				 if (aFormat.length<3){
					  formatChar = "."
					  aFormat = dateFormat.split(formatChar)	

					  if (aFormat.length<3){    //<===============ÀÌºÎºÐ ½ÇÇà
						   formatChar = "-"
						   aFormat = dateFormat.split(formatChar)							   

						   if (aFormat.length<3){
							   // invalid date format
							   formatChar=""

						   }
					  }
				 }
			}

			if(aFormat[0] != "yyyy") aFormat[0] = aFormat[0].substr(0,4);
			if(aFormat[1] != "mm")   aFormat[1] = aFormat[1].substr(0,2);
			if(aFormat[2] != "dd")   aFormat[2] = aFormat[2].substr(0,2);


			//½ÇÇà°á°ú
            //aFromat[0]=yyyy,  aFromat[0]=mm, aFromat[0]=dd,
			//formatChar = "-"
            //***----------------------------------------------------------------------------------------
			tokensChanged = 0
			if ( formatChar != "" )
			{

				// use user's date
				aData = ctl2.value.split(formatChar) //aData[0] = 2006, aData[1] =04, aData[2] =06

				for (i=0;i<3;i++)
				{
					if ((aFormat[i]=="d") || (aFormat[i]=="dd")){
						dateSelected = parseInt(aData[i], 10)
						tokensChanged ++
					}
					else if ((aFormat[i]=="m") || (aFormat[i]=="mm")){
						monthSelected = parseInt(aData[i], 10) - 1
						tokensChanged ++
					}
					else if (aFormat[i]=="yyyy"){
						yearSelected = parseInt(aData[i], 10)
						tokensChanged ++
					}
					else if (aFormat[i]=="mmm"){
						for (j=0; j<12; j++)
						{
							if (aData[i]==monthName[j]){
								monthSelected=j
								tokensChanged ++
							}
						}
					}
				}//i
			}

            //½ÇÇà°á°ú
			//tokensChanged = 3;			
			//texDatel¿¡ ³¯Â¥°¡ ÀÖÀ¸¸é yearSelected,monthSelected,dateSelectd¿¡ °¢°¢ textDate1³¯Â¥°¡ ±¸ºÐµÇ¾î °ªÀÌ µé¾î°¡ ÀÖ´Ù.


			//***----------------------------------------------------------------------------------------
			//texDate1¿¡ ³¯Â¥°¡ ¾øÀ¸¸é ¿À´Ã³¯Â¥ Ãâ·Â(Ã³À½ÀÌ¸é)
			if ((tokensChanged!=3)||isNaN(dateSelected)||isNaN(monthSelected)||isNaN(yearSelected)) //¿À´Ã³¯Â¥ Ãâ·Â
			{
				dateSelected = dateNow
				monthSelected = monthNow
				yearSelected = yearNow
			}
			//***----------------------------------------------------------------------------------------
	
			odateSelected=dateSelected
			omonthSelected=monthSelected
			oyearSelected=yearSelected
				

			aTag = ctl
			do {				
				aTag = aTag.offsetParent;
				leftpos += aTag.offsetLeft;
				toppos += aTag.offsetTop;				
			} while(aTag.tagName!="BODY");


			//***----------------------------------------------------------------------------------------
			//´Þ·Â Ãâ·Â À§Ä¡Àâ±â
			crossobj.left = fixedX==-1 ? ctl.offsetLeft + leftpos : fixedX
			crossobj.top = fixedY==-1 ? ctl.offsetTop + toppos + ctl.offsetHeight + 2 : fixedY
			constructCalendar (1, monthSelected, yearSelected);
			crossobj.visibility = (dom || ie) ? "visible" : "show"

	   }
	   else
	   {
			hideCalendar()
			if (ctlNow!=ctl) {popUpCalendar(ctl, ctl2, format)}
	   }

	   ctlNow = ctl

  }

}



function popUpCalendar2(ctl, ctl2, ctl3) 
{	
	mode=2;


	var leftpos=0
	var toppos=0

	if (bPageLoaded)
	{
        //***----------------------------------
		if (crossobj.visibility == "hidden" ) {
			ctlToPlaceValue1 = ctl
			ctlToPlaceValue2 = ctl2
			ctlToPlaceValue3 = ctl3

			yearSelected = parseInt(ctlToPlaceValue1.value,10)
			monthSelected = parseInt(ctlToPlaceValue2.value,10) - 1
			dateSelected = parseInt(ctlToPlaceValue3.value,10)

			//***----------------------------------------------------------------------------------------
			//texDate1¿¡ ³¯Â¥°¡ ¾øÀ¸¸é ¿À´Ã³¯Â¥ Ãâ·Â(Ã³À½ÀÌ¸é)
			if (isNaN(dateSelected)||isNaN(monthSelected)||isNaN(yearSelected)) //¿À´Ã³¯Â¥ Ãâ·Â
			{
				dateSelected = dateNow
				monthSelected = monthNow
				yearSelected = yearNow

			}
			//***----------------------------------------------------------------------------------------
	
			odateSelected=dateSelected
			omonthSelected=monthSelected
			oyearSelected=yearSelected


			aTag = ctl
			do {				
				aTag = aTag.offsetParent;
				leftpos += aTag.offsetLeft;
				toppos += aTag.offsetTop;				
			} while(aTag.tagName!="BODY");


			//***----------------------------------------------------------------------------------------
			//´Þ·Â Ãâ·Â À§Ä¡Àâ±â
			crossobj.left = fixedX==-1 ? ctl.offsetLeft + leftpos : fixedX
			crossobj.top = fixedY==-1 ? ctl.offsetTop + toppos + ctl.offsetHeight + 2 : fixedY
			constructCalendar (1, monthSelected, yearSelected);
			crossobj.visibility = (dom || ie) ? "visible" : "show"

          
			
	   }
	   else
	   {
			hideCalendar()
			if (ctlNow!=ctl) {popUpCalendar2(ctl, ctl2, ctl3)}
	   }

	   ctlNow = ctl

  }


}




 function popUpCalendar3(){	

	if (!ie) { yearNow += 1900 }

	dateSelected = dateNow
	monthSelected = monthNow
	yearSelected = yearNow



	odateSelected=dateSelected
	omonthSelected=monthSelected
	oyearSelected=yearSelected

	//ctlNow = yearSelected

	viewck = true;


}




 window.onload=init   


 
 

