/*var COM_MSG_00003 = "은(는) 최대";
var COM_MSG_00004 = "Bytes까지 쓸수 있습니다.";
var COM_MSG_00004 = "현재";
var COM_MSG_00004 = "Bytes를 사용하였습니다.";*/

/* 숫자만 입력 가능하게 함
 * onkeypress 이벤트에 적용 : ime-mode를 반드시 disabled로 설정해야 함.
 * 예) style="ime-mode:disabled" onkeypress="onlyNumber()"
 */
function onlyNumber()
{
    if( window.event.keyCode >= 48 && window.event.keyCode <= 57) {
    } else {
        window.event.keyCode = "";
    }
}

/*
 * 숫자 1~5까지만 입력 가능하게 함
 */
function onlyNumber2()
{
    if( window.event.keyCode >= 48 && window.event.keyCode <= 53) {
    } else {
        window.event.keyCode = "";
    }
}

/* 필수 항목 입력 여부 체크
 * 예) if(requiredField(frm.are_code, "지역코드")) return;
 */
function requiredField(obj, msg){
    if(obj.value.replace(/[ ]/g, "") == ""){
        alert(msg);
        if(obj.select != null) obj.select();
        obj.focus();
        return true;;
    }
    return false;
}

/* 입력 텍스트의 바이트 수 체크
 * 예) if(!check_msglen(frm.htl_comid, 15, "공급업체 상품코드")) return;
 */
function check_msglen(obj, maxlen, msg)
{
    var length = calculate_msglen(obj.value);
    if (length > maxlen) {
        //alert("[" + objName + "]" + COM_MSG_00003 + " " + maxlen + " " + COM_MSG_00003 + "\n" + COM_MSG_00004 + " " + length + " " + COM_MSG_00005);
        alert(msg + " [Now : " + length + "]");
        //obj.select();
        obj.focus();
        return false;
    }
    return true;
}

/* 입력 텍스트의 바이트 수 계산하기
 * 예) var len = calculate_msglen(obj.value);
 */
function calculate_msglen(message)
{
    var nbytes = 0;

    for (i=0; i<message.length; i++) {
        var ch = message.charAt(i);
        if(escape(ch).length > 4) {
            nbytes += 2;
        } else if (ch == '\n') {
            if (message.charAt(i-1) != '\r') {
                nbytes += 1;
            }
        } else if (ch == '<' || ch == '>') {
            nbytes += 4;
        } else {
            nbytes += 1;
        }
    }

    return nbytes;
}

/*
 * Iframe 리사이징
 */
var n=navigator.appName;
var ie=(n=='Microsoft Internet Explorer');
var opera=(n=='Opera');
function calcHeight(name) {
	if (ie) {
		//find the height of the internal page
		var the_height = parent.document.getElementById(name).contentWindow.document.body.scrollHeight + 50;

		//change the height of the iframe
		parent.document.getElementById(name).height = the_height;
	} else {
		parent.document.getElementById(name).height = 0;

		//find the height of the internal page
		var the_height = parent.document.getElementById(name).contentWindow.document.documentElement.scrollHeight + 50;

		//change the height of the iframe
		parent.document.getElementById(name).height = the_height;
	}

	if (parent.document.getElementById("wrap_bg")) {
		parent.document.getElementById("wrap_bg").style.height = parent.document.getElementById("wrap_hol").clientHeight + 50;
	}
}

/*
 * 스크립트, 메타테그, 스타일테그 사용 막기
 */
function noScript(obj,msg) {
	if (obj.value || obj.value == "") {
		var str = obj.value;
	} else {
		var str = obj;
	}

	if (str != "") {
		str = str.toLowerCase();
		if (str.indexOf("<script") > -1) {
			alert("<script " + msg);
			return false;
		} else if (str.indexOf("<meta") > -1) {
			alert("<meta " + msg);
			return false;
		} else if (str.indexOf("<style") > -1) {
			alert("<style " + msg);
			return false;
		} else if (str.indexOf("<!--") > -1 || str.indexOf("-->") > -1) {
			alert("<!-- -->(주석) " + msg);
			return false;
		} else if (str.indexOf("<![cdata") > -1) {
			alert("<![CDATA " + msg);
			return false;
		} else if (str.indexOf("<html") > -1 || str.indexOf("</html") > -1) {
			alert("<html " + msg);
			return false;
		} else if (str.indexOf("<head") > -1 || str.indexOf("</head") > -1) {
			alert("<head " + msg);
			return false;
		} else if (str.indexOf("<title") > -1 || str.indexOf("</title") > -1) {
			alert("<title " + msg);
			return false;
		} else if (str.indexOf("<form") > -1 || str.indexOf("</form") > -1) {
			alert("<form " + msg);
			return false;
		}
	}
	
    return true;
}

