
/**¦¬¦¬ Ä¶¸°´õ °ü·ÃÇÔ¼ö ½ÃÀÛ ¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬**/

var tt_calendar_target;
var tt_calendar_pop_top;
var tt_calendar_pop_left;
var tt_calendar_day;
var tt_calendar_popup = window.createPopup();

function tt_calendar_click(e)
{
    tt_calendar_day = e.title;
    if (tt_calendar_day.length > 6)
    {
        tt_calendar_target.value = tt_calendar_day
    }
    tt_calendar_popup.hide();
}

function tt_calendar(obj)
{
    var now = obj.value.split("-");
    tt_calendar_target = obj;
    tt_calendar_pop_top = document.body.clientTop + tt_calendar_get_object_top(obj) - document.body.scrollTop;
    tt_calendar_pop_left = document.body.clientLeft + tt_calendar_get_object_left(obj) -  document.body.scrollLeft;

    if (now.length == 3) {
        tt_calendar_show(now[0],now[1],now[2]);
    } else {
        now = new Date();
        tt_calendar_show(now.getFullYear(), now.getMonth()+1, now.getDate());
    }
}

function tt_calendar_M(obj)
{
    var now = obj.value.split("-");
    tt_calendar_target = obj;
    tt_calendar_pop_top = document.body.clientTop + tt_calendar_get_object_top(obj) - document.body.scrollTop;
    tt_calendar_pop_left = document.body.clientLeft + tt_calendar_get_object_left(obj) -  document.body.scrollLeft;

    if (now.length == 2) {
        tt_calendar_show_cal_m(now[0],now[1]);
    } else {
        now = new Date();
        tt_calendar_show_cal_m(now.getFullYear(), now.getMonth()+1);
    }
}

function tt_calendar_do_over(el)
{
    tt_calendar_day = el.title;

    if (tt_calendar_day.length > 7) {
        el.style.borderColor = "#FF0000";
    }
}

function tt_calendar_do_out(el)
{
    tt_calendar_day = el.title;

    if (tt_calendar_day.length > 7) {
        el.style.borderColor = "#FFFFFF";
    }
}

function tt_calendar_day2(d)    //2ÀÚ¸® ¼ýÀÚ·Î º¯°æ
{
    var str = new String();

    if (parseInt(d) < 10) {
        str = "0" + parseInt(d);
    } else {
        str = "" + parseInt(d);
    }
    return str;
}

