/*--------------------------------------------------------------------------------*\
*  User Function
\*--------------------------------------------------------------------------------*/

//var zoomRate = 10;
//var maxRate = 200;
//var minRate = 80;
//var curRate = 100;

// a 태그 엔터키 먹기
$(function() {
    $('a').keypress(function(e) {
        if (e.keyCode == 13 || e.which == 13) {
            
            if ($(this).attr('href') == 'javascript:;' || $(this).attr('class') == 'fancybox iframe') {
                $(this).click();
                return false;
            }
            else {
                $(this).click();
                if ($(this).attr('target') == '_blank') window.open($(this).attr('href'));
                else location.href = $(this).attr('href');
                return false;
            }
        }
    });
});

// 쿠키설정
function setCookie(key, value, term) {
    var expire = new Date();
    expire.setDate(expire.getDate() + term);
    document.cookie = key + "=" + escape(value) + "; path=/; expires=" + expire.toGMTString() + ";";
}

function getCookie(name) {
    var cookiename = name + "=";
    var x = 0;
    while (x <= document.cookie.length) {
        var y = (x + cookiename.length);
        if (document.cookie.substring(x, y) == cookiename) {
            if ((endOfCookie = document.cookie.indexOf(";", y)) == -1)
                endOfCookie = document.cookie.length;
            return unescape(document.cookie.substring(y, endOfCookie));
        }
        x = document.cookie.indexOf(" ", x) + 1;

        if (x == 0) break;
    }
    return "";
}

// 화면확대 / 축소
function PageZoom(type) {
    if (((type == "in") && (curRate >= maxRate)) || ((type == "out") && (curRate <= minRate))) {
        return;   /* 범위 초과시 리턴한다 */
    }

    if (type == "in") {
        curRate = (-(-(curRate))) + (-(-(zoomRate)));
    }
    else if (type == "out") {
        curRate = (-(-(curRate))) - (-(-(zoomRate)));
    }
    else {
        if (getCookie("zoomVal") != null && getCookie("zoomVal") != "") {
            curRate = getCookie("zoomVal");

            if (!((curRate >= minRate) & (curRate <= maxRate))) {
                curRate = 100;
            }
        }
        else {
            curRate = 100;
        }
    }

    document.body.style.zoom = curRate + '%';
    setCookie("zoomVal", curRate, 1);
}

//-----------------------------------------------------------------------------
// 체크박스 선택된 값 가져오기
// @return : String
// 사용법 : $getCheckBox('체크박스네임', 'index' or 'value')
// note : index = 체크박스인덱스 번호, value = 체크박스 값
//-----------------------------------------------------------------------------

function $getCheckBox(name, rtnValue, checktype) {
    tmp = new Array()
    chks = $("input[name$='" + name + "']:checked");
    chks.each(function(index, elem) {
        if (chks[index].checked == true) {
            if (rtnValue == "index") {
                tmp.push(index);
            }
            else {
                tmp.push(chks[index].value);
            }
        }
    });
    return tmp;
}

/*--------------------------------------------------------------------------------*\
*  String prototype
\*--------------------------------------------------------------------------------*/

//-----------------------------------------------------------------------------
// 문자의 좌, 우 공백 제거
// @return : String
//-----------------------------------------------------------------------------

String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

//-----------------------------------------------------------------------------
// 문자의 좌 공백 제거
// @return : String
//-----------------------------------------------------------------------------

String.prototype.ltrim = function() {
    return this.replace(/(^\s*)/, "");
}

//-----------------------------------------------------------------------------
// 문자의 우 공백 제거
// @return : String
//-----------------------------------------------------------------------------

String.prototype.rtrim = function() {
    return this.replace(/(\s*$)/, "");
}

//-----------------------------------------------------------------------------
// 지정된길이만큼 문자열 잘라내기
// @return : String
//-----------------------------------------------------------------------------
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;
}

//-----------------------------------------------------------------------------
// 문자열의 byte 길이 반환
// @return : int
//-----------------------------------------------------------------------------

String.prototype.byte = function() {
    var cnt = 0;
    for (var i = 0; i < this.length; i++) {
        if (this.charCodeAt(i) > 127)
            cnt += 2;
        else
            cnt++;
    }
    return cnt;
}