/*
 * 특수문자 배제체크
 */
function Check_nonChar(id_text, chr, msg)
{
    var nonchar = "";

    if (chr == "") {
        nonchar = '~`!@#$%^&*()-_=+\|<>?,./;:"' + "'";
    } else if (chr == "1") {
        nonchar = '~`!@#$%^&*()-=+\|<>?./;:"' + "'";
	} else if (chr == "2") {
        nonchar = '~`!@#$%^&*()-=+\|<>?,./;:"' + "' ";
    } else {
        nonchar = chr;
    }

    var nonkorean = nonchar;

    var i ;
    for ( i=0; i < id_text.length; i++ )  {
        if( nonkorean.indexOf(id_text.substring(i,i+1)) >= 0) {
            if (nonkorean.indexOf(" ") >= 0) {
                alert(msg + " [" + nonchar + "공백]");
            } else {
                alert(msg + " [" + nonchar + "]");
            }
            return true;
            break ;
        }
    }
    return false;
}

/*
 * 날짜 콤보박스
 */
function ChangeOptionDays(frm,Which)
{
    DaysObject = eval(frm + "." + Which + "Day");
    MonthObject = eval(frm + "." + Which + "Month");
    YearObject = eval(frm + "." + Which + "Year");

    Month = MonthObject[MonthObject.selectedIndex].text;
    Year = YearObject[YearObject.selectedIndex].text;

    DaysForThisSelection = DaysInMonth(Month, Year);
    CurrentDaysInSelection = DaysObject.length;
    if (CurrentDaysInSelection > DaysForThisSelection)
    {
        for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
        {
            DaysObject.options[DaysObject.options.length - 1] = null
        }
    }
    if (DaysForThisSelection > CurrentDaysInSelection)
    {
        for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
        {
            NewOption = new Option(DaysObject.options.length + 1,DaysObject.options.length + 1);
            DaysObject.add(NewOption);
        }
    }
    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;

    return true;
}

function DaysInMonth(WhichMonth, WhichYear)
{
    var DaysInMonth = 31;
    if (WhichMonth == "4" || WhichMonth == "6" || WhichMonth == "9" || WhichMonth == "11") DaysInMonth = 30;
    if (WhichMonth == "2" && (WhichYear/4) != Math.floor(WhichYear/4))    DaysInMonth = 28;
    if (WhichMonth == "2" && (WhichYear/4) == Math.floor(WhichYear/4))    DaysInMonth = 29;
    return DaysInMonth;
}

/*
 * 시작날짜와 종료날짜 체크
 */
function chkDate(flag,frm) {
    var frm_year  = frm.FirstYear.value;
    var frm_month = frm.FirstMonth.value;
    var frm_date  = frm.FirstDay.value;

    if( !IsNumeric(frm_year)  || !IsNumeric(frm_month) || !IsNumeric(frm_date)  || (Number(frm_month) < 1 || Number(frm_month) > 12 ) )
    {
        alert("날짜입력 형식이 잘못되었거나 달력에 없는 날짜입니다.");
        return false;
    }

    montharray=new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); 

    var maxdays = (frm_month != 2) ? montharray[frm_month-1] : (( frm_year%4==0 && frm_year%100 !=0 || frm_year%400 ==0 ) ? 29:28 );

    if( Number(frm_date) < 1 || Number(frm_date) > maxdays )
    {
        alert("날짜입력 형식이 잘못되었거나 달력에 없는 날짜입니다.");
        return false;
    }

    //두번째 일자도 있으면..
    if( flag != null && flag == "2"){
       var to_year      = frm.SecondYear.value;
       var to_month      = frm.SecondMonth.value;
       var to_date    = frm.SecondDay.value;

        if( !IsNumeric(to_year)  ||
            !IsNumeric(to_month) ||
            !IsNumeric(to_date)  ||
            (Number(to_month) < 1 || Number(to_month) > 12 ) )
        {
            alert("날짜입력 형식이 잘못되었거나 달력에 없는 날짜입니다.");
            return false;
        }

        maxdays = (to_month != 2) ? montharray[to_month-1] : (( frm_year%4==0 && frm_year%100 !=0 || frm_year%400 ==0 ) ? 29:28 );

        if( Number(to_date) < 1 || Number(to_date) > maxdays )
        {
            alert("날짜입력 형식이 잘못되었거나 달력에 없는 날짜입니다.");
            return false;
        }

       // 기간 확인
       var selfrmDate = new Date(Number(from_year),Number(from_month)-1,Number(from_date));
       var selToDate = new Date(Number(to_year),Number(to_month)-1,Number(to_date));
       
       if ( (selToDate - selFromDate) < 0  )  {
          alert ("종료일이 시작일 보다 더 빠른 날짜 입니다.");
          return false;
       }
    }
}

