//layer popup
function commonLayerOpen(thisId){
	$('#'+thisId).show();
}
function commonLayerClose(thisId){
	$('#'+thisId).hide();
}

function change_toggle(id) {
    $("#"+id).toggle();
}

// 날짜 포멧 
Date.prototype.format = function(f) {
    if (!this.valueOf()) return " ";

    var weekName = ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"];
    var d = this;

    return f.replace(/(yyyy|yy|MM|dd|E|hh|mm|ss|a\/p)/gi, function($1) {
        switch ($1) {
            case "yyyy": return d.getFullYear();
            case "yy": return (d.getFullYear() % 1000).zf(2);
            case "MM": return (d.getMonth() + 1).zf(2);
            case "dd": return d.getDate().zf(2);
            case "E": return weekName[d.getDay()];
            case "HH": return d.getHours().zf(2);
            case "hh": return ((h = d.getHours() % 12) ? h : 12).zf(2);
            case "mm": return d.getMinutes().zf(2);
            case "ss": return d.getSeconds().zf(2);
            case "a/p": return d.getHours() < 12 ? "오전" : "오후";
            default: return $1;
        }
    });
};

String.prototype.string = function(len){var s = '', i = 0; while (i++ < len) { s += this; } return s;};
String.prototype.zf = function(len){return "0".string(len - this.length) + this;};
Number.prototype.zf = function(len){return this.toString().zf(len);};


// 숫자체크
function checkNumber(val){
    var regexp = /^[0-9]*$/
    if( !regexp.test(val) ) {
        return false;
    }
    return true;
}

// 이메일체크
function checkEmail(val){
    var regexp=/^[-A-Za-z0-9_]+[-A-Za-z0-9_.]*[@]{1}[-A-Za-z0-9_]+[-A-Za-z0-9_.]*[.]{1}[A-Za-z]{1,5}$/;
    if( !regexp.test(val) ) {
        return false;
    }
    return true;
}

// 전화번호체크
function checkPhone(val){
    var regexp= /^\d{2,3}-\d{3,4}-\d{4}$/;
    if( !regexp.test(val) ) {
        return false;
    }
    return true;
}


// 전화번호체크
function checkMobile(val){
    var regexp= /^((01[1|6|7|8|9])[1-9]+[0-9]{6,7})|(010[1-9][0-9]{7})$/;
    if( !regexp.test(val) ) {
        return false;
    }
    return true;
}


// 콤마
function setComma(_no) {
	return _no.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}

// json sort
function sortJSON(data, key, way) {
    return data.sort(function(a, b) {
        var x = a[key]; var y = b[key];
        if (way === '123' ) { return ((x < y) ? -1 : ((x > y) ? 1 : 0)); }
        if (way === '321') { return ((x > y) ? -1 : ((x < y) ? 1 : 0)); }
    });
}

// 아이디 유효성 체크
function member_id_valid_check(val){
    var regexp = /^[a-zA-Z0-9_-]{5,20}$/;
    if( !regexp.test(val) ) {
        return false;
    }
    return true;
}

// 비밀번호 유효성 체크
function member_pwd_valid_check(val){
    var regexp =  /[ㄱ-ㅎ|ㅏ-ㅣ|가-힣]/;
    if(regexp.test(val)) {
        return false;
    }
    if(val.length < 6)  return false;
    if(val.length > 16) return false;

    return true;
}


var scale = 1;
function zoom_in() {
    scale *= 1.25;
    zoom(scale);
}

function zoom_out() {
    scale /= 1.25;
    zoom(scale);
}

function zoom(scale) {
    var body = document.body;
    body.style.zoom = scale;  // IE
    body.style.webkitTransform = 'scale('+scale+')';  // Webkit(chrome)
    body.style.webkitTransformOrigin = '0 0';
    body.style.mozTransform = 'scale('+scale+')';  // Mozilla(firefox)
    body.style.mozTransformOrigin = '0 0';
    body.style.oTransform = 'scale('+scale+')';  // Opera
    body.style.oTransformOrigin = '0 0';
}

// 폰트크기 조절
var targets = new Array('div', 'td', 'tr', 'li', 'ul', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'input');
var sizes = new Array('9', '12', '14', '16', '18', '20', '22', '24', '26');
var startSize = 1;
function ts(target, inc) {
    if (!document.getElementById) return;
    var d = document, cEl = null, size = startSize, i, j, cTags;
    size += inc;
    if (size < 0) {
        size = 0;
    }
    if (size > 9) {
        size = 9;
    }
    startSize = size;
    if (!( cEl = d.getElementById(target))) {
        cEl = d.getElementsByTagName(target)[0];
    }
    cEl.style.fontSize = sizes[size];
    for (i=0; i<targets.length; i++) {
        cTags = cEl.getElementsByTagName(targets[i]);
        for (j=0; j<cTags.length; j++){
            cTags[j].style.fontSize = sizes[size] + "pt";
   cTags[j].style.lineHeight = sizes[size] * 1.5 + "pt";
        }
    }
}
// 폰트크기 조절

function search_keyword_reg(keyword){
	var return_state = true;
    var form_data = {
		"keyword"			: keyword
	};
	$.ajax({
        url: '/web/search/search_keyword_reg',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
			if(rtnJson.code=='9999') {
				alert(rtnJson.msg);
                return_state = false;
			} else {
			    return_state = true;
            }
        },
        error: function (rtnHtml) {
            return_state = false;
        }

    });

    return return_state;



}








