function showGuideToRegistVideo() {
    var url = "/apps/vod/register/VideoRegistGuide.jsp";
    var name = '';
    var left = 0;
    var top = 0;
    var width = 650;
    var height = 600;
    var toolbar = 0;
    var menubar = 0;
    var statusbar = 0;
    var scrollbar = 0;
    var resizable = 0;
    var location = 0;
    popup_window_common(url, name, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable, location);
}



var NS4;
var IE4;
if (document.all)
{
    IE4 = true;
    NS4 = false;
}
else
{
    IE4 = false;
    NS4 = true;
}
var isWin = (navigator.appVersion.indexOf("Win") != -1)

var agent = navigator.userAgent.toLowerCase();
var isIE = (agent.indexOf("msie") != -1) && (agent.indexOf("opera") == -1) && (agent.indexOf("webtv") == -1);

var frmMinHeight = 500;
var applyMinSize = true;
var frmMaxWidth;
var frmMaxHeight;
var applyMaxSize = false;

function setMinSize(width, height) {
    frmMinWidth = width;
    frmMinHeight = height
    applyMinSize = true;
}

function setMaxSize(width, height) {
    frmMaxWidth = width;
    frmMaxHeight = height
    applyMaxSize = true;
}

function resizeIframe(name) {
    if (name == null || name == "") {
        name = "myframeapps";
    }
    

    try {
        if (IE4) {
            var oBody   = document.frames(name).document.body;
        } else {
            var oBody = document.getElementById(name).contentDocument.body;
        }

        var oIFrame = document.getElementById(name);

        var frmWidth  = oBody.scrollWidth;
        var frmHeight = oBody.scrollHeight;

        if (applyMinSize) {
            //frmWidth  = Math.max(frmWidth, frmMinWidth);
            frmHeight = Math.max(frmHeight, frmMinHeight);
        }

        if (applyMaxSize) {
            //frmWidth  = Math.min(frmWidth, frmMaxWidth);
            frmHeight = Math.min(frmHeight, frmMaxHeight);
        }

        oIFrame.style.height = frmHeight;
        //oIFrame.style.width = frmWidth;
    } catch (e) {
    }
}

function resizeIframeCascade(s) {
    var t = s.top;
    do {
        var p = s.parent;
        if(p) {
            if(s.name != '') {
                p.resizeIframe(s.name);
            } else {
                return;
            }
        } else {
            return;
        }
        s = p;
    } while(p != t);
}

function resizeIframeS(name, mh) {
    if (name == null || name == "") {
        name = "myframeapps";
    }

    try {
        if (IE4) {
            var oBody   = document.frames(name).document.body;
        } else {
            var oBody = document.getElementById(name).contentDocument.body;
        }

        var oIFrame = document.getElementById(name);

        var frmWidth  = oBody.scrollWidth;
        var frmHeight = oBody.scrollHeight;

        frmHeight = Math.max(frmHeight, mh);

        oIFrame.style.height = frmHeight;
    } catch (e) {}
}

function parentResizeIframe(name) {
    if (parent && parent != this && parent.resizeIframe != null) {
        parent.resizeIframe(name);
    }
}

function getCookieVal(offset) {
    endstr = document.cookie.indexOf(";", offset);
    if(endstr == -1) {
        edstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset, endstr));
}

function getCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while(i < clen) {
        var j = i + alen;
        if(document.cookie.substring(i, j) == arg) {
            return getCookieVal(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;

        if(i == 0) break;
    }
    return null;
}

function setCookie(name, value) {
    var argv = setCookie.arguments;
    var argc = setCookie.arguments.length;

    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] :  null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;

    document.cookie = name + "=" + escape(value)
        + ((expires == null)?"":(";expires=" + expires.toGMTString()))
        + ((path == null)?"":(";path=" + path))
        + ((domain == null)?"":(";domain=" + domain))
        + ((secure == false)?"":";secure");
}

function deleteCookie(name) {
    var expires = new Date();
    expires.setTime(expires.getTime() - 1);
    var value = getCookie(name);
    setCookie(name, value, expires);
}