/*
 * 숫자여부 체크
 */
function IsNumeric(value)
    {
        var ch, ch2=1;

        for ( k = 0; k < value.length; k++ )
        {
            ch = value.charAt(k);
            if ( ch < '0' || ch > '9' )
            {
                return (false);
            }
        }
        return (true);
    }

/*
 * 현재날짜 (2008-01-01)
 */
function NowDate()
{
    var now_month = "";
    var now_day = "";
    var rtn = "";

    Now = new Date();
    NowDay = Now.getDate();
    NowMonth = Now.getMonth();
    NowYear = Now.getYear();

    if (NowMonth < 10) {
        now_month = "0" + NowMonth;
    } else {
        now_month = NowMonth;
    }

    if (NowDay < 10) {
        now_day = "0" + NowDay;
    } else {
        now_day = NowDay;
    }

    rtn = NowYear + "-" + now_month + "-" + now_day;
    return rtn;
}

/*
 * 모달창(showModalDialog)
 */
function openModal(fileName,windowName,theWidth,theHeight,etcParam) {
    var objNewWin;
    var x = theWidth;
    var y = theHeight;
    try {
        var sy = window.screen.height / 2 - y / 2 - 70;
        if (etcParam == 'fix') {
            etcParam = "toolbar:no; location:no; directories:no; status:yes; menubar:no; scrollbars:yes; resizable:no; help:no; edge:sunken";
            var sy = window.screen.height / 2 - y / 2 - 40;
        }

        var sx = window.screen.width / 2 - x / 2;

        if (sy < 0) {
            sy = 0;
        }

        var sz = "; top=" + sy + "; left=" + sx;

        if (windowName == "newWindow") {
            windowName = new String(Math.round(Math.random() * 100000));
        }

        var vRetval = window.showModalDialog(fileName, windowName, etcParam + "; dialogWidth:" + x + "px; dialogHeight:" + y + "px" + sz);

        return vRetval;
    }
    catch(ex) {
        //alert("창 오픈 중 에러발생[" + ex.message + "][" + ex.name + "][" + ex.number + "][" + ex.description + "]");
        return 'err';
    }
}

/*
 * 팝업창 중간에 띄우기
 */
function openWindow(theURL,winName,myWidth, myHeight, isCenter) { //v3.0
    if(window.screen)if(isCenter)if(isCenter=="true"){
        var myLeft = (screen.width-myWidth)/2;
        var myTop = (screen.height-myHeight)/2;

        style= "'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, width=" + myWidth + ",height=" + myHeight + ",top=" + myTop +",left=" + myLeft + "'";
    }
    window.open(theURL,winName,style);
}

/*
 * 주민번호 체크
 */
function JuminCheck(jumin1,jumin2) {
	var resno=jumin1 + "-" + jumin2;
	
	// 주민번호의 형태와 7번째 자리(성별) 유효성 검사
	fmt = /^\d{6}-[1234]\d{6}$/;
	if (!fmt.test(resno)) {
		return false;
	}

	// 날짜 유효성 검사
	var birthYear = (resno.charAt(7) <= "2") ? "19" : "20";
	if (!isDate(birthYear+jumin1))
	{
		return false;
	}

	// Check Sum 코드의 유효성 검사
	buf = new Array(13);
	for (i = 0; i < 6; i++) buf[i] = parseInt(resno.charAt(i));
	for (i = 6; i < 13; i++) buf[i] = parseInt(resno.charAt(i + 1));

	multipliers = [2,3,4,5,6,7,8,9,2,3,4,5];
	for (i = 0, sum = 0; i < 12; i++) sum += (buf[i] *= multipliers[i]);

	if ((11 - (sum % 11)) % 10 != buf[12]) {
		return false;
	}
	return true;
}

