﻿//========================================================================
// Description : 플래쉬 오픈 (플래시파일 이름, 경로, 넓이, 높이, var값)
// Action Script 3.0
// 참고 : swLiveConnect -> http://namsun.fgtv.com/educenter/edu/flash4/html/10interactivity13.html#84182
//        menu -> 오른쪽 버튼사용시 메뉴 true/false
//========================================================================
function FlashOpen(FN_Src,FN_Width,FN_Height, FN_Vars){

    var FN_Vars = FN_Vars;

    document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codeBase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" WIDTH="' + FN_Width + '" HEIGHT="' + FN_Height + '" id="FlashObject" swLiveConnect="true" VIEWASTEXT>');
    document.write('<PARAM NAME=flashVars VALUE="'+ FN_Vars +'" />');
    document.write('<PARAM NAME=movie VALUE="' + FN_Src + '"> ');
    document.write('<PARAM NAME=quality VALUE=high>');
    document.write('<PARAM NAME=wmode VALUE=Transparent>');
    document.write('<PARAM NAME=menu VALUE=false />');
    document.write('<PARAM NAME=allowScriptAccess VALUE=true />');
    document.write('<PARAM NAME=bgcolor VALUE=#FFFFFF>');
    document.write('<EMBED src="' + FN_Src + '" flashVars = "'+ FN_Vars +'" quality=high bgcolor=#FFFFFF  WIDTH="' + FN_Width + '" HEIGHT="' + FN_Height + '" wmode="Transparent"  NAME="FlashObject" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>');
    document.write('</OBJECT>');
}

/***************************************************************************/
/*  Description : 팝업창 띄우기
/***************************************************************************/
function PopupWindow(url, W, H, wName, schk) {
    if (screen.width == W){
        var T = 0;
        var L = 0;
    }else{
        var L = ((screen.width) - W) / 2;
        var T = ((screen.height) - H) / 2;
    }
    var win = window.open(url+'', wName, 'width='+W+',height='+H+',top='+T+',left='+L+',resizable=no,scrollbars='+schk+'');
    win.focus();
}