function addLoadEvent(func){
    /**
    var oldonload = window.onload;
    if(typeof window.onload != "function"){
        window.onload = func;
    }
    else{
        window.onload = function(){
            oldonload();
            func();
        }
    }

    /*/
    if (window.addEventListener) {
      window.addEventListener("load", func, false);
    } else if (window.attachEvent) {
      window.attachEvent("onload", func);
    } else {
      window.onload = func;
    }
    /**/

}



function autoBlur() {
    if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG")
    document.body.focus();
}

//document.onfocusin=autoBlur;

/*
* 기능설명 : iframe의 부모창 자동리사이징
*/
function autoResizeiFrame() {
    /**/
    parentResizeIframe(self.name);
    widnowScrollTop();
    /*/
    if (parent.document.getElementById("myframeapps")) {
          var contentfr = parent.document.getElementById("myframeapps");
          //FIREFOX
          if (contentfr.contentDocument && contentfr.contentDocument.body.offsetHeight) {
               contentfr.height = contentfr.contentDocument.body.offsetHeight+16;
        //IE
        } else if (contentfr.Document && contentfr.Document.body.scrollHeight) {
            self.resizeTo(document.body.scrollWidth , document.body.scrollHeight);
          }
     }
    /**/
}


function autoResizeiFrameS() {
    /**/
    var fnm = self.name;
    parentResizeIframe(fnm);
    /*/
    var obj;
    if(parent != null) {
        obj = parent.document.all[self.name];
        if(obj != null) {
            obj.style.pixelHeight = self.document.body.scrollHeight;
        }
    }
    /**/
}

function autoResizeOnlyiFrame() {
    /**/
    var fnm = self.name;
    parentResizeIframe(fnm);
    /*/
    var obj;
    if(parent != null) {
        obj = parent.document.all[self.name];
        if(obj != null) {
            obj.style.pixelHeight = self.document.body.scrollHeight;
        }
    }
    /**/
}


/*
* 기능설명 : 상단으로 스크롤링
* 부가설명 : IFrame내에서 페이지 이동시 페이지 위치가 중간부터 보이는 것 방지하기 위해...
*/
function windowScrollTop() {
    window.scrollTo(0,0);
}

function widnowScrollTop() {
    try { parent.scrollTo(0,0); } catch(e) {}
}


/*
* 기능설명 : 팝업
* 파라미터 : URL, 팝업이름, 왼쪽위치, 상단위치, 팝업가로사이즈, 팝업세로사이즈, 툴바, 메뉴바, 상태바, 스크롤바, 리사이징, 로케이션바
*/
function popup_window_common(url, name, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable, location) {
    toolbar_str = toolbar ? 'yes' : 'no';
    menubar_str = menubar ? 'yes' : 'no';
    statusbar_str = statusbar ? 'yes' : 'no';
    scrollbar_str = scrollbar ? 'yes' : 'no';
    resizable_str = resizable ? 'yes' : 'no';
    location_str = location ? 'yes' : 'no';
    var mdWindow = null;
    mdWindow = window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str+',location='+location_str);
    if(!mdWindow){
        alert("팝업차단을 해제해주세요.");
        return;
    }
    mdWindow.focus();
}


/*
* 기능설명 : 팝업
* 파라미터 : URL
*/
function popup_window_common2(url) {
    var mdWindow = null;
    mdWindow = window.open(url);
    if(!mdWindow){
        alert("팝업차단을 해제해주세요.");
        return false;
    }
    mdWindow.focus();
}


/*
* 로그인
* 파라미터 : 로그인/로그아웃 in,out), 타겟(_self, _parent)
*/
function login(flag, targetwindow) {

    var this_location = self.location.href;
    if (parent.myframeapps) this_location = parent.location.href;

    if (flag == 'in') {
        if(parent == null || parent == 'undefined' || parent.myframeapps == null || parent.myframeapps == 'undefined') {
            self.location.href = '/apps/login.do?doprocess=loginform&loginUrl=' + this_location;
        } else {
            parent.location.href = '/content/99.jsp?doprocess=loginform&loginUrl=' + this_location;
        }
    } else {
        if(parent == null || parent == 'undefined' || parent.myframeapps == null || parent.myframeapps == 'undefined') {
            self.location.href = '/apps/login.do?doprocess=logout';
        } else {
            parent.location.href = '/content/99.jsp?doprocess=logout';
        }
    }
}