function isDate(dt){
	var birthYear = dt.substr(0, 4);
	var birthMonth = dt.substr(4, 2) - 1;
	var birthDate = dt.substr(6, 2);
	var birth = new Date(birthYear, birthMonth, birthDate);

	if ( birth.getYear() % 100 != birthYear.substr(2, 2) || birth.getMonth() != birthMonth || birth.getDate() != birthDate) {
		return false;
	}
	return true;
}

/*
 * 선택된 메뉴에 스타일 주기(B0119)
 */
function menuStyleSelected(target,menuNum) {
    for (var i=1; i<=7; i++) {
        if (eval(target+".document").getElementById("menu"+i)) {
            if (menuNum == "menu"+i) {
                //eval(target+".document").getElementById("menu"+i).className = "menuon";
            } else {
                //eval(target+".document").getElementById("menu"+i).className = "menuoff";
            }
        } else {
            break;
        }
    }
}

/*
 * 구조스킨 Main 영역 스타일 변경
 */
function skinBodyStyle(id,bgColor,bordColor) {
    var url = document.URL;
	
	if (url.indexOf("/PI") != -1 && bgColor != ""){
		parent.document.getElementById("bodyCss").style.background = "#" + bgColor;
        parent.document.getElementById("bodyCss").style.border = "1px solid #" + bordColor;
	} else {
		parent.document.getElementById("bodyCss").style.background = "#ffffff";
        parent.document.getElementById("bodyCss").style.border = "1px solid #E2E2E2";
	}
}

/*
 * CheckStrLength()
 * 입력 텍스트의 바이트 수 체크해서 input에 넣기
 * 예) CheckStrLength(frm.textarea, 200, frm.inputname, "공급업체 상품코드")
 */
function CheckStrLength(frm,msglen,vfrm,msg)
{
	var temp;
	var f = frm.value.length;
	var tmpstr = "";
	var enter = 0;
	var strlen;

	// 초기 최대길이를 텍스트 박스에 뿌려준다.
	if(f == 0){
		if (vfrm || vfrm != "") {
			vfrm.value = msglen;
		}
		
	} else {
		for(k=0;k<f;k++)
		{
			temp = frm.value.charAt(k);

			if(temp == '\n')// 입력 라인 제한을 위해 엔터키 횟수 증가
			{
				enter++;
			}
			if(escape(temp).length > 4){
				msglen -= 2;
			} else {
				msglen--;
			}
			if(msglen < 0)
			{
				alert(msg);
				frm.value = tmpstr;
				break;
			} else if(enter > 4) {
				alert("라인수 5라인을 넘을수 없습니다.");
				enter = 0;
				strlen = tmpstr.length - 1;
				//alert(strlen);
				frm.value = tmpstr.substring(0,strlen);
				break;
			} else {
				if (vfrm || vfrm != "") {
					vfrm.value = msglen;
				}
				tmpstr += temp;
			}
		}
	}
}

/*
 * 레이어 팝업
 */
function layerWindow(url,divWidth,divHeight) {
    var tg = "";
    var x = divWidth;
    var y = divHeight;

	if (parent.document.getElementById("divLayer2"))
	{
		tg = "parent";
	} else {
		tg = "self";
	}

    eval(tg).document.body.scroll = "no";
    eval(tg).document.getElementById("divLayer2").style.width = divWidth + "px";
    eval(tg).document.getElementById("divLayer2").style.height = divHeight + "px";

    var sy = window.screen.height / 2 - y / 2 - 70;
    var sx = window.screen.width / 2 - x / 2;

    if (sy < 0) {
        sy = 0;
    }

    eval(tg).document.getElementById("divLayer2").style.top = sy + "px";
    eval(tg).document.getElementById("divLayer2").style.left = sx + "px";

    eval(tg).document.getElementById("divLayer").style.display = "block";
    eval(tg).diviFrmLogin.document.write("<body bgcolor='#666666' oncontextmenu='return false' ondragstart='return false' onselectstart='return false'></body>");
    eval(tg).document.getElementById("divLayer2").style.display = "block";

    eval(tg).diviFrmLogin2.document.location.replace(url);
}