function tt_calendar_show(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 = "<html><body>";
    Cal_HTML += "<form name='calendar'>";
    Cal_HTML += "<table id=Cal_Table border=0 bgcolor='#f4f4f4' cellpadding=1 cellspacing=1 width=100% onmouseover='parent.tt_calendar_do_over(window.event.srcElement)' onmouseout='parent.tt_calendar_do_out(window.event.srcElement)' style='font-size : 12;font-family:±¼¸²;'>";
    Cal_HTML += "<tr height='28' align=center bgcolor='#f4f4f4'>";
    Cal_HTML += "<td colspan=7 align=center>";
    Cal_HTML += "   <select name='selYear' STYLE='font-size:11;' OnChange='parent.tt_calendar_change_year_d(calendar.selYear.value, calendar.selMonth.value, "+intThisDay+")';>";
    for (var optYear=(intThisYear-50); optYear<=(intThisYear+10); optYear++) {
        Cal_HTML += "       <option value='"+optYear+"' ";
        if (optYear == intThisYear) Cal_HTML += " selected>\n";
        else Cal_HTML += ">\n";
        Cal_HTML += optYear+"</option>\n";
    }
    Cal_HTML += "   </select>";
    Cal_HTML += "&nbsp;&nbsp;&nbsp;<a style='cursor:hand;' OnClick='parent.tt_calendar_show("+intPrevYear+","+intPrevMonth+","+intThisDay+");'>¢¸</a> ";
    Cal_HTML += "<select name='selMonth' STYLE='font-size:11;' OnChange='parent.tt_calendar_change_year_d(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>\n";
        else Cal_HTML += ">\n";
        Cal_HTML += Month_Val[i-1]+"</option>\n";
    }
    Cal_HTML += "   </select>&nbsp;";
    Cal_HTML += "<a style='cursor:hand;' OnClick='parent.tt_calendar_show("+intNextYear+","+intNextMonth+","+intThisDay+");'>¢º</a>";
    Cal_HTML += "</td></tr>";
    Cal_HTML += "<tr align=center bgcolor='#87B3D6' style='color:#2065DA;' height='25'>";
    Cal_HTML += "   <td style='padding-top:3px;' width='24'><font color=black>ÀÏ</font></td>";
    Cal_HTML += "   <td style='padding-top:3px;' width='24'><font color=black>¿ù</font></td>";
    Cal_HTML += "   <td style='padding-top:3px;' width='24'><font color=black>È­</font></td>";
    Cal_HTML += "   <td style='padding-top:3px;' width='24'><font color=black>¼ö</font></td>";
    Cal_HTML += "   <td style='padding-top:3px;' width='24'><font color=black>¸ñ</font></td>";
    Cal_HTML += "   <td style='padding-top:3px;' width='24'><font color=black>±Ý</font></td>";
    Cal_HTML += "   <td style='padding-top:3px;' width='24'><font color=black>Åä</font></td>";
    Cal_HTML += "</tr>";

    for (intLoopWeek=1; intLoopWeek < 7; intLoopWeek++) {   // ÁÖ´ÜÀ§ ·çÇÁ ½ÃÀÛ, ÃÖ´ë 6ÁÖ
        Cal_HTML += "<tr height='24' align=right bgcolor='white'>"
        for (intLoopDay=1; intLoopDay <= 7; intLoopDay++) { // ¿äÀÏ´ÜÀ§ ·çÇÁ ½ÃÀÛ, ÀÏ¿äÀÏ ºÎÅÍ
            if (intThirdWeekday > 0) {                                          // Ã¹ÁÖ ½ÃÀÛÀÏÀÌ 1º¸´Ù Å©¸é
                Cal_HTML += "<td>";
                intThirdWeekday--;
            } else {
                if (thirdPrintDay > intLastDay) {                               // ÀÔ·Â ³¯Â¦ ¿ù¸»º¸´Ù Å©´Ù¸é
                    Cal_HTML += "<td>";
                } else {                                                                // ÀÔ·Â³¯Â¥°¡ ÇöÀç¿ù¿¡ ÇØ´ç µÇ¸é
                    Cal_HTML += "<td onClick=parent.tt_calendar_click(this); title="+intThisYear+"-"+tt_calendar_day2(intThisMonth).toString()+"-"+tt_calendar_day2(thirdPrintDay).toString()+" style=\"cursor:Hand;border:1px solid white;";
                    if (intThisYear == NowThisYear && intThisMonth==NowThisMonth && thirdPrintDay==intThisDay) {
                        Cal_HTML += "background-color:#C6F2ED;";
                    }

                    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 = tt_calendar_popup.document.body;
    oPopBody.style.backgroundColor = "lightyellow";
    oPopBody.style.border = "solid black 1px";
    oPopBody.innerHTML = Cal_HTML;

    var calHeight = oPopBody.document.all.Cal_Table.offsetHeight;
    //ÇàÀÌ 6°³ ÇàÀÎÁö, 5°³ÀÎÁö ±¸ºÐ
    if (intLoopWeek == 6)   calHeight = 214;
    else    calHeight = 189;

    tt_calendar_popup.show(tt_calendar_pop_left, (tt_calendar_pop_top + tt_calendar_target.offsetHeight), 170, calHeight, document.body);
}

function tt_calendar_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>\n";
    Cal_HTML += "</head><body>\n";
    Cal_HTML += "<table id=Cal_Table border=0 bgcolor='#f4f4f4' cellpadding=1 cellspacing=1 width=100% onmouseover='parent.tt_calendar_do_over(window.event.srcElement)' onmouseout='parent.tt_calendar_do_out(window.event.srcElement)' style='font-size : 12;font-family:±¼¸²;'>\n";
    Cal_HTML += "<tr height='30' align=center bgcolor='#f4f4f4'>\n";
    Cal_HTML += "<td colspan='4' align='center'>\n";
    Cal_HTML += "<a style='cursor:hand;' OnClick='parent.tt_calendar_show_cal_m("+intPPyear+","+intThisMonth+");'>¢¸</a>&nbsp;";
    Cal_HTML += "<select name='selYear' STYLE='font-size:11;' OnChange='parent.tt_calendar_change_year_m(this.value, "+intThisMonth+")';>";
    for (var optYear=(intThisYear-2); optYear<(intThisYear+2); optYear++) {
            Cal_HTML += "       <option value='"+optYear+"' ";
            if (optYear == intThisYear) Cal_HTML += " selected>\n";
            else Cal_HTML += ">\n";
            Cal_HTML += optYear+"</option>\n";
    }
    Cal_HTML += "   </select>\n";
    Cal_HTML += "<a style='cursor:hand;' OnClick='parent.tt_calendar_show_cal_m("+intNNyear+","+intThisMonth+");'>¢º</a>";
    Cal_HTML += "</td></tr>\n";
    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.tt_calendar_click(this); title="+intThisYear+"-01"+" style=\"cursor:Hand;\">1¿ù</td>";
    Cal_HTML += "<td onClick=parent.tt_calendar_click(this); title="+intThisYear+"-02"+" style=\"cursor:Hand;\">2¿ù</td>";
    Cal_HTML += "<td onClick=parent.tt_calendar_click(this); title="+intThisYear+"-03"+" style=\"cursor:Hand;\">3¿ù</td>";
    Cal_HTML += "<td onClick=parent.tt_calendar_click(this); title="+intThisYear+"-04"+" style=\"cursor:Hand;\">4¿ù</td>";
    Cal_HTML += "</tr>\n";
    Cal_HTML += "<tr height='20' align=center bgcolor=white>";
    Cal_HTML += "<td onClick=parent.tt_calendar_click(this); title="+intThisYear+"-05"+" style=\"cursor:Hand;\">5¿ù</td>";
    Cal_HTML += "<td onClick=parent.tt_calendar_click(this); title="+intThisYear+"-06"+" style=\"cursor:Hand;\">6¿ù</td>";
    Cal_HTML += "<td onClick=parent.tt_calendar_click(this); title="+intThisYear+"-07"+" style=\"cursor:Hand;\">7¿ù</td>";
    Cal_HTML += "<td onClick=parent.tt_calendar_click(this); title="+intThisYear+"-08"+" style=\"cursor:Hand;\">8¿ù</td>";
    Cal_HTML += "</tr>\n";
    Cal_HTML += "<tr height='20' align=center bgcolor=white>";
    Cal_HTML += "<td onClick=parent.tt_calendar_click(this); title="+intThisYear+"-09"+" style=\"cursor:Hand;\">9¿ù</td>";
    Cal_HTML += "<td onClick=parent.tt_calendar_click(this); title="+intThisYear+"-10"+" style=\"cursor:Hand;\">10¿ù</td>";
    Cal_HTML += "<td onClick=parent.tt_calendar_click(this); title="+intThisYear+"-11"+" style=\"cursor:Hand;\">11¿ù</td>";
    Cal_HTML += "<td onClick=parent.tt_calendar_click(this); title="+intThisYear+"-12"+" style=\"cursor:Hand;\">12¿ù</td>";
    Cal_HTML += "</tr>\n";
    Cal_HTML += "</table>\n</body></html>";

    var oPopBody = tt_calendar_popup.document.body;
    oPopBody.style.backgroundColor = "lightyellow";
    oPopBody.style.border = "solid black 1px";
    oPopBody.innerHTML = Cal_HTML;

    tt_calendar_popup.show(tt_calendar_pop_left, (tt_calendar_pop_top + tt_calendar_target.offsetHeight), 160, 99, document.body);
}

//ÀÏ´Þ·Â ³âµµ¸®½ºÆ®¿¡¼­ ³âµµ ¼±ÅÃ
function tt_calendar_change_year_d(sYear,sMonth,sDay)
{
    tt_calendar_show(sYear, sMonth, sDay);
}

//¿ù´Þ·Â ³âµµ¸®½ºÆ®¿¡¼­ ³âµµ ¼±ÅÃ
function tt_calendar_change_year_m(sYear,sMonth)
{
    tt_calendar_show_cal_m(sYear, sMonth);
}

function tt_calendar_get_object_top(obj)
{
    if (obj.offsetParent == document.body)
        return obj.offsetTop;
    else
        return obj.offsetTop + tt_calendar_get_object_top(obj.offsetParent);
}

function tt_calendar_get_object_left(obj)
{
    if (obj.offsetParent == document.body)
        return obj.offsetLeft;
    else
        return obj.offsetLeft + tt_calendar_get_object_left(obj.offsetParent);
}

/**¦¬¦¬ Ä¶¸°´õ °ü·ÃÇÔ¼ö Á¾·á ¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬**/

function tt_format_number(num)
{
	num=new String(num);
	num=num.replace(/,/gi,"");

	var sign="";
	if(isNaN(num))
	{
		alert("¼ýÀÚ¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù.");
		return 0;
	}

	if(num==0)
		return num;

	if(num<0)
	{
		num=num*(-1);
		sign="-";
	}
	else
		num=num*1;

	num = new String(num)
	var temp="";
	var pos=3;
	num_len=num.length;
	while (num_len>0)
	{
		num_len=num_len-pos;
		if(num_len<0)
		{
			pos=num_len+pos;
			num_len=0;
		}
		temp=","+num.substr(num_len,pos)+temp;
	}

	return sign+temp.substr(1);
}

/** ³¯Â¥°ü·Ã ÇÔ¼ö : ½ÃÀÛ ***************************************************************************************************/

function tt_date_text2time(timeString)          //Time ½ºÆ®¸µÀ» ÀÚ¹Ù½ºÅ©¸³Æ® Date °´Ã¼·Î º¯È¯
{                                               //Parameter time: Time Çü½ÄÀÇ String (°íÁ¤Æø ³â¿ùÀÏ½ÃºÐÃÊ)
    var chkPattern = /-/g;                      //ex) 2005-01-02 ¶Ç´Â 20050102 : '-' »ç¿ëÀº ÆíÇÑ´ë·Î
    var chkString  = timeString.replace(chkPattern, "")

    var chkYear  = chkString.substr(0,4);
    var chkMonth = chkString.substr(4,2) - 1;   // 1¿ù=0,12¿ù=11
    var chkDay   = chkString.substr(6,2);

    return new Date(chkYear, chkMonth, chkDay);
}

function tt_date_time2text(chkDate)             //Date °´Ã¼¸¦ TimeString(ex 2005-01-02)·Î º¯°æ
{
    var chkYear  = chkDate.getFullYear();
    var chkMonth = chkDate.getMonth() + 1;      //1¿ù=0,12¿ù=11ÀÌ¹Ç·Î 1 ´õÇÔ
    var chkDay   = chkDate.getDate();

    if (("" + chkMonth).length == 1) { chkMonth = "0" + chkMonth; }
    if (("" + chkDay).length   == 1) { chkDay   = "0" + chkDay;   }

    return (chkYear + "-" + chkMonth + "-" + chkDay)
}

function tt_date_add(chkString, yy, mo, dd)     //¹®ÀÚ¿­ ¹Þ¾Æ¼­ ¹®ÀÚ¿­·Î ¹ÝÈ¯
{                                               //ex) 2007-01-01 + 2°³¿ù => 2007-03-01
    if (typeof(yy) == "undefined") yy=0;
    if (typeof(mo) == "undefined") mo=0;
    if (typeof(dd) == "undefined") dd=0;

    var date = tt_date_text2time(chkString);

    date.setFullYear(date.getFullYear() + yy);  //yy³âÀ» ´õÇÔ
    date.setMonth(date.getMonth()       + mo);  //mo¿ùÀ» ´õÇÔ
    date.setDate(date.getDate()         + dd);  //ddÀÏÀ» ´õÇÔ

    return tt_date_time2text(date);
}

function tt_date_term_month(time1, time2)       //measureMonthInterval(time1,time2)
{                                               //µÎ TimeÀÌ ¸î °³¿ù Â÷ÀÌ³ª´ÂÁö ±¸ÇÔ
    var date1 = tt_date_text2time(time1);
    var date2 = tt_date_text2time(time2);

    var years  = date2.getFullYear() - date1.getFullYear();
    var months = date2.getMonth() - date1.getMonth();
    var days   = date2.getDate() - date1.getDate();

    return (years * 12 + months + (days >= 0 ? 0 : -1) );
}

/** ³¯Â¥°ü·Ã ÇÔ¼ö : Á¾·á ***************************************************************************************************/

/** ¹®ÀÚ¿­ ÇÔ¼ö ½ÃÀÛ *****************************************************************************/
String.prototype.tt_trim=function()
{
    var str=this.replace(/(\s+$)/g,"");
    return str.replace(/(^\s*)/g,"");
}
/** ¹®ÀÚ¿­ ÇÔ¼ö Á¾·á *****************************************************************************/

function tt_radio_is_checked(tt_focus, tt_element)
{
    var is_checked = false;

    if (typeof(tt_element.length) == "undefined")  // °°Àº ÀÌ¸§ÀÇ Radio, Checkbox °¡ 1°³ÀÏ °æ¿ì
    {
        if (tt_element.checked)
            is_checked = true;

        if (tt_focus && !is_checked && !tt_element.readOnly && !tt_element.disabled)
            tt_element.focus();
    }
    else                                            // °°Àº ÀÌ¸§ÀÇ Radio, Checkbox °¡ 2°³ ÀÌ»óÀÏ °æ¿ì
    {
        for (i=0; i<tt_element.length; i++)
        {
            if (tt_element[i].checked)
                is_checked = true;
        }

        if (tt_focus && !is_checked && !tt_element[0].readOnly && !tt_element.disabled)
            tt_element[0].focus();
    }

    return is_checked;
}

function tt_radio_checked_value(tt_element)
{
    var checked_value = "";

    if (typeof(tt_element.length) == "undefined")  // °°Àº ÀÌ¸§ÀÇ Radio °¡ 1°³ÀÏ °æ¿ì
    {
        if (tt_element.checked)
            checked_value = tt_element.value;
    }
    else                                        // °°Àº ÀÌ¸§ÀÇ Radio °¡ 2°³ ÀÌ»óÀÏ °æ¿ì
    {
        for (i=0; i<tt_element.length; i++)
        {
            if (tt_element[i].checked)
                checked_value = tt_element[i].value;
        }
    }

    return checked_value;
}

function tt_checkbox_count(tt_element, tt_condition)
{
   /********************************************
    * tt_element   : °°Àº name À» »ç¿ëÇÏ´Â Ã¼Å©¹Ú½º
    * tt_condition : Á¶°Ç
        - all       : ÀüÃ¼ °¹¼ö
        - checked   : ¼±ÅÃÇÑ Ã¼Å©¹Ú½º °¹¼ö
        - unchecked : ¼±ÅÃÇÏÁö ¾ÊÀº Ã¼Å©¹Ú½º °¹¼ö
    ********************************************/

    if (tt_condition!="all" && tt_condition!="checked" && tt_condition!="unchecked")
    {
        alert("Àß¸øµÈ Á¢±ÙÀÔ´Ï´Ù.")
        return false;
    }

    var countAll       = 0;
    var countChecked   = 0;
    var countUnChecked = 0;

    if (typeof(tt_element.length) == "undefined")   // °°Àº ÀÌ¸§ÀÇ Checkbox °¡ 1°³ÀÏ °æ¿ì
    {
        countAll=1;

        if (tt_element.checked)
            countChecked = 1;
    }
    else                                            // °°Àº ÀÌ¸§ÀÇ Checkbox °¡ 2°³ ÀÌ»óÀÏ °æ¿ì
    {
        countAll = tt_element.length;

        for (i=0; i<tt_element.length; i++)
        {
            if (tt_element[i].checked)
                countChecked = countChecked + 1;
        }
    }

    countUnChecked = countAll - countChecked;

    switch (tt_condition)
    {
        case "all"       : return countAll;       break;
        case "checked"   : return countChecked;   break;
        case "unchecked" : return countUnChecked; break;
    }
}

function tt_checkbox_check(tt_target, tt_checked)
{
    var tt_status;

    if(tt_checked=="auto")
    {
        if(tt_checkbox_count(tt_target, "unchecked") > 0)
            tt_status=true;     //¼±ÅÃµÇÁö ¾ÊÀº°Ô 1°³¶óµµ ÀÖÀ» °æ¿ì ÀüºÎ ¼±ÅÃ
        else
            tt_status=false;    // ¸ðµÎ ¼±ÅÃµÇ¾úÀ» °æ¿ì ÀüºÎ ÇØÁ¦
    }
    else if(tt_checked===true || tt_checked===false)    // true³ª false ÀÏ °æ¿ì ¸ðµÎ ¼±ÅÃ ¶Ç´Â ÇØÁ¦
        tt_status=tt_checked;

    if (tt_target.length==1)
        tt_target.checked=tt_status;
    else
    {
        for (i=0; i<tt_target.length; i++)
            tt_target[i].checked=tt_status;
    }

    return tt_status;
}

function tt_select_is_empty(tt_focus, tt_element)
{
    if ((tt_element.options[tt_element.selectedIndex].value.tt_trim() == "") || (tt_element.options[tt_element.selectedIndex].value.tt_trim().length <= 0))
    {
        if (tt_focus && !tt_element.disabled)
            tt_element.focus();

       	return true;
    }
    else
        return false;
}

function tt_select_selected_value(tt_element)
{
    return tt_element.options[tt_element.selectedIndex].value.tt_trim();
}

function tt_select_selected_text(tt_element)
{
    return tt_element.options[tt_element.selectedIndex].text.tt_trim();
}

//±Ý¾×°è»ê
function book_price_basis(chkIssueDate)
{
    if (tt_date_term_month("2007-02", chkIssueDate) > 0)
        return 10000;
    else
        return 13000;
}