/*
function Login(state) {
    if (state == 'out') {
        var logouturl = '/apps/login.do?doprocess=logout';
        self.location.href = logouturl;
    } else {
        var loginurl = document.location.href;

        for (i=0; i<10; i++) {
            if (loginurl.indexOf('&') > -1)
                loginurl = loginurl.replace('&','!');
            else
                break;
        }

        var loginurl = '/content_kor/login/login.jsp?loginUrl='+loginurl;
        self.location.href = loginurl;
    }
}
*/


/*
* URL 이동
* 타겟, URL
*/
function moveUrl(targetwindow, moveurl) {
    targetwindow.location.href = moveurl;
}


/*
* 기능설명 : 플래쉬 삽입
* 파라미터 : 파일경로, 가로, 세로, 아이디, 배경색, 윈도우모드
*/
function insertFlash(url, w, h, id, bg, win){
    if(w == ":SET WIDTH:" || h == ":SET HEIGHT:") {
        var flashStr=
        "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+w+"' height='"+h+"' id='"+id+"' align='middle'>"+
        "<param name='movie' value='"+url+"' />"+
        "<param name='wmode' value='"+win+"' />"+
        "<param name='menu' value='false' />"+
        "<param name='quality' value='high' />"+
        "<param name='bgcolor' value='"+bg+"' />"+
        "<embed src='"+url+"' wmode='"+win+"' menu='false' quality='high' bgcolor='"+bg+"' width='"+w+"' height='"+h+"' name='"+id+"' align='middle' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
        "</object>";
        document.write(flashStr);
    } else {
        var flashStr=
            "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+w+"' height='"+h+"' align='middle'>"+
            "<param name='movie' value='"+url+"' />"+
            "<param name='wmode' value='"+win+"' />"+
            "<param name='menu' value='false' />"+
            "<param name='quality' value='high' />"+
            "<embed src='"+url+"' wmode='"+win+"' menu='false' quality='high'  width='"+w+"' height='"+h+"' align='middle' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
            "</object>";
        document.write(flashStr);
    }

    //alert(flashStr);
}

function insertMovie(url, w, h) {
    var m_width = w;
    var m_height = h;
    var args = insertMovie.arguments;
    var argc = insertMovie.arguments.length;
    var id = "mplayer";
    if(argc > 3) {
        id = id + "_" + args[3];
    }
    mediaContent = '<object id="' + id + '" type="video/x-ms-wmv" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'+m_width+'" height="'+m_height+'">';
    mediaContent += '<param name="URL" value="' + url + '">';
    mediaContent += '<param name="autoStart" value="true">';
    mediaContent += '<param name="enablecontextmenu" value="0">';
    mediaContent += '<embed id="' + id + '" width="'+m_width+'" height="'+m_height+'" showcontrols=1 showstatusbar=1 autostart=0 playcount=0 src="' + url +'"></embed>';
    mediaContent += '</object>';

    //alert(mediaContent);
    document.write(mediaContent);
}

function insertS2MMovie(host, ip, url, w, h) {
    var m_width = w;
    var m_height = h;
    var args = insertS2MMovie.arguments;
    var argc = insertS2MMovie.arguments.length;
    var id = "mplayer";
    if(argc > 3) {
        id = id + "_" + args[5];
    }
    
	mediaContent = '<object id="'+id+'" classid="CLSID:E76AAE10-AF57-4AEA-B33D-C3EDFA414DAE" width="'+m_width+'" height="'+m_height+'" CODEBASE="http://'+host+'/cab_down/S2MPlayer.cab#version=3,2,0,6" name="S2MPlayer">';
	mediaContent += '<PARAM NAME="ServerIP" VALUE="'+ip+'">';
	mediaContent += '<PARAM NAME="UserID" VALUE="anonymous">';
	mediaContent += '<PARAM NAME="MovieFile" VALUE="'+url+'">';
	mediaContent += '<PARAM NAME="MovieTitle" VALUE="">';
	mediaContent += '<PARAM NAME="FullScreenStart" VALUE="0">'; 
	mediaContent += '<PARAM NAME="NotAutoStart" VALUE="0">';
	mediaContent += '<PARAM NAME="HideSkinControl" VALUE="0">';	
	mediaContent += '<PARAM NAME="HideSkinControl_time" VALUE="0">';
	mediaContent += '<PARAM NAME="NotFullScreen" VALUE="1">';
	mediaContent += '<PARAM NAME="NotPopupWindow" VALUE="1">';
	mediaContent += '<PARAM NAME="LogoPath" VALUE="http://'+host+'/cab_down/logo.bmp">';
	mediaContent += '</object>';

    //alert(mediaContent);
    document.write(mediaContent);
}

