﻿// 엔터체크
function TextBoxExScript_EnterCheck(nextobj) 
{
	nextobj	= document.getElementById(nextobj)
	
	try{
			if(event.keyCode == 13 || event.keyCode == 9){  
					nextobj.focus();
					event.returnValue = false;
			}
	}
	catch(exp){
			alert('Can Not Find Next Control Name');
	}
}

// 일본어 전각을 반각
function TextBoxExScript_f_Check() 
{
    var obj = event.srcElement;

    var text = obj.value;

    han_name = 'ｱｲｳｴｵｶｷｸｹｺｻｼｽｾｿﾀﾁﾂﾃﾄﾅﾆﾇﾈﾉﾊﾋﾌﾍﾎﾏﾐﾑﾒﾓﾔﾕﾖﾗﾘﾙﾚﾛﾜｦﾝｧｨｩｪｫ･abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789－';
    zen_name = 'アイウエオカキクケコサシスセソタチツテトナニヌネノ';
    zen_name+= 'ハヒフヘホマミムメモヤユヨラリルレロワヲンァィゥェォ・ａｂｃｄｅｆｇｈｉｊｋｌｍｎｏｐｑｒｓｔｕｖｗｘｙｚ';
    zen_name+= 'ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ０１２３４５６７８９-';
    zenKana ='アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンァィゥェォ０１２３４５６７８９ー';
    hanKana ='ｱｲｳｴｵｶｷｸｹｺｻｼｽｾｿﾀﾁﾂﾃﾄﾅﾆﾇﾈﾉﾊﾋﾌﾍﾎﾏﾐﾑﾒﾓﾔﾕﾖﾗﾘﾙﾚﾛﾜｦﾝｧｨｩｪｫ0123456789-';

    str = '';
    for(i=0;i<text.length;i++) {
        c=text.charAt(i);
        n=zenKana.indexOf(c,0);
        if(n>=0) c=hanKana.charAt(n);
        str+=c;
    }
    obj.value = str;
}

// 초기 0으로 셋팅
function TextBoxExScript_f_setZero() 
{
    var obj = event.srcElement;
    if (obj.value == '') {
        obj.value = 0;
    }
}


// 숫자 체크
function TextBoxExScript_f_Numeric()
{
    var e = event.keyCode;

    if ((e >= 48 && e <= 57) || e == 13 || (e >= 96 && e <= 105) || e == 8 || e == 46 || e == 37 || e == 39 || e == 109 || e == 35 || e == 36 || e == 9)
    //if ((e >= 48 && e <= 57) || (e >= 96 && e <= 105) || e == 8 || e == 46 || e == 37 || e == 39 || e == 109 || e == 189 || e == 35 || e == 36 || e == 9)
        event.returnValue = true;
    else
        event.returnValue = false;
}

function TextBoxExScript_f_NotSpecialChar()
{
    var e = event.keyCode;

	event.returnValue = true;

	// 187(=), 13=엔터, 멀티텝=9
    //if ( e == 16 || e == 191 || e == 222 || e == 220 || e == 111 || e == 187)
//                        if(e == 13)
//			                event.returnValue = false;
//		                else
//			                event.returnValue = true;
}

function TextBoxExScript_f_Normal()
{
}

function TextBoxExScript_f_onKeyManage()
{
    var e = event.keyCode;
    var Obj = event.srcElement;
    if (e == 37 || e == 39) return;

    TextBoxExScript_remove_minus(Obj);
    TextBoxExScript_remove_zero(Obj);
    Obj.value = TextBoxExScript_add_comma(Obj.value);
}

function TextBoxExScript_f_onFocusManage()
{
    var Obj = event.srcElement;
    if (Obj.value == 0) {
        Obj.select();
    }
}

function TextBoxExScript_remove_minus()
{
    var Obj = event.srcElement;
    var oVal = Obj.value.replace(/,/g,'');
    var cut_idx = 0;

    if (oVal.charAt(0) == TextBoxExScript_cCal_divide )
    {
        Obj.value = TextBoxExScript_cCal_divide + Obj.value.replace(/-/g,'');
    }
    else
    {
        Obj.value = Obj.value.replace(/-/g,'');
    }
}