/***************************************************************************/
/*  Description : 팝업 윈도우 크기 자동 조정 스케줄 팝업창에서 사용
/***************************************************************************/
function WindowResize() {    var scrollWidth, scrollHeight
    scrollWidth = parseInt(document.body.scrollWidth);
    scrollHeight = parseInt(document.body.scrollHeight);

    var divElement = document.createElement("div");
    divElement.style.position = "absolute";
    divElement.style.left = 0;
    divElement.style.top = 0;
    divElement.style.width = "100%";
    divElement.style.height = "100%";
    document.body.appendChild(divElement);

    window.resizeBy(scrollWidth-divElement.offsetWidth, scrollHeight-divElement.offsetHeight);

    document.body.removeChild(divElement);
}

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 += "%" + (oxf0 + ((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;
}
 
/*  Function Equivalent to URLDecoder.decode(String, "UTF-8")
    Copyright (C) 2002 Cresc Corp.
    Version: 1.0
*/
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 to 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;
}


/***************************************************************************/
/** Description : 파일 삭제
/***************************************************************************/
function DeleteFile(actionPage, targetName, fileName){

    if (confirm("파일을 삭제하시겠습니까?")) {
    
        document.getElementById("ModeType").value = "DELETEFILE";
        document.getElementById("targetName").value = targetName;
        document.getElementById("Del_FileName").value = fileName;
        document.getElementById("wFrm").action = actionPage;
        document.getElementById("wFrm").submit();
    }
}

/***************************************************************************/
/** Description : 체크박스 전체선택 & 선택해제
/***************************************************************************/
var chk_val = false

function ChkAll(){
    //alert(document.getElementsByName("IdxArr").length);
    if (!chk_val){
        if (document.getElementsByName("IdxArr") != null ){
            if (document.getElementsByName("IdxArr").length != null ){
                for (i = 0; i < document.getElementsByName("IdxArr").length; i++ ){
                    document.getElementsByName("IdxArr")[i].checked = true;
                }
            }else {
                document.getElementsByName("IdxArr").checked = true;
            }
        }
        chk_val = true;
    }else {
        if (document.getElementsByName("IdxArr") != null ){
            if (document.getElementsByName("IdxArr").length != null ){
                for (i = 0; i < document.getElementsByName("IdxArr").length; i++ ){
                    document.getElementsByName("IdxArr")[i].checked = false;
                }
            }else {
                document.getElementsByName("IdxArr").checked = false;
            }
        }
        chk_val = false;
    }
}


/***************************************************************************/
/** Description : 체크박스 선택 확인
/**              v1:한명 이상을 선택하세요
/**              v2:명을 선택 하셨습니다.
/**              v3:선택된 회원을 정회원으로 승인하시겠습니까?
/***************************************************************************/
function IdxPro(v1,v2,v3){
    var count = 0;
    var chk = 0;
    if (document.getElementsByName("IdxArr") != null ){
        if (document.getElementsByName("IdxArr").length != null ){
            for (i = 0; i < document.getElementsByName("IdxArr").length; i++ )
            {
                if (document.getElementsByName("IdxArr")[i].checked == true){
                    count += 1;
                    chk = i;
                }
            }
        }else {
            if (document.getElementsByName("IdxArr").checked == true){count = 1; }
        }
    }

    if (count < 1) {
        alert(v1);
        return;
    }else {
        if (confirm("총 " + count + " " + v2 + " \n" + v3)){
            document.getElementById("dFrm").submit();
        }
    }

}




//========= 주민등록번호 Check 스크립트 =========
// 사용법: ChkJumin(frm.Jumin1, frm.Jumin2) 형태로 쓰시면 됩니다.
function ChkJumin(ssn1, ssn2) {

    var chk =0;
    var yy  = ssn1.value.substring(0,2);
    var mm  = ssn1.value.substring(2,4);
    var dd  = ssn2.value.substring(4,6);
    var sex = ssn2.value.substring(0,1);

    // 주민등록번호를 자리수에 맞게 입력했는지 체크
    if (ssn2.value.split(" ").join("") == "") {
        alert ('주민등록번호를 입력하십시오.');
        ssn1.focus();
        return false;
    }
    if (ssn1.value.length!=6) {
        alert ('주민등록번호 앞자리를 입력하십시오');
        ssn1.focus();
        return false;
    }
    if (ssn2.value.length != 7 ) {
        alert ('주민등록번호 뒷자리를 입력하십시오.');
        ssn2.focus();
        return false;
    }
    if (isNaN(ssn1.value) || isNaN(ssn2.value)) {
        ssn1.value = ""
        ssn2.value = ""
        alert('주민등록번호는 숫자만 가능합니다.');
        return false;
    }
    if ((ssn1.value.length!=6)||(mm <1||mm>12||dd<1)){
        alert ('주민등록번호 앞자리가 잘못되었습니다.');
        ssn1.focus();
        return false;
    }
    if ((sex != 1 && sex !=2 && sex !=3 && sex !=4 )||(ssn2.value.length != 7 )){
        alert ('주민등록번호 뒷자리가 잘못되었습니다.');
        ssn2.focus();
        return false;
    }

    for (var i = 0; i <=5 ; i++) {
        chk = chk + ((i%8+2) * parseInt(ssn1.value.substring(i,i+1)))
    }
    for (var i = 6; i <=11 ; i++) {
        chk = chk + ((i%8+2) * parseInt(ssn2.value.substring(i-6,i-5)))
    }

    chk = 11 - (chk %11)
    chk = chk % 10

    if (chk != ssn2.value.substring(6,7)) {
        alert ('주민등록번호가 정확하지 않습니다.');
        ssn1.focus();
        return false;
    }
    
    return true;
}


function showHideMenu(target){

    if(document.getElementById(target).style.display == "none"){
        document.getElementById(target).style.display = "block";
    }else{
        document.getElementById(target).style.display = "none";
    }
}


function classChange(target, className){
    eval(document.getElementById(target)).className = className;
}


function LayerPopup(){
    var state = "off";//상태 조절을 위해

    //alert(document.body.clientHeight+"/"+document.body.scrollHeight);

    if(document.getElementById("objPopupLayerBg") == null && state == "off"){
        var obj = document.createElement("div");
        with (obj.style){
            position = "absolute";
            left    = 0;
            top     = 0;
            width   = "100%";
            height  = document.body.scrollHeight;
            backgroundColor = "#000000";
            filter  = "Alpha(Opacity=40)";
            opacity = "0.4";
        }
        obj.id = "objPopupLayerBg";
        document.body.appendChild(obj);
    }else{
        document.body.removeChild(document.getElementById("objPopupLayerBg"));
    }
}

function sitemap(){
    if(document.getElementById("sitemap").style.display == "none"){
        document.getElementById("sitemap").style.display = "block";
    }else{
        document.getElementById("sitemap").style.display = "none";
    }
    LayerPopup();
}


function setPng24(obj)
{

    if( navigator.appName.indexOf("Microsoft") > -1 ){              // 마이크로소프트 익스플로러인지 확인
        if( navigator.appVersion.indexOf("MSIE 6") > -1){
            obj.width = obj.height = 1;
            obj.className = obj.className.replace(/\bpng24\b/i,'');
            obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
            obj.src = '';
            return '';
        }
    }
}

function changePage(linkUrl, target){
    if(target == "_blank"){
        window.open(linkUrl, "_blank", "");
    }else{
        window.location.href=linkUrl;
    }
}


function Right(Str, Num){
    if (Num <= 0)
        return "";
    else if (Num > String(Str).length)
        return Str;
    else {
        var iLen = String(Str).length;
        return String(Str).substring(iLen, iLen - Num);
     }
}


function portfolioChgContents(target){
    document.getElementById("tabMenu_main").src="/images/portfolio/tab_main_off.gif";
    document.getElementById("tabMenu_project").src="/images/portfolio/tab_project_off.gif";
    document.getElementById("tabMenu_staff").src="/images/portfolio/tab_staff_off.gif";
    document.getElementById("tabMenu_actor").src="/images/portfolio/tab_actor_off.gif";
    document.getElementById("tabMenu_story").src="/images/portfolio/tab_story_off.gif";
    document.getElementById("tabMenu_photo").src="/images/portfolio/tab_photo_off.gif";

    document.getElementById("tabContents_main").style.display="none";
    document.getElementById("tabContents_project").style.display="none";
    document.getElementById("tabContents_staff").style.display="none";
    document.getElementById("tabContents_actor").style.display="none";
    document.getElementById("tabContents_story").style.display="none";
    document.getElementById("tabContents_photo").style.display="none";

    eval(document.getElementById("tabMenu_"+target)).src="/images/portfolio/tab_"+ target +"_on.gif";
    eval(document.getElementById("tabContents_"+target)).style.display="block";
}



function viewDetail(targetName, W, H){
    W = Number(W) + 54;
    H = Number(H) + 102;
    if (screen.width == W){
        var T = 0;
        var L = 0;
    }else{
        var L = ((screen.width) - W) / 2;
        var T = (((screen.height) - H) / 2) -100;
    }
    var win = window.open("/popup/pop_photo_view.asp?targetName="+targetName+"&W="+ W +"&H="+ H +" ", "_blank", "width="+W+",height="+H+",top="+ T +",left="+ L +", resizable=no,scrollbars=no");
    win.focus();
}


function privacyPop(){
    PopupWindow("/popup/pop_privacy.asp", "770", "525", "privacy", "no");
}