var fixedX = -1; ////////// 레이어 X축 위치 (-1 : 버튼에 바로 아래에 표시)
var fixedY = -1; ////////////// 레이어 Y축 위치 (-1 : 버튼에 바로 아래에 표시)
var startAt = 0; ///////////// 일요일 표시 부분 / 0 : 일요일(일월화...) / 1 : 월요일(...금토일)
var showToday = 1; // 오늘 날자 표시 유무 - 0 : 감춤 / 1 : 보임
var imgDir = './'; // 이미지 디렉토리 - ./ : 현재 디렉토리
var Sort='';
/////////////////////////////// 각 변수 선언 ///////////////////
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);
if (Sort==1){
parent.searchGo();
}
}
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 iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
function popUpCalendar(ctl, ctl2, format, sort) {
var leftpos = 0;
var toppos = 0;
Sort=sort
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 {
//DTD선언문때문에 바뀐코딩 20100625
if(aTag.offsetParent==null) break;//<-- 추가
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 - document.body.scrollTop : fixedY;//<-수정
/*
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 - iecompattest().scrollTop : fixedY;
*/
constructCalendar (1, monthSelected, yearSelected);
bShow = true;
ctlNow = ctl;
}
}
init();