var fixedX = -1; ////////// ·¹ÀÌ¾î XÃà À§Ä¡ (-1 : ¹öÆ°¿¡ ¹Ù·Î ¾Æ·¡¿¡ Ç¥½Ã)
var fixedY = -1; ////////////// ·¹ÀÌ¾î YÃà À§Ä¡ (-1 : ¹öÆ°¿¡ ¹Ù·Î ¾Æ·¡¿¡ Ç¥½Ã)
var startAt = 0; ///////////// ÀÏ¿äÀÏ Ç¥½Ã ºÎºÐ / 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 = "<img src='' width=0 height=0>";
   strCalendar += "<style type='text/css'>";
   strCalendar += "td {font-size:12px; font-family:±¼¸²; text-decoration:none; }";
   strCalendar += "A:link,A:active,A:visited{text-decoration:none;font-size:12PX;color:#333333;}";
   strCalendar += "A:hover {text-decoration:none; color:ff9900}";
   strCalendar += "font { font-size: 9pt; }";
   strCalendar += ".cnj_close {font-size:8pt;color:#000000; background-color:#EFEFEF; border-width:1; border-color:#808080; border-style:solid;cursor:hand;font-weight:bold;height:16px;width:16px;text-align:center;vertical-align:bottom}";
   strCalendar += ".cnj_close2 {font-size:8pt;color:#000000; background-color:#EFEFEF; border-width:1; border-color:#808080; border-style:solid;cursor:hand;font-weight:bold;height:16px;width:16px;text-align:center;vertical-align:bottom}";
   strCalendar += ".cnj_input {background-color:rgb(240,240,240);border-width:1pt; height:16pt;cursor:hand;}";
   strCalendar += ".cnj_input2 {font-size:8pt;color:#808080; background-color:#EFEFEF; border-width:1; border-color:#808080; border-style:solid;cursor:hand;height:16px;}";
   strCalendar += ".cnj_input3 {font-size:8pt;color:#000000; background-color:#FFFFFF; border-width:1; border-color:#C00000; border-style:solid;cursor:hand;height:16px;}";
   strCalendar += ".cnj_input4 {font-size:8pt;color:#C00000; background-color:#FFFFFF; border-width:1; border-color:#808080; border-style:solid;cursor:hand;height:16px;}";
   strCalendar += ".cnj_td {border-width:1;border-style:solid;border-color:#a0a0a0;}";
   strCalendar += "</style>";

   //strCalendar += "<div id='calendar' style='z-index:+999;position:absolute;;'>";
   strCalendar += "<table width='160' border='1' bordercolor='#D6CBC2' bgcolor='#FFFFFF' style='border-collapse:collapse;' cellpadding='3' cellspacing='0'>";
   strCalendar += "<tr>";
   strCalendar += "   <td colspan='4' align='center' style='padding:5 0 2 0;'>";
   strCalendar += "      <table width='145' border='0' cellspacing='0' cellpadding='0'>";
   strCalendar += "      <tr>";
   strCalendar += "         <td width='145' height='21' background='/carrot/img_carrot/cal_top01.gif' align='center' style='padding:3 0 0 0;'>";
   strCalendar += "            <span id='caption'></span>";
   strCalendar += "         </td>";
   strCalendar += "      </tr>";
   strCalendar += "      <tr>";
   strCalendar += "         <td height='3' width='145'></td>";
   strCalendar += "      </tr>";
   strCalendar += "      <tr>";
   strCalendar += "         <td width='145'><img src='/carrot/img_carrot/cal_top02.gif' width='145' height='13'></td>";
   strCalendar += "      </tr>";
   strCalendar += "      </table>";
   strCalendar += "      <!-- ´Þ·Â  ³¯Â¥½ÃÀÛ -->";
   strCalendar += "      <span id='content'></span>";
   strCalendar += "      <!-- ´Þ·Â  ³¯Â¥  ³¡ -->";
   strCalendar += "   </td>";
   strCalendar += "</tr>";
   strCalendar += "</table>";
   //strCalendar += "</div>";
   strCalendar += "<div id='selectMonth' style='z-index:+999;position:absolute;display:none;'></div> ";
   strCalendar += "<div id='selectYear' style='z-index:+999;position:absolute;display:none;'></div>";
   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;

      sHTML1  = "<img src='/carrot/img_carrot/v_prev.gif' width='7' height='7' align='absmiddle' border='0' onClick='javascript:parent.movedecMonth()' title='ÀÌÀü ´Þ(¿ù)·Î ÀÌµ¿' style='cursor:hand'>";
      //sHTML1 += "<input name='spanYear' id='spanYear' value='"+yearNow+"³â' readonly style='text-align:right;width:40;font-size:9pt;font-family:Times New Roman;font-weight:bold;valign:bottom;border:1px;color:FFFF99;background:'>";
      //sHTML1 += "<input name='spanMonth' id='spanMonth' value='"+monthName[monthNow].substring(0,3)+"' readonly style='text-align:right;width:26;font-size:9pt;font-family:Times New Roman;font-weight:bold;valign:bottom;border:1px;color:FFFF99;background:'>";
      sHTML1 += "<span id='spanYear'></span>";
      sHTML1 += "<span id='spanMonth'></span>";
      sHTML1 += "<img src='/carrot/img_carrot/v_next.gif' width='7' height='7' align='absmiddle' border='0' onClick='javascript:parent.moveincMonth()' title='´ÙÀ½ ´Þ(¿ù)·Î ÀÌµ¿' style='cursor:hand'>";

      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:none;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","<e>");
   sTmp = sTmp.replace("d","<d>");
   sTmp = sTmp.replace("<e>",padZero(d));
   sTmp = sTmp.replace("<d>",d);
   sTmp = sTmp.replace("mmmm","<p>");
   sTmp = sTmp.replace("mmm","<o>");
   sTmp = sTmp.replace("mm","<n>");
   sTmp = sTmp.replace("m","<m>");
   sTmp = sTmp.replace("<m>",m+1);
   sTmp = sTmp.replace("<n>",padZero(m+1));
   sTmp = sTmp.replace("<o>",monthName[m]);
   sTmp = sTmp.replace("<p>",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 = " <B>"+ newMonth +"¿ù</B> "; 
      } 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 = " <B>"+ newMonth +"¿ù</B> "; 
      } 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 ="<tr><td align='center' style='cursor:pointer'  "
      sHTML +="   onmouseover='this.style.backgroundColor=\"#FFCC99\"' "
      sHTML +="   onmouseout='clearInterval(parent.intervalID1);this.style.backgroundColor=\"\"'  "
      sHTML +="   onmousedown='clearInterval(parent.intervalID1);parent.intervalID1=setInterval(\"parent.decMonth()\",30)' "
      sHTML +="   onmouseup='clearInterval(parent.intervalID1)'> "
      sHTML +="   ¡ã</td></tr>";
      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 = "<b>" + sName + "</b>" }
         sHTML +="<tr><td height='15' id='m" + j + "' onmouseover='this.style.backgroundColor=\"#FFCC99\"' onmouseout='this.style.backgroundColor=\"\"' "
         sHTML +=" style='cursor:pointer' onClick='parent.selectMonth("+j+");event.cancelBubble=true'> " + sName + "¿ù"
         sHTML +="</td></tr>";
         j ++;
      }
        
       // ¿ù ´ÙÀ½ ¿ù ¸µÅ©
      sHTML += "<tr><td align='center' onmouseover='this.style.backgroundColor=\"#FFCC99\"' style='cursor:pointer' "
      sHTML += " onmouseout='clearInterval(parent.intervalID2);this.style.backgroundColor=\"\"' "
      sHTML += " onmousedown='clearInterval(parent.intervalID2);parent.intervalID2=setInterval(\"parent.incMonth()\",30)'  "
      sHTML += " onmouseup='clearInterval(parent.intervalID2)'> "
      sHTML += " ¡å</td></tr>";

          /////// ¿ù Ç¥ Å©±â ///////////////////////////////
      oPopup.document.getElementById("selectMonth").innerHTML  = ""+
      "<table width='50' style='font-family:±¼¸²; font-size:11px; border-width:1; border-style:solid; border-color:#a0a0a0;' bgcolor='#FFFFDD' "+ 
      " onmouseover='clearTimeout(parent.timeoutID2)' "+
      " onmouseout='clearTimeout(parent.timeoutID2);parent.timeoutID2=setTimeout(\"parent.popDownMonth()\",100)' cellspacing=0>"+
      ""+ sHTML   + ""+
      "</table>";
      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 = " <B>"+ newYear +"³â  </B> "; 
      } 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 = " <B>"+ newYear +"³â  </B> "; 
      } 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 ="<tr><td align='center' style='cursor:pointer'  "
      sHTML +="   onmouseover='this.style.backgroundColor=\"#FFCC99\"' "
      sHTML +="   onmouseout='clearInterval(parent.intervalID1);this.style.backgroundColor=\"\"'  "
      sHTML +="   onmousedown='clearInterval(parent.intervalID1);parent.intervalID1=setInterval(\"parent.decYear()\",30)' "
      sHTML +="   onmouseup='clearInterval(parent.intervalID1)'> "
      sHTML +="   ¡ã</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 height='15' id='y" + j + "' onmouseover='this.style.backgroundColor=\"#FFCC99\"' onmouseout='this.style.backgroundColor=\"\"' "
         sHTML +=" style='cursor:pointer' onClick='parent.selectYear("+j+");event.cancelBubble=true'> " + sName + "³â  "
         sHTML +="</td></tr>";
         j ++;
      }
        
       // ³âµµ ´ÙÀ½ ³âµµ ¸µÅ©
      sHTML += "<tr><td align='center' onmouseover='this.style.backgroundColor=\"#FFCC99\"' style='cursor:pointer' "
      sHTML += " onmouseout='clearInterval(parent.intervalID2);this.style.backgroundColor=\"\"' "
      sHTML += " onmousedown='clearInterval(parent.intervalID2);parent.intervalID2=setInterval(\"parent.incYear()\",30)'   "
      sHTML += " onmouseup='clearInterval(parent.intervalID2)'> "
      sHTML += " ¡å</td></tr>";

         /////// ³âµµ Ç¥ Å©±â ///////////////////////////////
      oPopup.document.getElementById("selectYear").innerHTML   = ""+
      "<table width='55' style='font-family:±¼¸²; font-size:11px; border-width:1; border-style:solid; border-color:#a0a0a0;' bgcolor='#FFFFDD' "+ 
      " onmouseover='clearTimeout(parent.timeoutID2)' "+
      " onmouseout='clearTimeout(parent.timeoutID2);parent.timeoutID2=setTimeout(\"parent.popDownYear()\",100)' cellspacing=0>"+
      ""+ sHTML   + ""+
      "</table>";
      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 =  "<table width='145' border='0' cellspacing='0' align='center' cellpadding='0'>";
   sHTML += "<tr>";
   sHTML += "   <td width='15%' height='3'></td>";
   sHTML += "   <td width='14%'></td>";
   sHTML += "   <td width='14%'></td>";
   sHTML += "   <td width='14%'></td>";
   sHTML += "   <td width='14%'></td>";
   sHTML += "   <td width='14%'></td>";
   sHTML += "   <td width='15%'></td>";
   sHTML += "</tr>";
   sHTML += "<tr align='center'>";