function TextBoxExScript_remove_zero()
{
    var Obj = event.srcElement;
    var oVal = Obj.value.replace(/,/g,'');
    var cut_idx = 0;
    var start_idx = 1;

    if (oVal.charAt(0) == TextBoxExScript_cCal_divide) start_idx = 2;

    if (oVal.length > start_idx)
    {
        for (i=start_idx-1; i<oVal.length-1; i++)
        {
            if (oVal.charAt(i) == '0') cut_idx = i+1;
            else break;
        }

        oVal = oVal.substring(cut_idx);
        Obj.value = oVal;
    }
}

function TextBoxExScript_add_comma(num)
{
    var num_amount = num;
    var fmt_amount = '';
    var minus_flag = '';

    num_amount = num_amount.replace(/,/g,'');

    if (num_amount.charAt(0) == TextBoxExScript_cCal_divide)
    {
        minus_flag = 'Y';
        num_amount = num_amount.substring(1);
    }


    if (num_amount.length > 3)
    {
        var str1 = num_amount.substring(0, num_amount.length%3);
        var str2 = num_amount.substring(num_amount.length%3, num_amount.length);

        if (str1.length != 0) str1 += ',';

        fmt_amount += str1;

        for (ikd=0; ikd<str2.length; ikd++)
        {
            if (ikd%3 == 0 && ikd != 0) fmt_amount += ',';
            fmt_amount += str2.charAt(ikd);
        }			
    }
    else
    {
        fmt_amount = num_amount;
    }

    if (minus_flag == 'Y') fmt_amount = TextBoxExScript_cCal_divide + fmt_amount;

    return fmt_amount;
}

function TextBoxExScript_Jumin(Msg)
{
	var Obj = event.srcElement;
	var num = Obj.value.replace(/,/g,'');

	var val			= 0;
	var NewValue	= '';

	if (  num.length > 6  && num.length <= 14 )
	{
		if ( num.charAt( 6 ) != '-' )
		{
			NewValue = num.substring( 0, 6 ) + '-' + num.substring( 6 );
			num = NewValue;
		} 
	}
	
	if ( num.length > 14 )	
	{
		num = num.substring( 0, 14 ); 
	}

	
	if( num.length == 14 )
	{
		var SPnum = num.split('-');
		
		check = true ;
		var val = 0;
		for (var i = 0; i <=5 ; i++)
		{
			val = val + ((i%8+2) * parseInt(SPnum[0].substring(i,i+1)));
		}
		for (var i = 6; i <=11 ; i++)
		{ 
			val = val + ((i%8+2) * parseInt(SPnum[1].substring(i-6,i-5)));
		}
		val = 11 - (val %11);
		val = val % 10;   
		if (val != SPnum[1].substring(6,7))  
			check =  false;

		if (check == false)
		{ 
			alert(Msg);
			num = ''; 
			Obj.focus();
		}
	}


	Obj.value = num;
}


function TextBoxExScript_Input_Hypen()
{
	var Obj = event.srcElement;
	var num = Obj.value.replace(/,/g,'');

	var val			= 0;
	var NewValue	= '';

	if (  num.length > 4  && num.length <= 10 )
	{
		if ( num.charAt( 4 ) != TextBoxExScript_cCal_divide )
		{
			NewValue = num.substring( 0, 4 ) + TextBoxExScript_cCal_divide + num.substring( 4 );
			num = NewValue;
		} 
	}

	if (  num.length > 7  && num.length <= 10 )
	{
		if ( num.charAt( 7 ) != TextBoxExScript_cCal_divide )
		{
			NewValue = num.substring( 0, 7 ) + TextBoxExScript_cCal_divide + num.substring( 7 );
			num = NewValue;
		} 
	}
	
	if ( num.length > 10 )	
	{
		num = num.substring( 0, 10 ); 
	}

	
	// 6번째 자리에 0이나 1이 안들어가면 그자리수 숫자를 삭제한다.
	if( num.length == 6) {
		if(!(num.charAt( 5 ) == '0' || num.charAt( 5 )== '1')) {
			num = num.substring( 0, 5 );
		}
	}

	// 9번째 자리에 0이나 1, 2, 3이 안들어가면 그자리수 숫자를 삭제한다.
	if( num.length == 9) {
		if(!(num.charAt( 8 ) == '0' || num.charAt( 8 )== '1' || num.charAt( 8 )== '2' || num.charAt( 8 )== '3')) {
			num = num.substring( 0, 8 );
		}
	}
	

	Obj.value = num;
}


