var fixedX = -1; ////////// ·¹À̾î XÃà À§Ä¡ (-1 : ¹öư¿¡ ¹Ù·Î ¾Æ·¡¿¡ Ç¥½Ã)
var fixedY = -1; ////////////// ·¹À̾î YÃà À§Ä¡ (-1 : ¹öư¿¡ ¹Ù·Î ¾Æ·¡¿¡ Ç¥½Ã)
var startAt = 0; ///////////// ÀÏ¿äÀÏ Ç¥½Ã ºÎºÐ / 0 : ÀÏ¿äÀÏ(ÀÏ¿ùÈ...) / 1 : ¿ù¿äÀÏ(...±ÝÅäÀÏ)
var showToday = 1; // ¿À´Ã ³¯ÀÚ Ç¥½Ã À¯¹« - 0 : °¨Ãã / 1 : º¸ÀÓ
var imgDir = './'; // À̹ÌÁö µð·ºÅ丮 - ./ : ÇöÀç µð·ºÅ丮
/////////////////////////////// °¢ º¯¼ö ¼±¾ð ///////////////////
var crossobj, crossMonthObj, crossYearObj, monthSelected, yearSelected, dateSelected, omonthSelected, oyearSelected, odateSelected, monthConstructed, yearConstructed, intervalID1, intervalID2, timeoutID1, timeoutID2, ctlToPlaceValue, ctlNow, dateFormat, nStartingMonth, nStartingYear
var bPageLoaded = false;
var ie = document.all;
var dom = document.getElementById;
var bShow = false;
var ns4 = document.layers;
var today = new Date(); /////////////// ³¯ÀÚ º¯¼ö ¼±¾ð
var dateNow = today.getDate(); //////////////// ·ÎÄà ÄÄÇ»ÅÍÀÇ ÀÏ(day)À» ±¸ÇÔ
var monthNow = today.getMonth(); ///////////////// ·ÎÄà ÄÄÇ»ÅÍÀÇ ¿ù(month)À» ±¸ÇÔ
var yearNow = today.getYear(); ///////////////// ·ÎÄà ÄÄÇ»ÅÍÀÇ ³â(year)À» ±¸ÇÔ
var monthName = new Array("1¿ù", "2¿ù", "3¿ù", "4¿ù", "5¿ù", "6¿ù", "7¿ù", "8¿ù", "9¿ù", "10¿ù", "11¿ù", "12¿ù")
var monthName2 = new Array("1¿ù", "2¿ù", "3¿ù", "4¿ù", "5¿ù", "6¿ù", "7¿ù", "8¿ù", "9¿ù", "10¿ù", "11¿ù", "12¿ù")
if (startAt==0) {
dayName = new Array ("ÀÏ","¿ù","È","¼ö","¸ñ","±Ý","Åä")
} else {
dayName = new Array ("¿ù","È","¼ö","¸ñ","±Ý","Åä","ÀÏ")
}
var oPopup = window.createPopup();
var oPopBody = oPopup.document.body;
var strCalendar;
var cleft;
var ctop;
if(dom) {
strCalendar = "
";
strCalendar += "";
strCalendar += "
";
strCalendar += "
";
strCalendar += " ";
strCalendar += " ";
strCalendar += " ";
strCalendar += " | ";
strCalendar += "
";
strCalendar += " ";
strCalendar += " | ";
strCalendar += "
";
if(showToday==1) {
strCalendar += " |
";
}
strCalendar += "
";
strCalendar += "
";
strCalendar += " ";
strCalendar += "";
oPopBody.innerHTML = strCalendar;
}
function init() {
if(!ns4) {
if(!ie) {
yearNow += 1900;
}
crossobj = oPopBody.all.calendar;
crossMonthObj = oPopBody.all.selectMonth;
crossYearObj = oPopBody.all.selectYear;
monthConstructed = false;
yearConstructed = false;
if(showToday==1) {
oPopup.document.getElementById("lblToday").innerHTML = ""+
""+
"¿À´Ã ³¯Â¥ : "+yearNow+"³â "+
""+monthName[monthNow].substring(0,3)+" "+
""+dateNow+"ÀÏ "+ // ÀÏ
"
";
}
sHTML1=" "
sHTML1+=" "
sHTML1+=" ";
sHTML1+=" ";
oPopup.document.getElementById("caption").innerHTML = sHTML1;
bPageLoaded = true;
}
}
function HolidayRec(d, m, y, desc) {
this.d = d;
this.m = m;
this.y = y;
this.desc = desc;
}
var HolidaysCounter = 0;
var Holidays = new Array();
function addHoliday(d, m, y, desc) {
Holidays[HolidaysCounter++] = new HolidayRec ( d, m, y, desc );
}
var styleAnchor = "text-decoration:none;color:black;cursor:hand;width:100%;height:100%";
var styleLightBorder = "border-style:solid;border-width:1px;border-color:#a0a0a0;text-decoration:underline;font-weight:bold;cursor:hand;width:100%;height:100%";
function padZero(num) {
return (num < 10)? '0' + num : num;
}
function constructDate(d,m,y) {
sTmp = dateFormat
sTmp = sTmp.replace("dd","");
sTmp = sTmp.replace("d","");
sTmp = sTmp.replace("",padZero(d));
sTmp = sTmp.replace("",d);
sTmp = sTmp.replace("mmmm","");
sTmp = sTmp.replace("mmm","");
sTmp = sTmp.replace("mm","");
sTmp = sTmp.replace("m","");
sTmp = sTmp.replace("",m+1);
sTmp = sTmp.replace("",padZero(m+1));
sTmp = sTmp.replace("",monthName[m]);
sTmp = sTmp.replace("",monthName2[m]);
sTmp = sTmp.replace("yyyy",y);
return sTmp.replace("yy",padZero(y%100));
}
function closeCalendar() {
oPopup.hide();
ctlToPlaceValue.value = constructDate(dateSelected,monthSelected,yearSelected);
}
function moveincMonth() {
monthSelected++;
if (monthSelected>11) {
monthSelected=0;
yearSelected++;
}
constructCalendar();
}
function movedecMonth() {
monthSelected--;
if (monthSelected<0) {
monthSelected=11;
yearSelected--;
}
constructCalendar();
}
function incMonth() {
if (nStartingMonth + 6 == 12) return;
for(i = 0; i < 7; i++) {
newMonth = (i + nStartingMonth) + 1;
if (newMonth > 12) {nStartingMonth--; break;}
if (newMonth == monthSelected + 1) {
txtMonth = " "+ newMonth +"¿ù ";
} else {
txtMonth = " " + newMonth + "¿ù";
}
oPopup.document.getElementById("m"+i).innerHTML = txtMonth;
}
nStartingMonth++;
bShow = true;
}
function decMonth() {
if (nStartingMonth == 1) return;
for (i=0; i<7; i++) {
newMonth = (i+nStartingMonth)-1;
if (newMonth < 1) {nStartingMonth++; break;}
if (newMonth==monthSelected + 1) {
txtMonth = " "+ newMonth +"¿ù ";
} else {
txtMonth = " " + newMonth + "¿ù";
}
oPopup.document.getElementById("m"+i).innerHTML = txtMonth;
}
nStartingMonth--;
bShow = true;
}
function selectMonth(nMonth) {
monthSelected = parseInt(nMonth + nStartingMonth - 1);
monthConstructed = false;
constructCalendar();
popDownMonth();
}
function constructMonth() {
popDownYear();
sHTML = "";
if(!monthConstructed) { // ¿ù ÀÌÀü ¿ù ¸µÅ©
sHTML ="
"
sHTML +=" ¡ã |
";
j = 0;
var nSelectedMonth = monthSelected + 1;
nStartingMonth = (nSelectedMonth - 3) < 1 ? 1 : nSelectedMonth - 3; //½ÃÀÛ¿ù - 3 ÀÌ 1º¸´Ù ÀÛÀ¸¸é 1·Î °íÁ¤
nStartingMonth = nStartingMonth > 6 ? 6 : nStartingMonth; //½ÃÀÛ¿ùÀÌ 6º¸´Ù Å©¸é 6·Î °íÁ¤ (6 ½ÃÀÛ ¿ù + ¸ñ·Ï ¼ýÀÚ 6 = 12 Á¾·á ¿ù)
var nEndMonth = (nSelectedMonth + 3) > 12 ? 12 : (nSelectedMonth + 3); // Á¾·á¿ù + 3ÀÌ 12º¸´Ù Å©¸é 12·Î °íÁ¤
nEndMonth = nEndMonth < 7 ? 7 : nEndMonth; //Á¾·á ¿ùÀÌ 7º¸´Ù ÀÛÀ¸¸é 7·Î °íÁ¤
for (i = nStartingMonth; i <= nEndMonth; i++) {
sName = i;
//////////////// ÇöÀç ¿ù ////////////////////////
if (i == nSelectedMonth) { sName = "" + sName + "" }
sHTML +=" " + sName + "¿ù"
sHTML +=" |
";
j ++;
}
// ¿ù ´ÙÀ½ ¿ù ¸µÅ©
sHTML += " "
sHTML += " ¡å |
";
/////// ¿ù Ç¥ Å©±â ///////////////////////////////
oPopup.document.getElementById("selectMonth").innerHTML = ""+
"";
monthConstructed = true;
}
}
function popUpMonth() {
constructMonth();
crossMonthObj.style.display = "";
crossMonthObj.style.left = crossobj.style.left + 50;
crossMonthObj.style.top = crossobj.style.top + 26;
}
function popDownMonth() {
crossMonthObj.style.display = "none";
}
function incYear() {
for(i=0; i<7; i++) {
newYear = (i+nStartingYear)+1;
if (newYear==yearSelected) {
txtYear = " "+ newYear +"³â ";
} else {
txtYear = " " + newYear + "³â ";
}
oPopup.document.getElementById("y"+i).innerHTML = txtYear;
}
nStartingYear++;
bShow = true;
}
function decYear() {
for (i=0; i<7; i++) {
newYear = (i+nStartingYear)-1;
if (newYear==yearSelected) {
txtYear = " "+ newYear +"³â ";
} else {
txtYear = " " + newYear + "³â ";
}
oPopup.document.getElementById("y"+i).innerHTML = txtYear;
}
nStartingYear--;
bShow = true;
}
function selectYear(nYear) {
yearSelected = parseInt(nYear+nStartingYear);
yearConstructed = false;
constructCalendar();
popDownYear();
}
function constructYear() {
popDownMonth();
sHTML = "";
if(!yearConstructed) { // ³âµµ ÀÌÀü ³âµµ ¸µÅ©
sHTML =" "
sHTML +=" ¡ã |
";
j = 0;
nStartingYear = yearSelected-3;
for (i=(yearSelected-3); i<=(yearSelected+3); i++) {
sName = i;
if (i==yearSelected) { sName = "" + sName + "" }
sHTML +=" " + sName + "³â "
sHTML +=" |
";
j ++;
}
// ³âµµ ´ÙÀ½ ³âµµ ¸µÅ©
sHTML += " "
sHTML += " ¡å |
";
/////// ³âµµ Ç¥ Å©±â ///////////////////////////////
oPopup.document.getElementById("selectYear").innerHTML = ""+
"";
yearConstructed = true;
}
}
function popDownYear() {
clearInterval(intervalID1);
clearTimeout(timeoutID1);
clearInterval(intervalID2);
clearTimeout(timeoutID2);
crossYearObj.style.display = "none";
}
function popUpYear() {
constructYear();
crossYearObj.style.display = "";
crossYearObj.style.left = crossobj.style.left + (6 + oPopup.document.getElementById("spanYear").offsetLeft) + "px";
crossYearObj.style.top = crossobj.style.top + 26;
}
function constructCalendar() {
var aNumDays = Array (31,0,31,30,31,30,31,31,30,31,30,31);
var dateMessage;
var startDate = new Date (yearSelected,monthSelected,1);
var endDate;
var intWeekCount = 1;
if(monthSelected==1) {
endDate = new Date (yearSelected,monthSelected+1,1);
endDate = new Date (endDate - (24*60*60*1000));
numDaysInMonth = endDate.getDate();
} else {
numDaysInMonth = aNumDays[monthSelected];
}
datePointer = 0;
dayPointer = startDate.getDay() - startAt;
if(dayPointer<0) {
dayPointer = 6;
}
sHTML = "";
for(i=0; i<7; i++) { /////// ¿äÀÏ ///////////////////////
sHTML += ""+ dayName[i]+" | ";
}
sHTML +="
";
for(var i=1; i<=dayPointer;i++) { // ºó ³¯Â¥
sHTML += " | ";
}
for(datePointer=1; datePointer<=numDaysInMonth; datePointer++) {
dayPointer++;
sHTML += "";
sStyle = styleAnchor;
if((datePointer==odateSelected) && (monthSelected==omonthSelected) && (yearSelected==oyearSelected)) {
sStyle += styleLightBorder;
}
sHint = "";
for(k=0;k ¸¶¿ì½º°¡ ³¯Â¥ À§·Î °¬À»¶§ ///////////////////////////////
dateMessage = "title=' ³¯Â¥ ¼±Åà : "+ yearSelected + "³â " + monthName[monthSelected] +" " + datePointer + "ÀÏ"+"' onmousemove='window.status=\" ³¯Â¥ ¼±Åà : "+ yearSelected + "³â " + monthName[monthSelected] +" " + datePointer + "ÀÏ"+"\"' onmouseout='window.status=\"\"' ";
if((datePointer == dateNow) && (monthSelected == monthNow) && (yearSelected == yearNow)) { // ÇöÀç ¿À´Ã ³¯Â¥
sHTML += " " + datePointer + " ";
} else
if(dayPointer % 7 == (startAt * -1)+1) { // ÀÏ¿äÀÏ À϶§
sHTML += " " + datePointer + " ";
} else {
sHTML += "" + datePointer + " ";
}
sHTML += "";
if((dayPointer+startAt) % 7 == startAt) {
sHTML += " |
";
intWeekCount ++;
}
}
sHTML += "
";
sHTML = sHTML.replace("
", "");
if (((dayPointer+startAt) % 7) == 0) intWeekCount--;
oPopup.document.getElementById("content").innerHTML = sHTML;
//////// ¼¿¸¯Æ® ¿ù ¼±ÅÃ
oPopup.document.getElementById("spanMonth").innerHTML = " " + monthName[monthSelected] + " "
//////// ¼¿¸¯Æ® ³âµµ ¼±ÅÃ
oPopup.document.getElementById("spanYear").innerHTML = " " + yearSelected + "³â "
//alert(intWeekCount);
var popHeight;
if (intWeekCount == 6)
popHeight = 195;
else
popHeight = 177;
oPopup.show(cleft, ctop, 198, popHeight, document.body);
}
function popUpCalendar(ctl, ctl2, format) {
var leftpos = 0;
var toppos = 0;
if(bPageLoaded) {
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) {
formatChar="";
}
}
}
}
tokensChanged = '0';
if(formatChar != "") {
aData = ctl2.value.split(formatChar);
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++;
}
}
} else
if(aFormat[i]=="mmmm") {
for(j=0; j<12; j++) {
if (aData[i]==monthName2[j]) {
monthSelected=j;
tokensChanged ++;
}
}
}
}
}
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");
cleft = fixedX==-1 ? ctl.offsetLeft + leftpos : fixedX;
ctop = fixedY==-1 ? ctl.offsetTop + ctl.offsetHeight + toppos : fixedY;
constructCalendar (1, monthSelected, yearSelected);
bShow = true;
ctlNow = ctl;
}
}
init();