/*
* 기능설명 : 스크립트 삽입
* 파라미터 : 스크립트
*/
function insertScript(val){
    document.write(val);
}


/*
* 기능설명 : 텍스트 Area Validater (ajax)
* 파라미터 :     chkFrm        : 체크할 폼이름
             maxSize    : 최대값
             rtnFrm        : 현재 문자길이를 표현할 폼
*/
function countByte(chkFrm, maxSize, rtnFrm) {
    var str = chkFrm.value;
    var paramName1 = encodeURIComponent("maxSize");        // UTF-8 인코딩
    var paramValue1 = encodeURIComponent(maxSize);        // UTF-8 인코딩
    var paramName2 = encodeURIComponent("inputStr");    // UTF-8 인코딩
    var paramValue2 = encodeURIComponent(str);            // UTF-8 인코딩
    var url = '/common/etc/calculateByte.jsp?' +paramName1+ '=' +paramValue1+ '&' +paramName2+ '='+paramValue2;
    request.open("GET", url, true);
    request.onreadystatechange = function() {
        if (request.readyState == 4) {
            if (request.status == 200) {
                var response = request.responseText;
                if (rtnFrm!=null) {
                    rtnFrm.value = response;
                }
            } else {
                alert("Error: status code is " + request.status);
            }
        }
    }
    request.send(null);

    if(rtnFrm.value > maxSize) {
        chkFrm.blur();
        chkFrm.focus();
        alert("입력범위를 초과하였습니다.");
        countChar(chkFrm, maxSize, rtnFrm);
    }
}


/*
* 기능설명 : 텍스트 Area Validater
* 파라미터 :     chkFrm        : 체크할 폼이름
             maxSize    : 최대값
             rtnFrm        : 현재 문자길이를 표현할 폼
*/
function checkChar(chkfrm, chksize, rtnfrm){
    var str, msg;
    var len = 0;
    var temp;
    var count = 0;

    msg = chkfrm.value;
    str = new String(msg);
    len = str.length;

    for (k=0 ; k<len ; k++){
        temp = str.charAt(k);

        if (escape(temp).length > 4) {
            count += 3;
        } else if (temp == '\r' && str.charAt(k+1) == '\n') { // \r\n일 경우
            count += 2;
        } else if (temp != '\n') {
            count++;
        }
    }

    rtnfrm.value = count;

    if(count > chksize) {
        chkfrm.blur();
        chkfrm.focus();
        alert(chksize + "Byte 까지만 등록이 가능합니다.");
        countChar(chkfrm, chksize, rtnfrm);
    }
}


/*
* 기능설명 : 텍스트 Area Validater (문자길이 카운트)
* 파라미터 :     chkFrm        : 체크할 폼이름
             maxSize    : 최대값
             rtnFrm        : 현재 문자길이를 표현할 폼
*/
function countChar(chkfrm, chksize, rtnfrm) {
    var str,msg;
    var len=0;
    var temp;
    var count;
    count = 0;

    msg = chkfrm.value;
    str = new String(msg);
    len = str.length;

    for(k=0 ; k<len ; k++) {
        temp = str.charAt(k);

        if(escape(temp).length > 4) {
            count += 3;
        } else if (temp == '\r' && str.charAt(k+1) == '\n') { // \r\n일 경우
            count += 2;
        } else if(temp != '\n') {
            count++;
        }
        if(count > chksize) {
            str = str.substring(0,k);
            break;
        }
    }
    chkfrm.value = str;
    checkChar(chkfrm, chksize, rtnfrm);
}

