	var yearSelect;
	var monthSelect;

	var todayDate;

	if (typeof(headerfooter_time_year) != "undefined")
	{
		/* ¿À´ÃÀÇ ³¯Â¥¸¦ ¼­¹ö ³¯Â¥·Î ¼³Á¤ */
		todayDate = new Date(
						headerfooter_time_year, headerfooter_time_month - 1,
						headerfooter_time_day, headerfooter_time_hour,
						headerfooter_time_minute, headerfooter_time_second);
	}
	else
		todayDate = new Date();

	function memorialDay(name, month, day, solarLunar, holiday, type)
	{
		this.name = name;
		this.month = month;
		this.day = day;
		this.solarLunar = solarLunar;
		this.holiday = holiday;	/* true : »¡°£³¯ false : ¾È»¡°£³¯ */
		this.type = type;	/* true : real time setting */
		this.techneer = true;
	}

	var memorialDays = Array (
		new memorialDay("½ÅÁ¤", 1, 1, 1, true),
		new memorialDay("", 12, 0, 2, true, true),	/* ½Ç½Ã°£À¸·Î Á¤ÇØÁü */
		new memorialDay("¼³³¯", 1, 1, 2, true),
		new memorialDay("", 1, 2, 2, true),
		new memorialDay("»ïÀÏÀý", 3, 1, 1, true),
		new memorialDay("½Ä¸ñÀÏ", 4, 5, 1, true),
		new memorialDay("¼®°¡Åº½ÅÀÏ", 4, 8, 2, true),
		new memorialDay("¾î¸°ÀÌ³¯", 5, 5, 1, true),
		new memorialDay("ÇöÃæÀÏ", 6, 6, 1, true),
		new memorialDay("Á¦ÇåÀý", 7, 17, 1, true),
		new memorialDay("±¤º¹Àý", 8, 15, 1, true),
		new memorialDay("", 8, 14, 2, true),
		new memorialDay("Ãß¼®", 8, 15, 2, true),
		new memorialDay("", 8, 16, 2, true),
		new memorialDay("°³ÃµÀý", 10, 3, 1, true),
		new memorialDay("¼ºÅºÀý", 12, 25, 1, true),

		new memorialDay("Á¤¿ù´ëº¸¸§", 1, 15, 2, false),
		new memorialDay("´Ü¿À", 5, 5, 2, false),
		new memorialDay("±¹±ºÀÇ³¯", 10, 1, 1, false),
		new memorialDay("ÇÑ±Û³¯", 10, 9, 1, false),
		new memorialDay("625ÀüÀïÀÏ", 6, 25, 1, false),
		new memorialDay("»ïÁù³¯", 3, 3, 2, false),
		new memorialDay("¹°ÀÇ³¯", 3, 22, 1, false),
		new memorialDay("¸¸¿ìÀý", 4, 1, 1, false),
		new memorialDay("Àå¾ÖÀÎÀÇ³¯", 4, 20, 1, false),
		new memorialDay("°úÇÐÀÇ³¯", 4, 21, 1 , false),
		new memorialDay("Ãæ¹«°øÅº½ÅÀÏ", 4, 28, 1, false),
		new memorialDay("±Ù·ÎÀÚÀÇ³¯¡¤¹ýÀÇ³¯", 5, 1, 1, false),
		new memorialDay("¾î¹öÀÌ³¯", 5, 8, 1, false),
		new memorialDay("½º½ÂÀÇ³¯", 5, 15, 1, false),
		new memorialDay("¹ß¸íÀÇ³¯", 5, 19, 1, false),
		new memorialDay("¹Ù´ÙÀÇ³¯", 5, 31, 1, false),
		new memorialDay("È¯°æÀÇ³¯", 6, 5, 1, false),
		new memorialDay("À¯µÎ", 6, 15, 2, false),
		new memorialDay("Ä¥¿ùÄ¥¼®", 7, 7, 2, false),
		new memorialDay("Áß¾çÀý", 9, 9, 2, false),
		new memorialDay("Ã¶µµÀÇ³¯", 9, 18, 1, false),
		new memorialDay("¼Ò¹æÀÇ³¯", 11, 9, 1, false)
	);
		

	function myDate(year, month, day, leapMonth)
	{
		this.year = year;
		this.month = month;
		this.day = day;
		this.leapMonth = leapMonth;
	}

	// À½·Â µ¥ÀÌÅÍ (Æò´Þ - ÀÛÀº´Þ :1,  Å«´Þ:2 )
	// (À±´ÞÀÌ ÀÖ´Â ´Þ - Æò´ÞÀÌ ÀÛ°í À±´Þµµ ÀÛÀ¸¸é :3 , Æò´ÞÀÌ ÀÛ°í À±´ÞÀÌ Å©¸é : 4)
	// (À±´ÞÀÌ ÀÖ´Â ´Þ - Æò´ÞÀÌ Å©°í À±´ÞÀÌ ÀÛÀ¸¸é :5,  Æò´Þ°ú À±´ÞÀÌ ¸ðµÎ Å©¸é : 6)
	var lunarMonthTable = [
	[2, 1, 2, 1, 2, 1, 2, 2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, 2, 1, 2, 1],   /* 2031 */
	[2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2],
	[1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 5, 2],
	[1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1],
	[2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2],
	[2, 2, 1, 2, 1, 4, 1, 1, 2, 2, 1, 2],
	[2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2],
	[2, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1],
	[2, 2, 1, 2, 5, 2, 1, 2, 1, 2, 1, 1],
	[2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 2, 1],
	[2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2],   /* 2041 */
	[1, 5, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2],
	[1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2]];

	/* ¾ç·Â <-> À½·Â º¯È¯ ÇÔ¼ö
	 * type : 1 - ¾ç·Â -> À½·Â
	 *        2 - À½·Â -> ¾ç·Â
	 * leapmonth : 0 - Æò´Þ
	 *             1 - À±´Þ (type = 2 ÀÏ¶§¸¸ À¯È¿)
	*/ 
	function lunarCalc(year, month, day, type, leapmonth)
	{
		var solYear, solMonth, solDay;
		var lunYear, lunMonth, lunDay;
		var lunLeapMonth, lunMonthDay;	
		var i, lunIndex;

		var solMonthDay = [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

		/* range check */
		if (year < 1900 || year > 2040)
		{
			alert('1900³âºÎÅÍ 2040³â±îÁö¸¸ Áö¿øÇÕ´Ï´Ù');
			return;
		}

		/* ¼Óµµ °³¼±À» À§ÇØ ±âÁØ ÀÏÀÚ¸¦ ¿©·¯°³·Î ÇÑ´Ù */
		if (year >= 2000)
		{
			/* ±âÁØÀÏÀÚ ¾ç·Â 2000³â 1¿ù 1ÀÏ (À½·Â 1999³â 11¿ù 25ÀÏ) */
			solYear = 2000;
			solMonth = 1;
			solDay = 1;
			lunYear = 1999;
			lunMonth = 11;
			lunDay = 25;
			lunLeapMonth = 0;

			solMonthDay[1] = 29;	/* 2000 ³â 2¿ù 28ÀÏ */
			lunMonthDay = 30;	/* 1999³â 11¿ù */
		}
		else if (year >= 1970)
		{
			/* ±âÁØÀÏÀÚ ¾ç·Â 1970³â 1¿ù 1ÀÏ (À½·Â 1969³â 11¿ù 24ÀÏ) */
			solYear = 1970;
			solMonth = 1;
			solDay = 1;
			lunYear = 1969;
			lunMonth = 11;
			lunDay = 24;
			lunLeapMonth = 0;

			solMonthDay[1] = 28;	/* 1970 ³â 2¿ù 28ÀÏ */
			lunMonthDay = 30;	/* 1969³â 11¿ù */
		}
		else if (year >= 1940)
		{
			/* ±âÁØÀÏÀÚ ¾ç·Â 1940³â 1¿ù 1ÀÏ (À½·Â 1939³â 11¿ù 22ÀÏ) */
			solYear = 1940;
			solMonth = 1;
			solDay = 1;
			lunYear = 1939;
			lunMonth = 11;
			lunDay = 22;
			lunLeapMonth = 0;

			solMonthDay[1] = 29;	/* 1940 ³â 2¿ù 28ÀÏ */
			lunMonthDay = 29;	/* 1939³â 11¿ù */
		}
		else
		{
			/* ±âÁØÀÏÀÚ ¾ç·Â 1900³â 1¿ù 1ÀÏ (À½·Â 1899³â 12¿ù 1ÀÏ) */
			solYear = 1900;
			solMonth = 1;
			solDay = 1;
			lunYear = 1899;
			lunMonth = 12;
			lunDay = 1;
			lunLeapMonth = 0;

			solMonthDay[1] = 28;	/* 1900 ³â 2¿ù 28ÀÏ */
			lunMonthDay = 30;	/* 1899³â 12¿ù */
		}

		lunIndex = lunYear - 1899;

		while (true)
		{
	//		document.write(solYear + "-" + solMonth + "-" + solDay + "<->");
	//		document.write(lunYear + "-" + lunMonth + "-" + lunDay + " " + lunLeapMonth + " " + lunMonthDay + "<br>");

			if (type == 1 &&
				year == solYear &&
				month == solMonth &&
				day == solDay)
			{
				return new myDate(lunYear, lunMonth, lunDay, lunLeapMonth);
			}	
			else if (type == 2 &&
					year == lunYear &&
					month == lunMonth &&
					day == lunDay && 
					leapmonth == lunLeapMonth)
			{
				return new myDate(solYear, solMonth, solDay, 0);
			}

			/* add a day of solar calendar */
			if (solMonth == 12 && solDay == 31)
			{
				solYear++;
				solMonth = 1;
				solDay = 1;

				/* set monthDay of Feb */
				if (solYear % 400 == 0)
					solMonthDay[1] = 29;
				else if (solYear % 100 == 0)
					solMonthDay[1] = 28;
				else if (solYear % 4 == 0)
					solMonthDay[1] = 29;
				else
					solMonthDay[1] = 28;

			}
			else if (solMonthDay[solMonth - 1] == solDay)
			{
				solMonth++;
				solDay = 1;	
			}
			else
				solDay++;

			/* add a day of lunar calendar */
			if (lunMonth == 12 &&
				((lunarMonthTable[lunIndex][lunMonth - 1] == 1 && lunDay == 29) ||
				(lunarMonthTable[lunIndex][lunMonth - 1] == 2 && lunDay == 30)))
			{
				lunYear++;
				lunMonth = 1;
				lunDay = 1;

				if (lunYear > 2043) {
					alert("ÀÔ·ÂÇÏ½Å ´ÞÀº ¾ø½À´Ï´Ù.");
					break;
				}

				lunIndex = lunYear - 1899;

				if (lunarMonthTable[lunIndex][lunMonth - 1] == 1)
					lunMonthDay = 29;
				else if (lunarMonthTable[lunIndex][lunMonth - 1] == 2)
					lunMonthDay = 30;
			}
			else if (lunDay == lunMonthDay)
			{
				if (lunarMonthTable[lunIndex][lunMonth - 1] >= 3
					&& lunLeapMonth == 0)
				{
					lunDay = 1;
					lunLeapMonth = 1;
				}
				else
				{
					lunMonth++;
					lunDay = 1;
					lunLeapMonth = 0;
				}

				if (lunarMonthTable[lunIndex][lunMonth - 1] == 1)
					lunMonthDay = 29;
				else if (lunarMonthTable[lunIndex][lunMonth - 1] == 2)
					lunMonthDay = 30;
				else if (lunarMonthTable[lunIndex][lunMonth - 1] == 3)
					lunMonthDay = 29;
				else if (lunarMonthTable[lunIndex][lunMonth - 1] == 4 &&
						lunLeapMonth == 0)
					lunMonthDay = 29;
				else if (lunarMonthTable[lunIndex][lunMonth - 1] == 4 &&
						lunLeapMonth == 1)
					lunMonthDay = 30;
				else if (lunarMonthTable[lunIndex][lunMonth - 1] == 5 &&
						lunLeapMonth == 0)
					lunMonthDay = 30;
				else if (lunarMonthTable[lunIndex][lunMonth - 1] == 5 &&
						lunLeapMonth == 1)
						lunMonthDay = 29;
				else if (lunarMonthTable[lunIndex][lunMonth - 1] == 6)
					lunMonthDay = 30;
			}
			else
				lunDay++;
		}
	}

	function getWeekday(year, month, day)
	{

		var weekday = Array("ÀÏ", "¿ù", "È­", "¼ö", "¸ñ", "±Ý", "Åä");
		var date = new Date(year, month - 1, day);

		if (date)
			return weekday[date.getDay()];
	}

	function getPassDay(year, month, day)
	{
		var date = new Date(year, month - 1, day);

		var interval = Math.floor((todayDate - date) / (1000 * 60 * 60 * 24) + 1);

		return interval;
	}

	function getDDay(year, month, day)
	{
		var date = new Date(year, month - 1, day);

		var interval = Math.floor((date - todayDate) / (1000 * 60 * 60 * 24) + 1);

		return interval;
	}

	function getDateSpecificInterval(year, month, day, interval)
	{
		var date = new Date(year, month - 1, parseInt(day, 10) + parseInt(interval, 10) - 1);

		return date;
	}

	function dayCalcDisplay(type)
	{
		switch (type) {
			/* ¿À´ÃÀº ¸îÀÏÂ° */
			case 1:
				var startYear = parseInt(document.getElementById("mStartYear").value, 10);
				var startMonth = parseInt(document.getElementById("mStartMonth").value, 10);
				var startDay = parseInt(document.getElementById("mStartDay").value, 10);
				break;

			/* x ÀÏÂ° µÇ´Â³¯ */
			case 2:
				var startYear = parseInt(document.getElementById("mmStartYear").value, 10);
				var startMonth = parseInt(document.getElementById("mmStartMonth").value, 10);
				var startDay = parseInt(document.getElementById("mmStartDay").value, 10);
				break;

			/* D-day */
			case 3:	
				var startYear = parseInt(document.getElementById("targetYear").value, 10);
				var startMonth = parseInt(document.getElementById("targetMonth").value, 10);
				var startDay = parseInt(document.getElementById("targetDay").value, 10);
				break;
				
			/* ¿äÀÏ °è»ê */			
			case 4:	
				var startYear = parseInt(document.getElementById("weekdayYear").value, 10);
				var startMonth = parseInt(document.getElementById("weekdayMonth").value, 10);
				var startDay = parseInt(document.getElementById("weekdayDay").value, 10);
				break;

			/* ¾ç·Â À½·Â º¯È¯ */			
			case 5:
				var startYear = parseInt(document.getElementById("lsStartYear").value, 10);
				var startMonth = parseInt(document.getElementById("lsStartMonth").value, 10);
				var startDay = parseInt(document.getElementById("lsStartDay").value, 10);
				break;
		}
		
		
		if ( !startYear || startYear == 0 ||
			 !startMonth || startMonth == 0 ||
			 !startDay || startDay == 0 )
		{
			alert('³¯Â¥¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä');
			return;
		}

		var solMonthDay = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

		if (startYear % 400 == 0 || ( startYear % 4 == 0 && startYear % 100 != 0 )) solMonthDay[1] += 1;


		if ( startMonth < 1 || startMonth > 12 ||
			 startDay < 1 || startDay > solMonthDay[startMonth-1] ) {
			if ( solMonthDay[1] == 28 && startMonth == 2 && startDay > 28 ) 
				alert("À±³âÀÌ ¾Æ´Õ´Ï´Ù. ´Ù½Ã ÀÔ·ÂÇØÁÖ¼¼¿ä");
			else
				alert("³¯Â¥ ¹üÀ§¸¦ ¹þ¾î³µ½À´Ï´Ù. ´Ù½Ã ÀÔ·ÂÇØÁÖ¼¼¿ä");
			return;
		}

		var startDate = new Date(startYear, startMonth - 1, startDay);
		var today = new Date(todayDate.getFullYear(),
							todayDate.getMonth(), todayDate.getDate());

		switch (type)
		{
		/* ¿À´ÃÀº ¸îÀÏÂ° */
		case 1:
			if (today < startDate)
			{
				alert("±âÁØÀÏÀ» ¿À´Ãº¸´Ù ÀÌÀü ³¯Â¥·Î ¼³Á¤ÇÏ¼¼¿ä");
				return;
			}

			var interval = getPassDay(startYear, startMonth, startDay); 
			document.getElementById("day1").value = interval;
			break;
		/* x ÀÏ µÇ´Â ³¯Àº */
		case 2:
			/*	
			if (today < startDate)
			{
				alert("±âÁØÀÏÀ» ¿À´Ã ÀÌÀü ³¯Â¥·Î ¼³Á¤ÇÏ¼¼¿ä");
				return;
			}
			*/

			var day2 = document.getElementById("day2").value;

			if (day2 <= 0)
			{
				alert("0 º¸´Ù Å« ¼ö¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
				return;
			}

			var date = getDateSpecificInterval(startYear, startMonth, startDay, day2);

			document.getElementById("resultDay").value = 
				String(date.getFullYear()) + "³â " + 
				String(date.getMonth() +1 ) + "¿ù " + 
				String(date.getDate()) + "ÀÏ";

			break;	
		/* D-Day */
		case 3:
			
			var interval = getDDay(startYear, startMonth, startDay);

			if (today > startDate)
			{
				alert("±âÁØÀÏÀ» ¿À´Ã ÀÌÈÄ ³¯Â¥·Î ¼³Á¤ÇÏ¼¼¿ä");
				return;
			}

			document.getElementById("day3").value = interval;

			break;

		/* ¿äÀÏ °è»ê */
		case 4:
			if (startYear < 100)
			{
				alert('³âµµ¸¦ 100³â ÀÌÈÄ·Î ÀÔ·ÂÇØ ÁÖ¼¼¿ä');
				return;
			}
			weekday.value = getWeekday(startYear, startMonth, startDay) + "¿äÀÏ";

			break;

		/* ¾ç·Â/À½·Â º¯È¯ */
		case 5:
			if (document.getElementById('solarLunar').value == 'solar')
			{
				var leapMonth = document.getElementById('leapMonth').checked;
				var date = lunarCalc(startYear, startMonth, startDay, 2, leapMonth);
			}
			else
			{
				var date = lunarCalc(startYear, startMonth, startDay, 1);
			}

			if (date)
			{
				document.getElementById('solarLunarDay').value = 
					date.year + "³â " + 
					(date.leapMonth ? "À±" : "") + date.month + "¿ù " +
					date.day + "ÀÏ ";

			}
			else
			{
				document.getElementById('solarLunarDay').value = "";
			}

			break;
		}
	}

	function memorialDayCheck(solarDate, lunarDate)
	{
		var i;
		var memorial;


		for (i = 0; i < memorialDays.length; i++)
		{
			if (memorialDays[i].month == solarDate.month &&
				memorialDays[i].day == solarDate.day &&
				memorialDays[i].solarLunar == 1)
				return memorialDays[i];

			if (memorialDays[i].month == lunarDate.month &&
				memorialDays[i].day == lunarDate.day &&
				memorialDays[i].solarLunar == 2 &&
				!memorialDays[i].leapMonth)
				return memorialDays[i];
		}

		return null;
	}