//-----------------------------------------------------------------------------
// 정수형으로 변환
// @return : String
//-----------------------------------------------------------------------------

String.prototype.int = function() {
    if (!isNaN(this)) {
        return parseInt(this);
    }
    else {
        return null;
    }
}

//-----------------------------------------------------------------------------
// 숫자만 가져 오기
// @return : String
//-----------------------------------------------------------------------------

String.prototype.num = function() {
    return (this.trim().replace(/[^0-9]/g, ""));
}

//-----------------------------------------------------------------------------
// 숫자만 가져 오기(실수형)
// @return : String
//-----------------------------------------------------------------------------

String.prototype.float = function() {
    return parseFloat(this.trim().replace(/[^0-9|^\.]/g, ""));
}

//-----------------------------------------------------------------------------
// 영문자만 가져 오기
// @return : String
//-----------------------------------------------------------------------------

String.prototype.abc = function() {
    return this.trim().replace(/[^a-zA-Z]/g, "");
}

//-----------------------------------------------------------------------------
// 숫자에 3자리마다 , 를 찍어서 반환
// @return : String
//-----------------------------------------------------------------------------
String.prototype.money = function() {
    var arrnum = this.trim().split(".");

    while ((/(-?[0-9]+)([0-9]{3})/).test(arrnum[0])) {
        arrnum[0] = arrnum[0].replace((/(-?[0-9]+)([0-9]{3})/), "$1,$2");
    }
    return arrnum.join(".");
}

//-----------------------------------------------------------------------------
// 숫자의 자리수(cnt)에 맞도록 반환
// @return : String
//-----------------------------------------------------------------------------

String.prototype.digits = function(cnt) {
    var digit = "";
    if (this.length < cnt) {
        for (var i = 0; i < cnt - this.length; i++) {
            digit += "0";
        }
    }
    return digit + this;
}


//------------ 지정한 소숫점에서 반올림 ----------------------
String.prototype.deciround = function(cipher) {
    var num = this.trim();
    var cipstr = "";

    for (var i = 0; i < cipher; i++) {
        cipstr += "0";
    }
    cipstr = parseInt("1" + cipstr);

    num = (Math.round(num * cipstr)) / cipstr;

    return num;
}

//-----------------------------------------------------------------------------
// " -> &#34; ' -> &#39;로 바꾸어서 반환
// @return : String
//-----------------------------------------------------------------------------