// 법인번호 점검 (숫자만으로 파라미터를 받았을때)
function gf_chkCorpNo(value){
    var data = value;
    var digit = 0;
    if(data.length != 12) {
          return false;
     } else {
        sumMod   =    0;
        summode += parseInt(data.substring(0 ,1 )) * 1;
        summode += parseInt(data.substring(1 ,2 )) * 2;
        summode += parseInt(data.substring(2 ,3 )) * 1;
        summode += parseInt(data.substring(3 ,4 )) * 3;
        summode += parseInt(data.substring(4 ,5 )) * 1;
        summode += parseInt(data.substring(5 ,6 )) * 2;
        summode += parseInt(data.substring(6 ,7 )) * 1;
        summode += parseInt(data.substring(7 ,8 )) * 2;
        summode += parseInt(data.substring(8 ,9 )) * 1;
        summode += parseInt(data.substring(9 ,10)) * 2;
        summode += parseInt(data.substring(10,11)) * 1;
        summode += parseInt(data.substring(11,12)) * 2;

        digit = 10 - (summode % 10) > 9 ? 0 :  10 - (summode % 10);

        if (parseInt(data.substring(12,13)) != digit) {
            return false;
        }
     }
     return true;
}

// 재외국인 번호 체크
function checkForeignNo(fgnno) {
    var sum=0;
    var odd=0;
    buf = new Array(13);
    for(i=0; i<13; i++) { buf[i]=parseInt(fgnno.charAt(i)); }
    odd = buf[7]*10 + buf[8];
    if(odd%2 != 0) { return false; }
    if( (buf[11]!=6) && (buf[11]!=7) && (buf[11]!=8) && (buf[11]!=9) ) {
        return false;
    }
    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]); }
    sum = 11 - (sum%11);
    if(sum >= 10) { sum -= 10; }
    sum += 2;
    if(sum >= 10) { sum -= 10; }
    if(sum != buf[12]) { return false }
    return true;
}

// 주민번호 체크
function checkJuminNo(juminno) {
    if(juminno=="" || juminno==null || juminno.length!=13) {
        return false;
    }
    var jumin1 = juminno.substr(0,6);
    var jumin2 = juminno.substr(6,7);
    var yy     = jumin1.substr(0,2);    // 년도
    var mm     = jumin1.substr(2,2);    // 월
    var dd     = jumin1.substr(4,2);    // 일
    var genda  = jumin2.substr(0,1);    // 성별
    var msg, ss, cc;

    // 숫자가 아닌 것을 입력한 경우
    if (!isNumeric(jumin1)) {
        alert("주민등록번호 앞자리를 숫자로 입력하세요.");
        return false;
    }
    // 길이가 6이 아닌 경우
    if (jumin1.length != 6) {
        alert("주민등록번호 앞자리를 다시 입력하세요.");
        return false;
    }
    // 첫번째 자료에서 연월일(YYMMDD) 형식 중 기본 구성 검사
    if (yy < "00" || yy > "99" ||
        mm < "01" || mm > "12" ||
        dd < "01" || dd > "31") {
        alert("주민등록번호 앞자리를 다시 입력하세요.");
        return false;
    }
    // 숫자가 아닌 것을 입력한 경우
    if (!isNumeric(jumin2)) {
        alert("주민등록번호 뒷자리를 숫자로 입력하세요.");
        return false;
    }
    // 길이가 7이 아닌 경우
    if (jumin2.length != 7) {
        alert("주민등록번호 뒷자리를 다시 입력하세요.");
        return false;
    }
    // 성별부분이 1 ~ 4 가 아닌 경우
    if (genda < "1" || genda > "4") {
        alert("주민등록번호 뒷자리를 다시 입력하세요.");
        return false;
    }
    // 연도 계산 - 1 또는 2: 1900년대, 3 또는 4: 2000년대
    cc = (genda == "1" || genda == "2") ? "19" : "20";
    // 첫번째 자료에서 연월일(YYMMDD) 형식 중 날짜 형식 검사
    if (isYYYYMMDD(parseInt(cc+yy), parseInt(mm), parseInt(dd)) == false) {
        alert("주민등록번호 앞자리를 다시 입력하세요.");
        return false;
    }
    // Check Digit 검사
    if (!isSSN(jumin1, jumin2)) {
        alert("입력한 주민등록번호를 검토한 후, 다시 입력하세요.");
        return false;
    }
    return true;
}