/*
 * IFRAME 안에서 레이어 팝업
 */
function layerWindow2(url,divWidth,divHeight) {
    var tg = "self";
    var x = 238;
    var y = 158;

    eval(tg).document.body.scroll = "no";
    eval(tg).document.getElementById("divLayer2").style.width = divWidth;
    eval(tg).document.getElementById("divLayer2").style.height = divHeight;

    var sy = 500 / 2 - y / 2 - 70;
    var sx = parent.document.getElementById("ifrm1").width / 2 - x / 2;

    if (sy < 0) {
        sy = 0;
    }

    eval(tg).document.getElementById("divLayer2").style.top = sy + "px";
    eval(tg).document.getElementById("divLayer2").style.left = sx + "px";

    eval(tg).document.getElementById("divLayer").style.display = "block";
    eval(tg).diviFrmLogin.document.write("<body bgcolor='#666666' oncontextmenu='return false' ondragstart='return false' onselectstart='return false'></body>");

    eval(tg).document.getElementById("divLayer2").style.display = "block";
    eval(tg).diviFrmLogin2.document.location.replace(url);
}

/*
 * 레이어 팝업
 */
function layerWindow3(url,divWidth,divHeight) {
    var tg = "";
    var x = divWidth;
    var y = divHeight;

	if (parent.document.getElementById("divLayer2"))
	{
		tg = "parent";
	} else {
		tg = "self";
	}

    eval(tg).document.body.scroll = "no";
    eval(tg).document.getElementById("divLayer2").style.width = divWidth + "px";
    eval(tg).document.getElementById("divLayer2").style.height = divHeight + "px";

    var sy = (window.screen.height / 2 - y / 2 - 70) - 100;
    var sx = (window.screen.width / 2 - x / 2) - 100;

    if (sy < 0) {
        sy = 0;
    }

    eval(tg).document.getElementById("divLayer2").style.top = sy + "px";
    eval(tg).document.getElementById("divLayer2").style.left = sx + "px";
    eval(tg).document.getElementById("divLayer2").style.display = "block";

    eval(tg).diviFrmLogin2.document.location.replace(url);
}

/*
 * 레이어창 닫기
 */
function layerWindowClose(tg) {
	if (tg) {
		tg = "self";
	} else {
		tg = "parent";
	}

    eval(tg).document.body.scroll = "yes";
    eval(tg).document.getElementById("divLayer2").style.width = 0;
    eval(tg).document.getElementById("divLayer2").style.height = 0;
    eval(tg).document.getElementById("divLayer2").style.top = 0;
    eval(tg).document.getElementById("divLayer2").style.left = 0;

    eval(tg).document.getElementById("divLayer").style.display = "none";
    eval(tg).document.getElementById("divLayer2").style.display = "none";
	//eval(tg).diviFrmLogin2.document.location.replace(url);
}

function layerWindowClose2(tg) {
	if (tg) {
		tg = "self";
	} else {
		tg = "parent";
	}

    //eval(tg).document.body.scroll = "yes";
    eval(tg).document.getElementById("divLayer2").style.width = 0;
    eval(tg).document.getElementById("divLayer2").style.height = 0;
    eval(tg).document.getElementById("divLayer2").style.top = 0;
    eval(tg).document.getElementById("divLayer2").style.left = 0;

    eval(tg).document.getElementById("divLayer").style.display = "none";
    eval(tg).document.getElementById("divLayer2").style.display = "none";
	//eval(tg).diviFrmLogin2.document.location.replace(url);
}

/*
 * 레이어 팝업 (모달창 대용)
 */
