﻿
function gal_img_change(paramstr) {
    document.getElementById("big_gal").src = "/img/gal/2/" + paramstr;
    //alert("t");
}

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}
function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
    }
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
    }

    /*-------------------------------------------------------------------------------*/
    /* 
    한글의 경우 키 입력시 바로바로 작업이 안되기 때문에 
    onchange 와 onblur 등 이벤트도 같이 등록. 
    */

    // 한글만 입력받기 (초성체 무시) 
    // 나머지 글자 무시 
    function nr_han(this_s, type) {
        /* 
        type 
        -> 'c' : 초성 포함 
        -> 's' : 초성 포함 + 공백 포함 
        -> '' : 초성, 공백 무시 
        */
        temp_value = this_s.value.toString();
        regexp = '';
        repexp = '';
        switch (type) {
            case 'c': regexp = /[^ㄱ-ㅎ가-힣]/g; break;
            case 's': regexp = /[^ㄱ-ㅎ가-힣\s]/g; break;
            case '': regexp = /[^가-힣]/g; break;
            default: regexp = /[^ㄱ-ㅎ가-힣\s]/g;
        }
        if (regexp.test(temp_value)) {
            temp_value = temp_value.replace(regexp, repexp);
            this_s.value = temp_value;
        }
    }

    /*-------------------------------------------------------------------------------*/

    // 한글만 입력받기 (초성체 포함) 
    // 나머지 글자 무시 
    function nr_han_cho(this_s) {
        nr_han(this_s, 'c');
    }

    /*-------------------------------------------------------------------------------*/

    // 한글만 입력받기 (초성체 포함, 공백 포함) 
    // 나머지 글자 무시 
    function nr_han_cho_space(this_s) {
        nr_han(this_s, 's');
    }


    /*-------------------------------------------------------------------------------*/
    function nr_numeng(this_s) {
        temp_value = this_s.value.toString();
        regexp = /[^0-0a-zA-Z]/g;
        repexp = '';
        temp_value = temp_value.replace(regexp, repexp);
        this_s.value = temp_value;
    }

    /*-------------------------------------------------------------------------------*/
    // 나머지 글자 무시 
    function nr_num(this_s, type) {
        /* 
        type 
        -> 'int' : 양의 정수 
        -> 'float' : 양의 실수 
        -> '-int' : 음의 정수 포함 
        -> '-int' : 음의 실수 포함 
        */
        temp_value = this_s.value.toString();
        regexp = /[^-\.0-9]/g;
        repexp = '';
        temp_value = temp_value.replace(regexp, repexp);
        regexp = '';
        repexp = '';
        switch (type) {
            case 'int': regexp = /[^0-9]/g; break;
            case 'float': regexp = /^(-?)([0-9]*)(\.?)([^0-9]*)([0-9]*)([^0-9]*)/; break;
            case '-int': regexp = /^(-?)([0-9]*)([^0-9]*)([0-9]*)([^0-9]*)/; break;
            case '-float': regexp = /^(-?)([0-9]*)(\.?)([^0-9]*)([0-9]*)([^0-9]*)/; break;
            default: regexp = /[^0-9]/g; break;
        }
        switch (type) {
            case 'int': repexp = ''; break;
            case 'float': repexp = '$2$3$5'; break;
            case '-int': repexp = '$1$2$4'; break;
            case '-float': repexp = '$1$2$3$5'; break;
            default: regexp = /[^0-9]/g; break;
        }
        temp_value = temp_value.replace(regexp, repexp);
        this_s.value = temp_value;
    }
    // 양의 정수만 입력받기 
    function nr_num_int(this_s) {
        nr_num(this_s, 'int');
    }
    // 양의 실수만 입력받기 
    function nr_num_float(this_s) {
        nr_num(this_s, 'float');
    }

    /*-------------------------------------------------------------------------------*/

    // 영어+숫자만 입력받기  (대소문자) 
    // 나머지 글자 무시 
    function nr_eng(this_s, type) {
        temp_value = this_s.value.toString();
        regexp = '';
        repexp = '';
        switch (type) {
            case 'small': regexp = /[^a-z0-9]/g; break;
            case 'big': regexp = /[^A-Z0-9]/g; break;
            case 'all': regexp = /[^a-zA-Z0-9]/i; break;
            default: regexp = /[^a-z0-9]/i; break;
        }
        temp_value = temp_value.replace(regexp, repexp);
        this_s.value = temp_value;
    }

    // 영어만 입력받기  (소문자) 
    // 나머지 글자 무시 
    function nr_eng_small(this_s) {
        nr_eng(this_s, 'small');
    }

    // 영어만 입력받기  (대문자) 
    // 나머지 글자 무시 
    function nr_eng_big(this_s) {
        nr_eng(this_s, 'big');
    }
    // 전화번호 규격에 맞게 DDD-MM~M-XXXX 
    // 나머지 글자 무시 
    function nr_phone(this_s) {
        temp_value = this_s.value.toString();
        temp_value = temp_value.replace(/[^0-9]/g, '');
        temp_value = temp_value.replace(/(0(?:2|[0-9]{2}))([0-9]+)([0-9]{4}$)/, "$1-$2-$3");
        this_s.value = temp_value;
    }



    // 주민등록 번호 규격에 맞게 123456-1234567  //검증하지 않음. 
    // 나머지 글자 무시 
    function nr_jumin(this_s) {
        temp_value = this_s.value.toString();
        temp_value = temp_value.replace(/[^0-9]/g, '');
        temp_value = temp_value.substr(0, 13);
        temp_value = temp_value.replace(/([0-9]{6})([0-9]{7}$)/, "$1-$2");
        this_s.value = temp_value;
    }



    /*-------------------------------------------------------------------------------*/

    // 사업자 등록 번호 규격에 맞게 123-12-12345  //검증하지 않음. 
    // 나머지 글자 무시 
    function nr_company_num(this_s) {
        temp_value = this_s.value.toString();
        temp_value = temp_value.replace(/[^0-9]/g, '');
        temp_value = temp_value.substr(0, 10);
        temp_value = temp_value.replace(/([0-9]{3})([0-9]{2})([0-9]{5}$)/, "$1-$2-$3");
        this_s.value = temp_value;
    }

    //----------------------------------------------=-------------------------------------- 



    // JScript 파일

    function jf_openWindowRtn(url, name, resize, scroll, width, height, left, top, isCenter) {
        return jf_popupWindowEx(url, name, width, height, left, top, resize, scroll, 0);
    }
    function jf_popupWindowEx(url, name, width, height, left, top, isResizable, isScrollable, useStatus) {
        var optArray = new Array();
        var idx = 0;
        if (width) optArray[idx++] = "width=" + width;
        if (height) optArray[idx++] = "height=" + height;
        if (left) optArray[idx++] = "left=" + left;
        if (top) optArray[idx++] = "top=" + top;
        if (isResizable) optArray[idx++] = "resizable=" + isResizable;
        if (isScrollable) optArray[idx++] = "scrollbars=" + isScrollable;
        if (useStatus) optArray[idx++] = "status=" + useStatus;

        var opts = "";
        for (idx = 0; idx < optArray.length; idx++) {
            if (idx > 0)
                opts += ",";
            opts += optArray[idx];
        }

        return window.open(url, name, opts, true);
    }

    function imageView(picname) {
        win = jf_openWindowRtn('about:blank', 'imgView', 'yes', 'yes', 200, 250, 1, 1, 0);
        var strData = "";

        strData += "<html><head><title>상품 이미지</title></head><body leftmargin='0' topmargin='0' onload='resize()'>\n";
        strData += "<script language='javascript'>           		\n";
        strData += "function resize()                           \n";
        strData += "{                                           \n";
        strData += "	var p_height, p_width;                    \n";
        strData += "	p_width = document.img_view.width+50;     \n";
        strData += "	p_height = document.img_view.height+60;   \n";
        strData += "	self.resizeTo(p_width, p_height);         \n";
        strData += "}\n";
        strData += "</script>\n";
        strData += "<table width='100%' height='100%' border='0' cellspacing='0' cellpadding='0'><tr><td>";
        strData += "<table width='100%' height='100%' border='0' cellspacing='0' cellpadding='0'><tr><td bgcolor='FEFAF3' style='padding-left:10px;padding-right:10px;padding-top:10px;padding-bottom:10px;' align='center' valign='middle'><a href='javascript:window.close();'><img name='img_view' src='" + picname + "' border='0'></a></td></tr></table></tr></table>\n";
        strData += "</body></html>\n";

        win.document.write(strData);
        win.location.reload()
    }

    function checkId() {
        window.open("/etc/checkId.aspx?id=ctl00_contentHolderMain_ID", "watermallIDCheck", "width=540,height=350");
    }

    function checkZip(var1, var2) {
        window.open("/etc/zipcode.aspx?zipForm=" + var1 + "&addressForm=" + var2, "watermallZipCheck", "width=560,height=400,scrollbars=yes");
    }