// 사업자등록번호 체크
function checkBizNo(vencod) {
    var sum = 0;
    var getlist =new Array(10);
    var chkvalue =new Array("1","3","7","1","3","7","1","3","5");
    for(var i=0; i<10; i++) { getlist[i] = vencod.substring(i, i+1); }
    for(var i=0; i<9; i++) { sum += getlist[i]*chkvalue[i]; }
    sum = sum + parseInt((getlist[8]*5)/10);
    sidliy = sum % 10;
    sidchk = 0;
    if(sidliy != 0) { sidchk = 10 - sidliy; }
    else { sidchk = 0; }
    if(sidchk != getlist[9]) { return false; }
    return true;
}

function isYYYYMMDD(y, m, d) {
    switch (m) {
    case 2:    // 2월의 경우
        if (d > 29) return false;
        if (d == 29) {
            // 2월 29의 경우 당해가 윤년인지를 확인
            if ((y % 4 != 0) || (y % 100 == 0) && (y % 400 != 0))
                return false;
        }
        break;
    case 4:    // 작은 달의 경우
    case 6:
    case 9:
    case 11:
        if (d == 31) return false;
    }
    // 큰 달의 경우
    return true;
}

function isNumeric(s) {
    for (i=0; i<s.length; i++) {
        c = s.substr(i, 1);
        if (c < "0" || c > "9") return false;
    }
    return true;
}

function isLeapYear(y) {
    if (y < 100)
    y = y + 1900;
    if ( (y % 4 == 0) && (y % 100 != 0) || (y % 400 == 0) ) {
        return true;
    } else {
        return false;
    }
}

function getNumberOfDate(yy, mm) {
    month = new Array(29,31,28,31,30,31,30,31,31,30,31,30,31);
    if (mm == 2 && isLeapYear(yy)) mm = 0;
    return month[mm];
}

function isSSN(s1, s2) {
    n = 2;
    sum = 0;
    for (i=0; i<s1.length; i++)
        sum += parseInt(s1.substr(i, 1)) * n++;
    for (i=0; i<s2.length-1; i++) {
        sum += parseInt(s2.substr(i, 1)) * n++;
        if (n == 10) n = 2;
    }
    c = 11 - sum % 11;
    if (c == 11) c = 1;
    if (c == 10) c = 0;
    if (c != parseInt(s2.substr(6, 1))) return false;
    else return true;
}



/*
* 기능설명 : 카운터 수정 페이지 이동 (관리자)
* 파라미터 : cmUrl        : 이동경로
*/

if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement) {
    HTMLElement.prototype.insertAdjacentElement = function(where,parsedNode) {
        switch (where) {
        case 'beforeBegin':
            this.parentNode.insertBefore(parsedNode,this)
            break;
        case 'afterBegin':
            this.insertBefore(parsedNode,this.firstChild);
            break;
        case 'beforeEnd':
            this.appendChild(parsedNode);
            break;
        case 'afterEnd':
            if (this.nextSibling) {
                this.parentNode.insertBefore(parsedNode,this.nextSibling);
            } else {
                this.parentNode.appendChild(parsedNode);
            }
            break;
        }
    }

    HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr) {
        var r = this.ownerDocument.createRange();
        r.setStartBefore(this);
        var parsedHTML = r.createContextualFragment(htmlStr);
        this.insertAdjacentElement(where,parsedHTML)
    }

    HTMLElement.prototype.insertAdjacentText = function(where,txtStr) {
        var parsedText = document.createTextNode(txtStr)
        this.insertAdjacentElement(where,parsedText)
    }
}

// HTML을 특수문자로 변환
String.prototype.htmlChars = function() {
    var result = this.replace(result, '&', '&amp;');
    result     = this.replace(result, '<', '&lt;');
    result     = this.replace(result, '>', '&gt;');
    result     = this.replace(result, '#', '&#35;');
    result     = this.replace(result, '"', '&quot;');
    result     = this.replace(result, '\'', '&#39;');
    return result;
}

// 좌우공백 없애기
String.prototype.trim = function() { return this.replace(/(^\s+)|(\s+$)/g, ""); }

// 왼쪽공백 없애기
String.prototype.ltrim = function() { return this.replace(/^\s+/g, ""); }

// 오른쪽 공백 없애기
String.prototype.rtrim = function() { return this.replace(/\s+$/g, ""); }

String.prototype.cut = function(len, tail) {
    var str = this;
    var l = 0;
    for (var i=0; i<str.length; i++) {
        l += (str.charCodeAt(i) > 128) ? 2 : 1;
        if (l > len) return str.substring(0,i) + tail;
    }
    return str;
}