function opnWinLayer01(url,divWidth,divHeight,tg) {
    var x = divWidth;
    var y = divHeight;

    eval(tg).document.getElementById("divLayer").style.height = parent.document.body.scrollHeight;

    //eval(tg).document.body.style.overflow = "hidden";

    eval(tg).document.getElementById("opnWinLayer01").style.width = divWidth + 10;
    eval(tg).document.getElementById("opnWinLayer01").style.height = divHeight + 34;
    eval(tg).document.getElementById("opnWinDt02").style.width = divWidth;
    eval(tg).document.getElementById("opnWinDt05").style.width = divWidth;
    eval(tg).document.getElementById("opnWinDt08").style.width = divWidth;
    eval(tg).document.getElementById("opnWinDt04").style.height = divHeight;
    eval(tg).document.getElementById("opnWinDt05").style.height = divHeight;
    eval(tg).document.getElementById("opnWinDt06").style.height = divHeight;

    var sy =((window.screen.height / 2 - y / 2 - 70) - 31) + eval(tg).document.body.scrollTop;
    var sx = window.screen.width / 2 - x / 2;

    if (sy < 0) {
        sy = 0;
    }

    eval(tg).document.getElementById("opnWinLayer01").style.top = sy;
    eval(tg).document.getElementById("opnWinLayer01").style.left = sx;

    parent.document.getElementById("divLayer").style.display = "block";
    eval(tg).diviFrmLogin.document.write("<body bgcolor='#666666' oncontextmenu='return false' ondragstart='return false' onselectstart='return false'></body>");

    eval(tg).document.getElementById("opnWinLayer01").style.display = "block";
    eval(tg).document.getElementById("opnWinCloseBtn").innerHTML = "<a href=\"javascript:opnWinLayerClose01('"+tg+"')\"><img id=\"closebtn\" src=\"../images/kr/main/win_close_btn.gif\" style=\"margin-top:5px;\"></a>";
    eval(tg).opnWinIfrm01.document.location.replace(url);
}

/*
 * 레이어창 닫기 (모달창 대용)
 */
function opnWinLayerClose01(tg) {
    //eval(tg).document.body.style.overflow = "auto";
    eval(tg).document.getElementById("opnWinLayer01").style.width = 0;
    eval(tg).document.getElementById("opnWinLayer01").style.height = 0;
    eval(tg).document.getElementById("opnWinLayer01").style.top = 0;
    eval(tg).document.getElementById("opnWinLayer01").style.left = 0;

    eval(tg).document.getElementById("divLayer").style.display = "none";
    eval(tg).document.getElementById("opnWinLayer01").style.display = "none";
	eval(tg).opnWinIfrm01.document.location.replace("../jsp/win_close.html");
}

/*
 문자열을 인코딩 할때 사용한다. 다음과 같이 디코딩 하여 사용한다.
 JAVA : URLEncoder.decode(str, "UTF-8")
 JS : decodeURL(str)
*/
function encodeURL(str){
    var s0, i, s, u;
    s0 = "";                // encoded str
    for (i = 0; i < str.length; i++){   // scan the source
        s = str.charAt(i);
        u = str.charCodeAt(i);          // get unicode of the char
        if (s == " "){s0 += "+";}       // SP should be converted to "+"
        else {
            if ( u == 0x2a || u == 0x2d || u == 0x2e || u == 0x5f || ((u >= 0x30) && (u <= 0x39)) || ((u >= 0x41) && (u <= 0x5a)) || ((u >= 0x61) && (u <= 0x7a))){       // check for escape
                s0 = s0 + s;            // don't escape
            }
            else {                  // escape
                if ((u >= 0x0) && (u <= 0x7f)){     // single byte format
                    s = "0"+u.toString(16);
                    s0 += "%"+ s.substr(s.length-2);
                }
                else if (u > 0x1fffff){     // quaternary byte format (extended)
                    s0 += "%" + (0xf0 + ((u & 0x1c0000) >> 18)).toString(16);
                    s0 += "%" + (0x80 + ((u & 0x3f000) >> 12)).toString(16);
                    s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                }
                else if (u > 0x7ff){        // triple byte format
                    s0 += "%" + (0xe0 + ((u & 0xf000) >> 12)).toString(16);
                    s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                }
                else {                      // double byte format
                    s0 += "%" + (0xc0 + ((u & 0x7c0) >> 6)).toString(16);
                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                }
            }
        }
    }
    return s0;
}