/*+++++++++++++++ IT사이트 특화 함수 ++++++++++++++++++++++++++++*/


//스크립트에서 플래쉬 함수호출
var flashPlayer;

function detectFlashPlayer(paramID) {
    if (navigator.appName.indexOf("Microsoft") != -1) 
        flashPlayer = window.paramID;
    else 
        flashPlayer = window.document.paramID;
}

/*서비스 탭메뉴 스타일 바꿔주는 */
function change_class(param_var, param_obj) {
    //alert(param_obj.substr(0, 5) + param_obj.substr(7, 4));
    document.getElementById(param_obj.substr(0, 7) + "id").className = param_obj.substr(0, 5) + param_obj.substr(7, 4);
}

//모달팝업관련
function fnCheckApproval(param_Popurl) {
    document.all('master_body').className = 'body_modal_on';
    var rtnParam, sWidth, sHeight, sUrl;

    try {
        sWidth = '1005px';
        sHeight = '900px';
        sUrl = param_Popurl;

        rtnParam = new Array();
        window.showModalDialog(sUrl, rtnParam, 'dialogWidth:' + sWidth + ';dialogHeight:' + sHeight + ';scroll:no;status:no;help:no;');
        document.location.reload();
        
        if (rtnParam != null && rtnParam.length > 0)
            document.all.hdnIsApproval.value = rtnParam[0];

        if (document.all.hdnIsApproval.value == "Y" || document.all.hdnIsApproval.value == "N") {
            return true;
        }
        else {
            return false;
        }
    }
    catch (exception) {
        return false;
    }

}