String.prototype.bytes = function() {
    var str = this;
    var l = 0;
    for (var i=0; i<str.length; i++) {
        l += (str.charCodeAt(i) > 128) ? 2 : 1;
    }
    return l;
}


// 태그만 제거
String.prototype.stripTags = function() {
    var result = this;
    var pos1 = result.indexOf('<');
    if(pos1 == -1) return result;

    var pos2 = result.indexOf('>', pos1);
    if(pos2 == -1) return result;

    return result.substr(0, pos1) + result.substr(pos2+1).stripTags();
}

String.prototype.replaceAll = function(searchStr, replaceStr) {
    var temp = this;

    while( temp.indexOf( searchStr ) != -1 ) {
        temp = temp.replace( searchStr, replaceStr );
    }
    return temp;
}

var fullURL = location.href;
var splitIndex = fullURL.indexOf('/',7);
var currentHost = "";

if(splitIndex != -1) {
    currentHost = fullURL.substring(0, splitIndex);
} else {
    currentHost = fullURL;
}

function truncateSelfHost(strValue, tURL) {
    urlRe = /([\/|\?|\||\.|\*|\^|\$|\+|\(|\)|\[|\]|\{|\}|\-])/g;
    tURL = tURL.replace(urlRe, "\\$1");

    eval("repRe = /("+tURL+")/gi");
    strValue = strValue.replace(repRe, "");
    return strValue;
}

function truncateSelfURL(strValue, tURL) {
    urlRe = /([\/|\?|\||\.|\*|\^|\$|\+|\(|\)|\[|\]|\{|\}|\-])/g;
    tURL = tURL.replace(urlRe, "\\$1");

    eval("repRe = /(<a[ ]+href=[ ]*[\"']*)("+tURL+")(#[^>]*>)/gi");
    strValue = strValue.replace(repRe, "$1$3");
    return strValue;
}

function truncateEditorURL(strValue) {
    return truncateSelfURL(strValue, currentHost+"/common/editor/editor.jsp");
}

function editorSave(strValue) {
    temp = strValue;
    temp = truncateEditorURL(temp);
    temp = truncateSelfURL(temp, fullURL);
    temp = truncateSelfHost(temp, currentHost);
    return temp;
}

// frame 안에서 F5를 눌렀을 때 메인화면으로 가는 것을 방지한다.
if (NS4) {
    document.captureEvents(Event.KEYDOWN)
    document.onkeydown = trapRefresh;
} else if (IE4) {
    document.onkeydown = trapRefresh;
}

function trapRefresh(e) {
    var event;
    if (window.event) event = window.event;
    else event = e;

    if (event.keyCode == 116) {
        if (window.event) {
            event.keyCode = 0;
        }
        event.cancelBubble = true;
        event.returnValue = false;
        document.location.reload();
    }
}

function hideStatus() {
    try {
        window.status = '';
    } catch(e) {
    }
    return true;
}

if(document.layers) {
    try { document.captureEvents(Event.mouseover | Event.mouseout); } catch(e) {}
}

try {
    document.onmouseover=hideStatus;
    document.onmouseout=hideStatus;
} catch(e) {
}

function fitWindowWithImage(imgObj) {
    var WinWidth, WinHeight, WinWidth1, WinHeight1;
    var ScrWidth, ScrHeight;
    var showScroll = false;


    WinWidth = imgObj.width;
    WinHeight = imgObj.height;

    ScrWidth = screen.availWidth;
    ScrHeight = screen.availHeight;

    if(WinWidth > ScrWidth) {
      WinWidth = ScrWidth;
      showScroll = true;
    }

    if(WinHeight > ScrHeight) {
      WinHeight = ScrHeight;
      showScroll = true;
    }

    window.resizeTo(WinWidth,WinHeight);

    if(showScroll == true) scrollbarsShow();
    else scrollbarsHide();
}

function scrollbarsHide() {
  document.body.style.overflow='hidden';
}

function scrollbarsShow() {
  document.body.style.overflow='';
}

function pause(numberMillis) {
     var now = new Date();
     var exitTime = now.getTime() + numberMillis;


     while (true) {
          now = new Date();
          if (now.getTime() > exitTime)
              return;
     }
}