/*
 문자열을 디코딩 할때 사용한다. 다음과 같이 인코딩 하여 사용한다.
 JAVA : URLEncoder.encode(str, "UTF-8")
 JS : encodeURL(str)
*/
function decodeURL(str)
{
    var s0, i, j, s, ss, u, n, f;
    s0 = "";                // decoded str
    for (i = 0; i < str.length; i++){   // scan the source str
        s = str.charAt(i);
        if (s == "+"){s0 += " ";}       // "+" should be changed to SP
        else {
            if (s != "%"){s0 += s;}     // add an unescaped char
            else{               // escape sequence decoding
                u = 0;          // unicode of the character
                f = 1;          // escape flag, zero means end of this sequence
                while (true) {
                    ss = "";        // local str to parse as int
                        for (j = 0; j < 2; j++ ) {  // get two maximum hex characters for parse
                            sss = str.charAt(++i);
                            if (((sss >= "0") && (sss <= "9")) || ((sss >= "a") && (sss <= "f"))  || ((sss >= "A") && (sss <= "F"))) {
                                ss += sss;      // if hex, add the hex character
                            } else {--i; break;}    // not a hex char., exit the loop
                        }
                    n = parseInt(ss, 16);           // parse the hex str as byte
                    if (n <= 0x7f){u = n; f = 1;}   // single byte format
                    if ((n >= 0xc0) && (n <= 0xdf)){u = n & 0x1f; f = 2;}   // double byte format
                    if ((n >= 0xe0) && (n <= 0xef)){u = n & 0x0f; f = 3;}   // triple byte format
                    if ((n >= 0xf0) && (n <= 0xf7)){u = n & 0x07; f = 4;}   // quaternary byte format (extended)
                    if ((n >= 0x80) && (n <= 0xbf)){u = (u << 6) + (n & 0x3f); --f;}         // not a first, shift and add 6 lower bits
                    if (f <= 1){break;}         // end of the utf byte sequence
                    if (str.charAt(i + 1) == "%"){ i++ ;}                   // test for the next shift byte
                    else {break;}                   // abnormal, format error
                }
            s0 += String.fromCharCode(u);           // add the escaped character
            }
        }
    }
    return s0;
}

/*
 * 해당 문자열 찾아내 replace 한다.
 */
function replaceAll(str, searchStr, replaceStr) {
    while (str.indexOf(searchStr) != -1) {
        str = str.replace(searchStr, replaceStr);
    }
    return str;
}

/*
 * 퀵메뉴
 */
function clickMenu(pth,id) {
    var cnts = "<a href=\"javascript:;\" onclick=\"sendMailPopCm('"+pth+"','"+id+"');\">메일보내기</a><br>" +
               "<a href=\"javascript:;\" onclick=\"sendMsgPopCm('"+pth+"','"+id+"');\">쪽지보내기</a><br>" +
               "<a href=\"javascript:;\" onclick=\"goMemberInfo('"+pth+"','"+id+"');\">회원정보보기</a><br>";
    clickMu.innerHTML = cnts;
 
    var menu=document.all.mytable;
	menu.style.display="";
    menu.style.left=event.x+document.body.scrollLeft-5;
    menu.style.top=event.y+document.body.scrollTop;
    return false;
}

/*
 * 쪽지 팝업
 */
function sendMsgPopCm(pth,recvId){
    var rtnVal = openModal(pth+"AI058_SP_012.do?ntRecvId="+recvId,"winClosure",436,490,"toolbar:no; location:no; directories:no; status:false; menubar:no; scroll:0; resizable:no; help:no; edge:sunken");
    if (typeof(rtnVal) == "undefined") {
        return;
    } else {
    }
}

/*
 * 메일 팝업
 */
function sendMailPopCm(pth,recvEml){
    var rtnVal = openModal(pth+"AI058_SP_013.do?recvId="+recvEml,"winClosure",436,490,"toolbar:no; location:no; directories:no; status:false; menubar:no; scroll:0; resizable:no; help:no; edge:sunken");
    if (typeof(rtnVal) == "undefined") {
        return;
    } else {
    }
}

/*
 * 회원 정보
 */
function goMemberInfo(pth,mbrId){
    openModal(pth+"AI059_VP_007.do?cafeMbrId="+mbrId,"winClosure",502,400,"toolbar:no; location:no; directories:no; status:false; menubar:no; scroll:0; resizable:no; help:no; edge:sunken");
}

/*
 * 공백없에기(trim 함수)
 * 	^ - 처음시작(beginning of line)
 *	\s - 공백(whitespace character)
 * $ - 끝라인(end of line)
 */
function trim(str) {  
    return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');      
}  


/*
function scrollTop() {
	top.document.body.scrollTop = 0;
}
*/
    
    