//   for(i=0; i<7; i++) {   /////// ¿äÀÏ ///////////////////////
//      sHTML += "<td width='27' align='right'><B>"+ dayName[i]+"</B></td>";
//   }
//   sHTML +="</tr><tr height=16>";
      
   for(var i=1; i<=dayPointer;i++)  {  // ºó ³¯Â¥
      sHTML += "<td class='cal'> </td>";
   }
   
   for(datePointer=1; datePointer<=numDaysInMonth; datePointer++) {
      dayPointer++;

      if((datePointer == dateNow) && (monthSelected == monthNow) && (yearSelected == yearNow)) {  // ÇöÀç ¿À´Ã ³¯Â¥
         sHTML += "<td align='center' bgcolor='#87C338' class='cal'>";
      } else {
         sHTML += "<td 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;
            }
         }
      }
      var regexp= /\"/g;
      sHint=sHint.replace(regexp,"&quot;");
      /////////////// ³¯Â¥ ¼±ÅÃ½Ã ==> ¸¶¿ì½º°¡ ³¯Â¥ À§·Î °¬À»¶§ ///////////////////////////////
      dateMessage = "title=' ³¯Â¥ ¼±ÅÃ : "+ yearSelected + "³â " +   monthName[monthSelected] +" "  + datePointer + "ÀÏ"+"' onmousemove='window.status=\" ³¯Â¥ ¼±ÅÃ : "+ yearSelected + "³â " + monthName[monthSelected] +" "  + datePointer + "ÀÏ"+"\"' onmouseout='window.status=\"\"' ";

      if((datePointer == dateNow) && (monthSelected == monthNow) && (yearSelected == yearNow)) {  // ÇöÀç ¿À´Ã ³¯Â¥
         sHTML += "<b><div style='"+sStyle+"' onclick='javascript:parent.dateSelected="+datePointer+";parent.closeCalendar();'><font color=#FFFFFF> " + datePointer + "</font> </div></b>";
      } else
      if(dayPointer % 7 == (startAt * -1)+1) {  // ÀÏ¿äÀÏ ÀÏ¶§
         sHTML += "<div style='"+sStyle+"' onclick='javascript:parent.dateSelected="+datePointer + ";parent.closeCalendar();'> <font color=red>" + datePointer + "</font> </div>";
      } else {
         sHTML += "<div style='"+sStyle+"' onclick='javascript:parent.dateSelected="+ datePointer + ";parent.closeCalendar();'>" + datePointer + "</div>";
      }
      sHTML += "";

      if((dayPointer+startAt) % 7 == startAt) { 
         sHTML += "</tr><tr align='center'>";
         intWeekCount ++;
      }
   }
   sHTML += "</tr>";
   sHTML = sHTML.replace("<tr height=16></tr>", "");
   if (((dayPointer+startAt) % 7) == 0) intWeekCount--;
   oPopup.document.getElementById("content").innerHTML = sHTML;  
   //////// ¼¿¸¯Æ® ¿ù ¼±ÅÃ
   oPopup.document.getElementById("spanMonth").innerHTML = "<font color='#FFFF99'><b>" +  monthName[monthSelected] + "</b></font>&nbsp;"

   //////// ¼¿¸¯Æ® ³âµµ ¼±ÅÃ
   oPopup.document.getElementById("spanYear").innerHTML  = "&nbsp;<font color='#FFFF99'><b>" + yearSelected   + "³â</b></font>&nbsp;"

   //alert(intWeekCount);
   var popHeight;
   if (intWeekCount == 6)
      popHeight = 142;
   else
      popHeight = 124;
   oPopup.show(cleft, ctop, 162, popHeight, document.body);
}

function popMiniCalendar(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;
      ctop = fixedY==-1 ?  event.y :   fixedY;  // ÇöÀç ¸¶¿ì½º À§Ä¡

      constructCalendar (1, monthSelected, yearSelected);

      bShow = true;
      ctlNow = ctl;
   }
}

init();