function TextBoxExScript_Input_Check() 
{
	var obj = event.srcElement;
	if (obj.value.length != 10) {
		//obj.value = '';
	}
}

function TextBoxExScript_Input_Hypen_YearMonth()
{
	var Obj = event.srcElement;
	var num = Obj.value.replace(/,/g,'');

	var val			= 0;
	var NewValue	= '';

	if (  num.length > 4  && num.length <= 7 )
	{
		if ( num.charAt( 4 ) != TextBoxExScript_cCal_divide )
		{
			NewValue = num.substring( 0, 4 ) + TextBoxExScript_cCal_divide + num.substring( 4 );
			num = NewValue;
		} 
	}


	if ( num.length > 7 )	
	{
		num = num.substring( 0, 7 ); 
	}

	
	// 6번째 자리에 0이나 1이 안들어가면 그자리수 숫자를 삭제한다.
	if( num.length == 6) {
		if(!(num.charAt( 5 ) == '0' || num.charAt( 5 )== '1')) {
			num = num.substring( 0, 5 );
		}
	}



	Obj.value = num;
}

function TextBoxExScript_Input_Hypen_Zipcode()
{
	var Obj = event.srcElement;
	var num = Obj.value.replace(/,/g,'');

	var val			= 0;
	var NewValue	= '';

	if (  num.length > 3  && num.length <= 7 )
	{
		if ( num.charAt( 3 ) != TextBoxExScript_cCal_divide )
		{
			NewValue = num.substring( 0, 3 ) + '-' + num.substring( 3 );
			num = NewValue;
		} 
	}


	if ( num.length > 7 )	
	{
		num = num.substring( 0, 7 ); 
	}


	Obj.value = num;
}


// 달력 START

var target;
var pop_top;
var pop_left;
var cal_Day;
var oPopup = window.createPopup();


function Calendar_Click(e) 
{
    cal_Day = e.title;
    if (cal_Day.length > 6) {
        target.value = cal_Day
    }
    oPopup.hide();
}