String.prototype.quota = function() {
    return this.replace(/"/g, "&#34;").replace(/'/g, "&#39;");
}

//-----------------------------------------------------------------------------
// 파일 확장자만 가져오기
// @return : String
//-----------------------------------------------------------------------------

String.prototype.ext = function() {
    return (this.indexOf(".") < 0) ? "" : this.substring(this.lastIndexOf(".") + 1, this.length);
}

//-----------------------------------------------------------------------------
// URL에서 파라메터 제거한 순수한 url 얻기
// @return : String
//-----------------------------------------------------------------------------    

String.prototype.uri = function() {
    var arr = this.split("?");
    arr = arr[0].split("#");
    return arr[0];
}

//-----------------------------------------------------------------------------
// URL에서 url 제거한 순수한 파라메터 얻기
// @return : String
//-----------------------------------------------------------------------------    

String.prototype.queryString = function() {
    var arr = this.split("?");
    arr.splice(0, 1);
    return arr.join("?");
}

//-----------------------------------------------------------------------------
// 특정문자로 자른후 원하는 배열값 가져오기
// @return : String
//-----------------------------------------------------------------------------    

String.prototype.specString = function(spliter, arrnum) {
    var arr = this.split(spliter);
    return arr[arrnum];
}

/*---------------------------------------------------------------------------------*\
*  각종 체크 함수들
\*---------------------------------------------------------------------------------*/

//-----------------------------------------------------------------------------
// 특수문자 포함여부
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.chrlimit = function() {
    var m_Sp = /[$\!\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|\;\:\"\'\,\.\<\>\/\?\ ]/;
    var strLen = this.length;
    var m_char, Isresult
    for (var i = 0; i < strLen; i++) {
        m_char = this.charAt(i);
        if (m_char.search(m_Sp) != -1) {
            Isresult = true;
            break;
        }
        else {
            Isresult = false;
        }
    }

    return Isresult;
}


//-----------------------------------------------------------------------------
// 정규식에 쓰이는 특수문자를 찾아서 이스케이프 한다.
// @return : String
//-----------------------------------------------------------------------------

String.prototype.meta = function() {
    var str = this;
    var result = ""

    for (var i = 0; i < str.length; i++) {
        if ((/([\$\(\)\*\+\.\[\]\?\\\^\{\}\|]{1})/).test(str.charAt(i))) {
            result += str.charAt(i).replace((/([\$\(\)\*\+\.\[\]\?\\\^\{\}\|]{1})/), "\\$1");
        }
        else {
            result += str.charAt(i);
        }
    }
    return result;
}

//-----------------------------------------------------------------------------
// 정규식에 쓰이는 특수문자를 찾아서 이스케이프 한다.
// @return : String
//-----------------------------------------------------------------------------

String.prototype.remove = function(pattern) {
    return (pattern == null) ? this : eval("this.replace(/[" + pattern.meta() + "]/g, \"\")");
}

//---------- 태그 제거 함수 -----------------------------
String.prototype.stripTags = function() {
    var str = this;
    var pos1 = str.indexOf('<');


    if (pos1 == -1) {
        return str.replace(/&nbsp;/g, "").trim();
    }
    else {
        var pos2 = str.indexOf('>', pos1);
        if (pos2 == -1) return str;
        return (str.substr(0, pos1) + str.substr(pos2 + 1)).stripTags().replace(/&nbsp;/g, "").trim();
    }
}

//-----------------------------------------------------------------------------
// 최소 최대 길이인지 검증
// str.isLength(min [,max])
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.isLength = function() {
    var min = arguments[0];
    var max = arguments[1] ? arguments[1] : null;
    var success = true;

    if (this.length < min) {
        success = false;
    }
    if (max && this.length > max) {
        success = false;
    }
    return success;
}

//-----------------------------------------------------------------------------
// 최소 최대 바이트인지 검증
// str.isByteLength(min [,max])
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.isByteLength = function() {
    var min = arguments[0];
    var max = arguments[1] ? arguments[1] : null;
    var success = true;

    if (this.byte() < min) {
        success = false;
    }
    if (max && this.byte() > max) {
        success = false;
    }
    return success;
}

//-----------------------------------------------------------------------------
// 공백이나 널인지 확인
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.isBlank = function() {
    var str = this.trim();
    for (var i = 0; i < str.length; i++) {
        if ((str.charAt(i) != "\t") && (str.charAt(i) != "\n") && (str.charAt(i) != "\r")) {
            return false;
        }
    }
    return true;
}

//-----------------------------------------------------------------------------
// 숫자로 구성되어 있는지 학인
// arguments[0] : 허용할 문자셋
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.isNum = function() {
    return (/^[0-9]+$/).test(this.remove(arguments[0])) ? true : false;
}

//-----------------------------------------------------------------------------
// 영어만 허용 - arguments[0] : 추가 허용할 문자들
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.isEng = function() {
    return (/^[a-zA-Z]+$/).test(this.remove(arguments[0])) ? true : false;
}

//-----------------------------------------------------------------------------
// 숫자와 영어만 허용 - arguments[0] : 추가 허용할 문자들
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.isEngNum = function() {
    return (/^[0-9a-zA-Z]+$/).test(this.remove(arguments[0])) ? true : false;
}

//-----------------------------------------------------------------------------
// 숫자와 영어만 허용 - arguments[0] : 추가 허용할 문자들
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.isNumEng = function() {
    return this.isEngNum(arguments[0]);
}

//-----------------------------------------------------------------------------
// 영어/숫자 와 특수문자 조합 허용 - arguments[0] : 추가 허용할 문자들
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.isEngNumAndSpc = function() {
    return (/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/).test(this.remove(arguments[0])) ? true : false;
}

//-----------------------------------------------------------------------------
// 아이디 체크 영어와 숫자만 체크 첫글자는 영어로 시작 - arguments[0] : 추가 허용할 문자들
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.isUserid = function() {
    return (/^[a-zA-z]{1}[0-9a-zA-Z]+$/).test(this.remove(arguments[0])) ? true : false;
}

//-----------------------------------------------------------------------------
// 한글 체크 - arguments[0] : 추가 허용할 문자들
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.isKor = function() {
    return (/^[가-힣]+$/).test(this.remove(arguments[0])) ? true : false;
}

//-----------------------------------------------------------------------------
// 주민번호 체크 - arguments[0] : 주민번호 구분자
// XXXXXX-XXXXXXX
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.isJumin = function() {
    var arg = arguments[0] ? arguments[0] : "";
    var jumin = eval("this.match(/[0-9]{2}[01]{1}[0-9]{1}[0123]{1}[0-9]{1}" + arg + "[1234]{1}[0-9]{6}$/)");

    if (jumin == null) {
        return false;
    }
    else {
        jumin = jumin.toString().num().toString();
    }
    // 생년월일 체크
    var birthYY = (parseInt(jumin.charAt(6)) == (1 || 2)) ? "19" : "20";
    birthYY += jumin.substr(0, 2);

    var birthMM = jumin.substr(2, 2) - 1;
    var birthDD = jumin.substr(4, 2);
    var birthDay = new Date(birthYY, birthMM, birthDD);

    if (birthDay.getYear() % 100 != jumin.substr(0, 2) || birthDay.getMonth() != birthMM || birthDay.getDate() != birthDD) {
        return false;
    }

    var sum = 0;
    var num = [2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5]
    var last = parseInt(jumin.charAt(12));

    for (var i = 0; i < 12; i++) {
        sum += parseInt(jumin.charAt(i)) * num[i];
    }
    return ((11 - sum % 11) % 10 == last) ? true : false;
}

//-----------------------------------------------------------------------------
// 외국인 등록번호 체크 - arguments[0] : 등록번호 구분자
// XXXXXX-XXXXXXX
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.isForeign = function() {
    var arg = arguments[0] ? arguments[0] : "";
    var jumin = eval("this.match(/[0-9]{2}[01]{1}[0-9]{1}[0123]{1}[0-9]{1}" + arg + "[5678]{1}[0-9]{1}[02468]{1}[0-9]{2}[6789]{1}[0-9]{1}$/)");

    if (jumin == null) {
        return false;
    }
    else {
        jumin = jumin.toString().num().toString();
    }

    // 생년월일 체크
    var birthYY = (parseInt(jumin.charAt(6)) == (5 || 6)) ? "19" : "20";
    birthYY += jumin.substr(0, 2);
    var birthMM = jumin.substr(2, 2) - 1;
    var birthDD = jumin.substr(4, 2);
    var birthDay = new Date(birthYY, birthMM, birthDD);

    if (birthDay.getYear() % 100 != jumin.substr(0, 2) || birthDay.getMonth() != birthMM || birthDay.getDate() != birthDD) {
        return false;
    }
    if ((parseInt(jumin.charAt(7)) * 10 + parseInt(jumin.charAt(8))) % 2 != 0) {
        return false;
    }

    var sum = 0;
    var num = [2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5]
    var last = parseInt(jumin.charAt(12));

    for (var i = 0; i < 12; i++) {
        sum += parseInt(jumin.charAt(i)) * num[i];
    }
    return (((11 - sum % 11) % 10) + 2 == last) ? true : false;
}

//-----------------------------------------------------------------------------
// 사업자번호 체크 - arguments[0] : 등록번호 구분자
// XX-XXX-XXXXX
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.isBiznum = function() {
    var arg = arguments[0] ? arguments[0] : "";
    var biznum = eval("this.match(/[0-9]{3}" + arg + "[0-9]{2}" + arg + "[0-9]{5}$/)");

    if (biznum == null) {
        return false;
    }
    else {
        biznum = biznum.toString().num().toString();
    }

    var sum = parseInt(biznum.charAt(0));
    var num = [0, 3, 7, 1, 3, 7, 1, 3];

    for (var i = 1; i < 8; i++) sum += (parseInt(biznum.charAt(i)) * num[i]) % 10;
    sum += Math.floor(parseInt(parseInt(biznum.charAt(8))) * 5 / 10);
    sum += (parseInt(biznum.charAt(8)) * 5) % 10 + parseInt(biznum.charAt(9));

    return (sum % 10 == 0) ? true : false;
}

//-----------------------------------------------------------------------------
// 법인 등록번호 체크 - arguments[0] : 등록번호 구분자
// XXXXXX-XXXXXXX
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.isCorpnum = function() {
    var arg = arguments[0] ? arguments[0] : "";
    var corpnum = eval("this.match(/[0-9]{6}" + arg + "[0-9]{7}$/)");

    if (corpnum == null) {
        return false;
    }
    else {
        corpnum = corpnum.toString().num().toString();
    }

    var sum = 0;
    var num = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]
    var last = parseInt(corpnum.charAt(12));

    for (var i = 0; i < 12; i++) {
        sum += parseInt(corpnum.charAt(i)) * num[i];
    }
    return ((10 - sum % 10) % 10 == last) ? true : false;
}

//-----------------------------------------------------------------------------
// 이메일의 유효성을 체크
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.isEmail = function() {
    return (/\w+([-+.]\w+)*@\w+([-.]\w+)*\.[a-zA-Z]{2,4}$/).test(this.trim());
}

//-----------------------------------------------------------------------------
// 전화번호 체크 - arguments[0] : 전화번호 구분자
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.isPhone = function() {
    var arg = arguments[0] ? arguments[0] : "";
    return eval("(/(02|0[3-9]{1}[0-9]{1})" + arg + "[1-9]{1}[0-9]{2,3}" + arg + "[0-9]{4}$/).test(this)");
}

//-----------------------------------------------------------------------------
// 핸드폰번호 체크 - arguments[0] : 핸드폰 구분자
// @return : boolean
//-----------------------------------------------------------------------------

String.prototype.isMobile = function() {
    var arg = arguments[0] ? arguments[0] : "";
    return eval("(/01[016789]" + arg + "[1-9]{1}[0-9]{2,3}" + arg + "[0-9]{4}$/).test(this)");
}

//-----------------------------------------------------------------------------
// 모든 문자 변환 - old : 이전문자, str : 변환문자
// @return : string
//-----------------------------------------------------------------------------

String.prototype.replaceAll = function(old, str) {
    return (this.split(old)).join(str);
}

//패스워드 영문숫자 조합
String.prototype.numstrmix = function() {
    var arr_buf = new Array();
    var alp_cnt = 0;
    var num_cnt = 0;
    var chr_cnt = 0;
    var i;
    for (i = 0; i < this.length; i++)
        arr_buf[i] = this.substring(i, i + 1);

    for (i = 0; i < this.length; i++) {
        if (('A' <= arr_buf[i] && arr_buf[i] <= 'Z') || ('a' <= arr_buf[i] && arr_buf[i] <= 'z')) alp_cnt++;
        if ('0' <= arr_buf[i] && arr_buf[i] <= '9') num_cnt++;
    }

    if (alp_cnt > 0 && num_cnt > 0) {
        return true;
    }
    else {
        return false;
    }
}

String.prototype.numtobyte = function(unit, n) {
    var num = this.float();
    var rnum;
    var cnt = 0;
    if (unit) {
        switch (unit.toUpperCase()) {
            case "KB": { cnt = 1; break; }
            case "MB": { cnt = 2; break; }
            case "GB": { cnt = 3; break; }
            case "TB": { cnt = 4; break; }
            case "PB": { cnt = 5; break; }
            case "EB": { cnt = 6; break; }
            case "ZB": { cnt = 7; break; }
            case "YB": { cnt = 8; break; }
        }

        for (; cnt > 0; cnt--) {
            num /= 1024;
        }
    }
    else {
        while (num >= 1024) {
            num /= 1024;
            cnt++;
        }

        var unit = "BYTE";
        switch (cnt) {
            case 1: { unit = "KB"; break; }
            case 2: { unit = "MB"; break; }
            case 3: { unit = "GB"; break; }
            case 4: { unit = "TB"; break; }
            case 5: { unit = "PB"; break; }
            case 6: { unit = "EB"; break; }
            case 7: { unit = "ZB"; break; }
            case 8: { unit = "YB"; break; }
        }
    }

    return (isNaN(n)) ? num.toString().money() + unit : num.toString().deciround(n).toString().money() + unit;
}

String.prototype.bytetonum = function() {
    var num = this.float();
    var unit = this.replace(/[^a-zA-Z]/g, "");
    var cnt = 0;
    switch (unit.toUpperCase()) {
        case "KB": { cnt = 1; break; }
        case "MB": { cnt = 2; break; }
        case "GB": { cnt = 3; break; }
        case "TB": { cnt = 4; break; }
        case "PB": { cnt = 5; break; }
        case "EB": { cnt = 6; break; }
        case "ZB": { cnt = 7; break; }
        case "YB": { cnt = 8; break; }
    }
    num *= Math.pow(1024, cnt);
    return num;
}

String.prototype.stripHTML = function() {
    return this.replace(/<[^<|>]*>/g, "");
}

Date.prototype.getDateFormat = function(arg) { // Y, M, D, y, m, d
    var year = this.getFullYear();
    var month = this.getMonth() + 1;
    var date = this.getDate();

    arg = arg.replaceAll("y", year);
    arg = arg.replaceAll("m", month);
    arg = arg.replaceAll("d", date);

    month = (month > 9) ? month : "0" + month;
    date = (date > 10) ? date : "0" + date;

    arg = arg.replaceAll("Y", year);
    arg = arg.replaceAll("M", month);
    arg = arg.replaceAll("D", date);

    return arg;
}

//-----------------------------------------------------------------------------
// 이미지 크기 리사이즈
//-----------------------------------------------------------------------------
function img_resize(imgID, size) {
    if (imgID != null) {
        var imgWid = imgID.width;
        if (imgWid > size) {
            imgID.width = size;

            //var imgHei = imgID.height;
            //imgID.height = (size * imgHei) / imgWid;
        }
    }
}

function imgSizeCheck(imgID, size) {
    imgID = 'document.' + imgID;
    setTimeout("img_resize(" + imgID + "," + size + ")", 200);
}

//-----------------------------------------------------------------------------
// 이미지사이즈에맞게 새창띄우기
//-----------------------------------------------------------------------------
function ImageSizeNewWin(ImgSrc) {
    PopImg = new Image();
    PopImg.src = ImgSrc;

    var imgWidth = PopImg.width;
    var imgHeight = PopImg.height;
    //alert(imgWidth + ' * ' + imgHeight);
    var winl = (screen.width - imgWidth) / 2;
    var wint = (screen.height - imgHeight) / 2;

    NewImgWin = window.open("", "", "status=no,width=" + imgWidth + ",height=" + imgHeight + ",top=" + wint + ",left=" + winl);

    NewImgWin.document.write('<html><head><title>이미지보기</title><meta http-equiv="Content-Type" content="text/html; charset=' + document.charset + '"></head>');
    NewImgWin.document.write('<body leftmargin=0 topmargin=0 onclick=self.close() style=cursor:pointer>');
    NewImgWin.document.write('<img src="' + ImgSrc + '" alt="이미지를 클릭하면 닫힙니다.">');
    NewImgWin.document.write('</body></html>');
}


//------------------------------------------------------
// 팝업창 가운데 띄우기
//------------------------------------------------------
function CenterNewWin(url, name, features) {
    if (document.layers) {
        var sinist = screen.width / 2 - outerWidth / 2;
        var toppo = screen.height / 2 - outerHeight / 2;
    } else {
        var sinist = screen.width / 2 - document.body.offsetWidth / 2;
        var toppo = -75 + screen.height / 2 - document.body.offsetHeight / 2;
    }

    window.open(url, name, features);
}


//------------------------------------------------------
// 게시물 신고하기 팝업
//------------------------------------------------------
function PostingDeclarePopup(tit, user) {
    CenterNewWin('/CoastIn/PostingDeclare.aspx?title=' + encodeURIComponent(tit) + '&user_id=' + user, 'PostingDeclare', 'toolbar=no,menubar=no,scrollbars=no,resizable=no,status=no,location=no,width=550,height=550');
}

//------------------------------------------------------
// 연안지도 팝업
//------------------------------------------------------
function CoastMapPopup(url) {
    CenterNewWin(url, 'Coastmap', 'toolbar=no,menubar=no,scrollbars=no,resizable=yes,status=no,location=no,width=1024,height=768');
}

//------------------------------------------------------
// 여객선 여행 팝업
//------------------------------------------------------
function ShippingSearchPop(url) {
    CenterNewWin(url, 'ShippingSearch', 'toolbar=no,menubar=no,scrollbars=yes,resizable=no,status=no,location=no,width=868,height=659');
}