function Calendar_D(obj) 
{
    var now = obj.value.split(TextBoxCalScript_cCal_divide);
    target = obj;
    pop_top = document.body.clientTop + GetObjectTop(obj) - document.body.scrollTop;
    pop_left = document.body.clientLeft + GetObjectLeft(obj) -  document.body.scrollLeft;

    if (now.length == 3) {
        Show_cal(now[0],now[1],now[2]);					
    } else {
        now = new Date();
        Show_cal(now.getFullYear(), now.getMonth()+1, now.getDate());
    }
}

                        function Calendar_D_C(obj) {
                            var now = obj.value.split(TextBoxCalScript_cCal_divide);
                            target = obj;
                            var ddd1 = screen.width/2-100/2;
                            var ddd2 = screen.height/2-200/2;
                            pop_top = screen.width/2-500;
                            pop_left = screen.height/2-200/2;

                            if (now.length == 3) {
	                            Show_cal(now[0],now[1],now[2]);					
                            } else {
	                            now = new Date();
	                            Show_cal(now.getFullYear(), now.getMonth()+1, now.getDate());
                            }
                        }

                        function Calendar_M(obj) {
                            var now = obj.value.split(TextBoxCalScript_cCal_divide);
                            target = obj;
                            pop_top = document.body.clientTop + GetObjectTop(obj) - document.body.scrollTop;
                            pop_left = document.body.clientLeft + GetObjectLeft(obj) -  document.body.scrollLeft;

                            if (now.length == 2) {
	                            Show_cal_M(now[0],now[1]);					
                            } else {
	                            now = new Date();
	                            Show_cal_M(now.getFullYear(), now.getMonth()+1);
                            }
                        }
                        
                        function doOver(el) {
                            cal_Day = el.title;

                            if (cal_Day.length > 7) {
	                            el.style.borderColor = '#FF0000';
                            }
                        }

                        function doOut(el) {
                            cal_Day = el.title;

                            if (cal_Day.length > 7) {
	                            el.style.borderColor = '#FFFFFF';
                            }
                        }

                        function day2(d) {	// 2자리 숫자료 변경
                            var str = new String();
                        	
                            if (parseInt(d) < 10) {
	                            str = '0' + parseInt(d);
                            } else {
	                            str = '' + parseInt(d);
                            }
                            return str;
                        }
                        
                        function fnChangeYearD(sYear,sMonth,sDay){
                            Show_cal(sYear, sMonth, sDay);
                        }

                        function fnChangeYearM(sYear,sMonth){
                            Show_cal_M(sYear, sMonth);
                        }

                        function fnChangeDay(iDay){
                            var sTemp = '';
                            if(iDay < 10) {
                                sTemp = '0' + iDay;
                            }
                            else {
                                sTemp = iDay;
                            }

                            return sTemp;
                        }
                        
                        function GetObjectTop(obj)
                        {
                            if (obj.offsetParent == document.body)
                                return obj.offsetTop;
                            else
                                return obj.offsetTop + GetObjectTop(obj.offsetParent);
                        }

                        function GetObjectLeft(obj)
                        {
                            if (obj.offsetParent == document.body)
                                return obj.offsetLeft;
                            else
                                return obj.offsetLeft + GetObjectLeft(obj.offsetParent);
                        }                                                                        
                        
                        
                        
            function Show_cal_M(sYear, sMonth) {
               var intThisYear = new Number(), intThisMonth = new Number();
               datToday = new Date();												// 현재 날자 설정
               intThisYear = parseInt(sYear,10);
               intThisMonth = parseInt(sMonth,10);
               if (intThisYear == 0) intThisYear = datToday.getFullYear();
               if (intThisMonth == 0) intThisMonth = parseInt(datToday.getMonth(),10)+1;	// 월 값은 실제값 보다 -1 한 값이 돼돌려 진다.
               switch(intThisMonth) {
                   case 1:                                             
                       intPrevYear = intThisYear -1;                   
                       intNextYear = intThisYear;                      
                       break;                                          
                   case 12:                                            
                       intPrevYear = intThisYear;                      
                       intNextYear = intThisYear + 1;                  
                       break;                                          
                   default:                                            
                       intPrevYear = intThisYear;                      
                       intNextYear = intThisYear;                      
                       break;                                          
               }                                                       
               intPPyear = intThisYear-1                               
               intNNyear = intThisYear+1                               
                                                                       
               Cal_HTML = '<html><head>';                              
               Cal_HTML += '</head><body>';                            
               Cal_HTML += "<table id=Cal_Table border=0 bgcolor='#f4f4f4' cellpadding=1 cellspacing=1 width=100% onmouseover='parent.doOver(window.event.srcElement)' onmouseout='parent.doOut(window.event.srcElement)' style='font-size : 12;font-family:굴림;'>";
               Cal_HTML += "<tr height='30' align=center bgcolor='#f4f4f4'>";
               Cal_HTML += "<td colspan=4 align=center>";
               Cal_HTML += "<a style='cursor:hand;' OnClick='parent.Show_cal_M("+intPPyear+","+intThisMonth+");'><img src='" + strUrlImageLeft + "' /></a>&nbsp;";
               Cal_HTML += "	<input name='selYear' readonly='readonly' size='4' style='border-top-style: none; border-right-style: none;border-left-style: none; text-align: center; border-bottom-style: none' type='text' value='" + intThisYear + "' />";
               Cal_HTML += "&nbsp;<a style='cursor:hand;' OnClick='parent.Show_cal_M("+intNNyear+","+intThisMonth+");'><img src='" + strUrlImageRight + "' /></a>";
               Cal_HTML += "</td></tr>";
               Cal_HTML += "<tr><td colspan=4 height='1' bgcolor='#000000'></td></tr>";
               Cal_HTML += "<tr height='20' align=center bgcolor=white>";
               Cal_HTML += "<td onClick=parent.Calendar_Click(this); title="+intThisYear+"-01"+" style='cursor:Hand;'>1" + Mon1 + "</td>";
               Cal_HTML += "<td onClick=parent.Calendar_Click(this); title="+intThisYear+"-02"+" style='cursor:Hand;'>2" + Mon1 + "</td>";
               Cal_HTML += "<td onClick=parent.Calendar_Click(this); title="+intThisYear+"-03"+" style='cursor:Hand;'>3" + Mon1 + "</td>";
               Cal_HTML += "<td onClick=parent.Calendar_Click(this); title="+intThisYear+"-04"+" style='cursor:Hand;'>4" + Mon1 + "</td>";
               Cal_HTML += "</tr>";
               Cal_HTML += "<tr height='20' align=center bgcolor=white>";
               Cal_HTML += "<td onClick=parent.Calendar_Click(this); title="+intThisYear+"-05"+" style='cursor:Hand;'>5" + Mon1 + "</td>";
               Cal_HTML += "<td onClick=parent.Calendar_Click(this); title="+intThisYear+"-06"+" style='cursor:Hand;'>6" + Mon1 + "</td>";
               Cal_HTML += "<td onClick=parent.Calendar_Click(this); title="+intThisYear+"-07"+" style='cursor:Hand;'>7" + Mon1 + "</td>";
               Cal_HTML += "<td onClick=parent.Calendar_Click(this); title="+intThisYear+"-08"+" style='cursor:Hand;'>8" + Mon1 + "</td>";
               Cal_HTML += "</tr>";
               Cal_HTML += "<tr height='20' align=center bgcolor=white>";
               Cal_HTML += "<td onClick=parent.Calendar_Click(this); title="+intThisYear+"-09"+" style='cursor:Hand;'>9" + Mon1 + "</td>";
               Cal_HTML += "<td onClick=parent.Calendar_Click(this); title="+intThisYear+"-10"+" style='cursor:Hand;'>10" + Mon1 + "</td>";
               Cal_HTML += "<td onClick=parent.Calendar_Click(this); title="+intThisYear+"-11"+" style='cursor:Hand;'>11" + Mon1 + "</td>";
               Cal_HTML += "<td onClick=parent.Calendar_Click(this); title="+intThisYear+"-12"+" style='cursor:Hand;'>12" + Mon1 + "</td>";
               Cal_HTML += "</tr>";
               Cal_HTML += "</table></body></html>";
               
               var oPopBody = oPopup.document.body;                                                                                                    
               oPopBody.style.backgroundColor = "lightyellow";                                                                                       
               oPopBody.style.border = "solid black 1px";                                                                                            
               oPopBody.innerHTML = Cal_HTML;                                                                                                          
               oPopup.show(pop_left, (pop_top + target.offsetHeight), 160, 99, document.body);                                                         
            }
            
            
            
                       function Show_cal(sYear, sMonth, sDay) {
                            var Months_day = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31)
                            var Month_Val = new Array('01','02','03','04','05','06','07','08','09','10','11','12');
                            var intThisYear = new Number(), intThisMonth = new Number(), intThisDay = new Number();

                            datToday = new Date();													    // 현재 날자 설정
                        	
                            intThisYear = parseInt(sYear,10);
                            intThisMonth = parseInt(sMonth,10);
                            intThisDay = parseInt(sDay,10);
                        	
                            if (intThisYear == 0) intThisYear = datToday.getFullYear();				    // 값이 없을 경우
                            if (intThisMonth == 0) intThisMonth = parseInt(datToday.getMonth(),10)+1;	// 월 값은 실제값 보다 -1 한 값이 돼돌려 진다.
                            if (intThisDay == 0) intThisDay = datToday.getDate();
                        	
                            switch(intThisMonth) {
	                            case 1:
			                            intPrevYear = intThisYear -1;
			                            intPrevMonth = 12;
			                            intNextYear = intThisYear;
			                            intNextMonth = 2;
			                            break;
	                            case 12:
			                            intPrevYear = intThisYear;
			                            intPrevMonth = 11;
			                            intNextYear = intThisYear + 1;
			                            intNextMonth = 1;
			                            break;
	                            default:
			                            intPrevYear = intThisYear;
			                            intPrevMonth = parseInt(intThisMonth,10) - 1;
			                            intNextYear = intThisYear;
			                            intNextMonth = parseInt(intThisMonth,10) + 1;
			                            break;
                            }
                            intPPyear = intThisYear-1
                            intNNyear = intThisYear+1

                            NowThisYear = datToday.getFullYear();									// 현재 년
                            NowThisMonth = datToday.getMonth()+1;									// 현재 월
                            NowThisDay = datToday.getDate();										// 현재 일
                        	
                            datFirstDay = new Date(intThisYear, intThisMonth-1, 1);			        // 현재 달의 1일로 날자 객체 생성(월은 0부터 11까지의 정수(1월부터 12월))
                            intFirstWeekday = datFirstDay.getDay();									// 현재 달 1일의 요일을 구함 (0:일요일, 1:월요일)
                            //intSecondWeekday = intFirstWeekday;
                            intThirdWeekday = intFirstWeekday;
                        	
                            datThisDay = new Date(intThisYear, intThisMonth, intThisDay);	        // 넘어온 값의 날자 생성
                            //intThisWeekday = datThisDay.getDay();									// 넘어온 날자의 주 요일
                        	
                            intPrintDay = 1;														// 달의 시작 일자
                            secondPrintDay = 1;
                            thirdPrintDay = 1;

                            Stop_Flag = 0
                        	
                            if ((intThisYear % 4)==0) {												// 4년마다 1번이면 (사로나누어 떨어지면)
	                            if ((intThisYear % 100) == 0) {
		                            if ((intThisYear % 400) == 0) {
			                            Months_day[2] = 29;
		                            }
	                            } else {
		                            Months_day[2] = 29;
	                            }
                            }
                            intLastDay = Months_day[intThisMonth];						// 마지막 일자 구함


               Cal_HTML = "<body>";
               Cal_HTML += "<form name='calendar'>";                                                                     
               Cal_HTML += "<table id=Cal_Table bgcolor='#BABABA' border=0 cellpadding=0 cellspacing=1  width='165px' height='100%' onmouseover='parent.doOver(window.event.srcElement)' onmouseout='parent.doOut(window.event.srcElement)' >";

            // 01
              Cal_HTML += "<tr bgcolor='#FFFFFF' >";
              Cal_HTML += "<td align=center valign=top> ";
              Cal_HTML += "<table border=0 cellpadding=0 cellspacing=0 width='100%'> ";
              Cal_HTML += "  <tr><td height='6px' background='" + strUrlImageTop + "'></td></tr> ";
              Cal_HTML += "  <tr><td height='6px'></td></tr> ";
              Cal_HTML += "  <tr><td align=center> ";
              Cal_HTML += "&nbsp;<a style='cursor:hand;' OnClick='parent.Show_cal("+intPrevYear+","+intPrevMonth+","+intThisDay+");'><img src='" + strUrlImageLeft + "' /></a> ";
              Cal_HTML += "	<select name='selYear' STYLE='font-size:11;' OnChange='parent.fnChangeYearD(calendar.selYear.value, calendar.selMonth.value, "+intThisDay+")';>";
              for (var optYear=Get_FirstYear; optYear<Get_LastYear; optYear++) 
              {
                  Cal_HTML += "		<option value='" + optYear + "' ";
                  if (optYear == intThisYear) Cal_HTML += " selected> ";
                  else Cal_HTML += ">";
                  Cal_HTML += optYear+"</option> ";
              }
              Cal_HTML += '	</select>';
              Cal_HTML += '&nbsp;&nbsp;';
              Cal_HTML += "<select name='selMonth' STYLE='font-size:11;' OnChange='parent.fnChangeYearD(calendar.selYear.value, calendar.selMonth.value, "+intThisDay+")';>";
              for (var i=1; i<13; i++) 
              {
                  Cal_HTML += "		<option value='"+Month_Val[i-1]+"' ";
                  if (intThisMonth == parseInt(Month_Val[i-1],10)) Cal_HTML += " selected>";
                  else Cal_HTML += ">";
                  Cal_HTML += Month_Val[i-1]+"</option>";
              }
              Cal_HTML += "	</select>&nbsp;";
              Cal_HTML += "<a style='cursor:hand;' OnClick='parent.Show_cal("+intNextYear+","+intNextMonth+","+intThisDay+");'><img src='" + strUrlImageRight + "' /></a>";
              Cal_HTML += "  </td></tr> ";
              Cal_HTML += "  <tr><td height='15px'></td></tr> ";
              Cal_HTML += "</table> ";



            // 02
               Cal_HTML += "<table border=0 cellpadding=0 cellspacing=1 width='140px' bgcolor='#F1F2E2'>";
               Cal_HTML += "<tr style='padding-top:2px;background-color:#27AECC; color:White; font-size:11px; font-family:Dotum' height=15 align=center>";
               Cal_HTML += "<td>"+Mon7+"</td><td>"+Mon1+"</td><td>"+Mon2+"</td><td>"+Mon3+"</td><td>"+Mon4+"</td><td>"+Mon5+"</td><td>"+Mon6+"</td>";
               Cal_HTML += "</tr>";




            // 주단위 루프 시작, 최대 6주 
               for (intLoopWeek=1; intLoopWeek < 7; intLoopWeek++) {	                                     
                   Cal_HTML += "<tr height='15' align=right bgcolor='white'>"                              
            // 요일단위 루프 시작, 일요일 부터
                       for (intLoopDay=1; intLoopDay <= 7; intLoopDay++) {	                                 
                           if (intThirdWeekday > 0) {                                                        
            // 첫주 시작일이 1보다 크면
                               Cal_HTML += "<td height='12px'>";                                           
                               intThirdWeekday--;                                                            
                           }                                                                                 
                           else {                                                                            
            // 입력 날짜 월말보다 크다면
                               if (thirdPrintDay > intLastDay) {								             
                                   Cal_HTML += "<td height='12px'>";                                       
                               }                                                                             
            // 입력날짜가 현재월에 해당 되면
                               else {                                                                        
                                   Cal_HTML += "<td height='12px' align=center onClick=parent.Calendar_Click(this); title="+intThisYear+TextBoxCalScript_cCal_divide+day2(intThisMonth).toString()+TextBoxCalScript_cCal_divide+day2(thirdPrintDay).toString()+" style='cursor:Hand;border:1px solid white;font-size:11px; font-family:Dotum;height:15px;padding-top:2px;background-color:#FFFFFF;";
                                   if (intThisYear == NowThisYear && intThisMonth==NowThisMonth && thirdPrintDay==intThisDay) { 
                                   Cal_HTML += "background-color:#C6F2ED;";                                                   
                               }                                                                                                


            // 공휴일 체크
                               var blResult = false;                                                                            
                               for(i=0; i< HolliyDay.length; i++) {                                                             
                                   if(HolliyDay[i] == sYear + sMonth + fnChangeDay(thirdPrintDay) ) {                           
                                       blResult = true;                                                                         
                                   }                                                                                            
                               }                                                                                                

                               if(blResult) {                                                                                   
                                   Cal_HTML += "color:red;"                                                                   
                               }                                                                                                

            // 토요일 일요일 체크
                               else {                                                                                           
                                   switch(intLoopDay) {                                                                         
                                       case 1:                                                                                  
                                           Cal_HTML += "color:red;"                                                           
                                           break;                                                                               
                                       case 7:                                                                                  
                                   	    Cal_HTML += "color:blue;"                                                             
                                   	    break;                                                                                  
                                       default:                                                                                 
                                           Cal_HTML += "color:black;"                                                         
                                           break;                                                                               
                                   }                                                                                            
                               }                                                                                                

                                   Cal_HTML += "'>"+thirdPrintDay;                                                         

                                  }                                                                                             
                                  thirdPrintDay++;                                                                              
                                  if (thirdPrintDay > intLastDay) {								                                
                                      Stop_Flag = 1;                                                                            
                                  }                                                                                             
                           }                                                                                                    
                              Cal_HTML += "</td>";                                                                            
                       }                                                                                                        
                       Cal_HTML += "</tr>";                                                                                   
                       if (Stop_Flag==1) break;                                                                                 
               }                                                                                                                

                  Cal_HTML += "</table></form></body></html>";

                  var oPopBody = oPopup.document.body;
                  oPopBody.style.border = "1px";
                  oPopBody.style.bordercolor = "#BABABA";
                  oPopBody.innerHTML = Cal_HTML;
                  //var calHeight = oPopBody.document.all.Cal_Table.offsetHeight;
                  var calHeight = 0;
                  if (calHeight == 0)	calHeight = 200;
                  else	calHeight = 200;
                  oPopup.show(pop_left, (pop_top + target.offsetHeight), 165, calHeight, document.body);
          }
                                 
