var selRange, product_brand_list; 
if (typeof(COMMON_JS) == 'undefined') {
    jQuery.migrateTrace = false;
    jQuery.migrateMute = true;
    $.fn.outerHTML = function() {
        return $(this).clone().wrapAll("<div/>").parent().html();
    }

    $.toast = function(opts) {
        var show = function() {
            if($('.toast-container').length) $('.toast-container').remove();
            var $toast = $('\
                <div class="toast-container">\
                    <div class="toast-box">' + opts.title + '</div>\
                </div>\
            ');

            var set_height = $toast.height();
            // 애니메이션 방법1
            // $toast.css({
            //     'top' : opts.top, 
            //     'left' : opts.left, 
            //     'z-index': opts.zIndex,
            //     'box-shadow' : '1px 1px 4px ' + colorset + 'aa',
            //     'color' : colorset,
            //     'font-size' : '14px',
            //     'border' : '1px solid ' + colorset,
            //     'height' : '0px',
            // }).animate({'height' : set_height}, opts.animation_duration);

            // 애니메이션 방법2
            // $toast.css({
            //     'display':'none', 
            //     'top' : opts.top, 
            //     'left' : opts.left, 
            //     'z-index': opts.zIndex,
            //     'box-shadow' : '1px 1px 4px ' + colorset + 'aa',
            //     'color' : colorset,
            //     'font-size' : '14px',
            //     'border' : '1px solid ' + colorset,
            // }).fadeIn(opts.animation_duration);

            // 애니메이션 방법3

            $toast.find('.toast-box').css({
                'top': opts.top,
                'left': opts.left,
                'z-index': opts.zIndex,
                'transform': 'translateX(-50%) scale(0)',
                'transition': 'transform ' + (opts.animation_duration / 1000) + 's',
                'opacity': '.3',
                'position': 'fixed',
                'word-break' : 'auto-phrase',
            });
            $toast.find('.toast-box').addClass(opts.type);

            $('body').append($toast);

            setTimeout(function() {
                $toast.find('.toast-box').css({ 'transform': 'translateX(-50%) scale(1)' });
                $toast.find('.toast-box').animate({ 'opacity': '1' }, opts.animation_duration);
            });

            setTimeout(function() {
                // $toast.find('.toast-box').css({'transform' : 'scale(0)'});
                $toast.find('.toast-box').fadeOut();
            }, opts.display_duration + opts.animation_duration);

            setTimeout(function() {
                $toast.remove();
            }, opts.display_duration + opts.animation_duration * 2);
        }

        opts = $.extend(true, {}, $.toast.defaults, opts);
        show();
    }

    $.toast.defaults = {
        'title': 'Type the title.',
        'type': 'info', // info - blue, danger - red, 
        'display_duration': 3000,
        'animation_duration': 300,
        'top': '150px',
        'left': '50%',
        'zIndex': '9999',
    };

    if (typeof rt_path == 'undefined')
        alert('rt_path 변수가 선언되지 않았습니다.');

    var COMMON_JS = true;

    var setLogs = function(type, action, icon, obj, page, select_el) {
        if(typeof page == 'undefined') page = PAGE;
        if(typeof select_el == 'undefined') select_el = editEL;
        $.ajax({
            url:'/template/log',
            type:'post',
            async: true,
            dataType:'json',
            data: { sid: SID, page: page, type: type, el: select_el, action: action, icon: icon, obj: obj },
            success:function(data) {
                if (typeof data.error != 'undefined' && data.error) {
                    return false;
                }
                addlogs(data);
            }
        });
    }
    
    var addlogs = function(data) {
        $('.history-dropdown li a').removeClass('active');
        var $li = $('<li>'),
            $log = $('<a>'),
            str = $.lang[LANG]['log.' + data.action],
            obj = (typeof $.lang[LANG]['log.' + data.obj] == 'undefined') ? data.obj + ' ' : $.lang[LANG]['log.' + data.obj] + ' ',
            obj = (data.type == 'MENU' || data.type == 'FOOT' || data.type == 'BOOKMARK') ? obj : '',
            logEL = (data.el) ? data.el : '';
        logEL = logEL.replace('el_', '');
        block = (data.obj == 'ELEM') ? '#' + logEL + ' ' : ' ';
    
        if (obj === '' && typeof str != 'undefined' && str.length > 0) str = str.replace(/^: /, '');
    
        if ($('.history-dropdown').children().length > 14) {
            $('.history-dropdown li').last().remove();
        }
        $log.attr('href', '#')
            .attr('data-seq', data.seq)
            .attr('data-toggle', 'tooltip')
            .attr('data-placement', 'left')
            .attr('title', data.date)
            .addClass('user-logs')
            .addClass('active')
            .append('<i class="fa ' + data.icon + '"></i> ' + obj + str);
    
        $li.append($log);
        $('.history-dropdown').prepend($li);
    }

    function getServiceHost() {
        var s = window.location.hostname;
        if (s == 'www.creatorlink.net' || s == 'creatorlink.net' || s == 'www.showbible.com' || s == 'showbible.com' || s == 'www.addblock.net' || s == 'addblock.net' ||
            s == 'www.creatorlink-gabia.com' || s == 'creatorlink-gabia.com') {
            s = s.replace('www.', '');
            s = (window.location.port) ? s + ':' + window.location.port : s;
        } else {
            s = window.location.host;
        }
        return s;
    }

    function clLocalStorageClear() {
      var cl_key_arr = ['referer','sid','type','pid','view','page_mode','status','parent','reply_name','reply','id','content','secret','href','forum_email'];
      $.each(cl_key_arr, function(i, k) {
          if (typeof k != 'undefined' && k) window.localStorage.removeItem(k);
      });
    }

    function log_analytics(sid, googleAnalytics, googleAnalytics_check) {
        var scriptTag = '';
        if (googleAnalytics_check == 'old') {
            scriptTag = "\
            (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n\
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n\
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n\
            })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');\n\
            ";
            if (googleAnalytics) {
                scriptTag += "\
                ga('create', '" + googleAnalytics + "', 'auto');\n\
                ga('require', 'displayfeatures');\n\
                ga('require', 'linkid');\n\
                ga('send', 'pageview');\n\
                ";
            }

        } else {
            if (sid && googleAnalytics) {
                scriptTag = "\
                window.dataLayer = window.dataLayer || [];\n\
                function gtag(){dataLayer.push(arguments); }\n\
                gtag('js', new Date());\n\
                ";
                scriptTag += (googleAnalytics) ? "gtag('config', '" + googleAnalytics + "');\n" : "";
                $('body').prepend('<script async src="https://www.googletagmanager.com/gtag/js?id=' + googleAnalytics + '"></script>');
            }
        }

        if(scriptTag != '') {
            var addScriptTag = '';
            if(sid && googleAnalytics) {
                addScriptTag += "\n\
                    <script>\n\
                        window.dataLayer = window.dataLayer || [];\n\
                        if(typeof localStorage.getItem('googleAnalyticsUID"+sid+"') != 'undefined' && localStorage.getItem('googleAnalyticsUID"+sid+"')) {\n\
                            dataLayer.push({ 'user_id': localStorage.getItem('googleAnalyticsUID"+sid+"') });\n\
                        }\n\
                    </script>\n\
                ";
            }

            addScriptTag += '<script>' + scriptTag + '</script>'
            $('body').prepend(addScriptTag);
        }
        
    }

    function naverSeo(type) {
        var jsonscript = '';
        switch (type) {
            case 'faq':
                {
                    jsonscript +=
                    '\
                    {\
                      "@context": "http://schema.org",\
                      "@type": "FAQPage",\
                      "mainEntity": [\
                        {\
                          "@type": "Question",\
                          "name": "포트폴리오 사이트만 만들 수 있나요?",\
                          "acceptedAnswer": {\
                            "@type": "Answer",\
                            "text": "아닙니다. 쇼핑몰, 회사홈페이지, 개인블로그, 모바일청첩장 등 원하시는 사이트를 자유롭게 만드실 수 있습니다."\
                          }\
                        },\
                        {\
                          "@type": "Question",\
                          "name": "결제 기능(쇼핑몰)을 사용할 수 있나요",\
                          "acceptedAnswer": {\
                            "@type": "Answer",\
                            "text": "<ul>\
                                        <li>쇼핑 요금제를 적용하여 쇼핑몰을 만들 수 있습니다.</li>\
                                        <li> </li>\
                                        <li>PG가입을 통해 신용카드나 계좌이체 등의 결제시스템을 연동할 수 있으며, 상품관리나 주문배송관리 등의 쇼핑 관련 기능이 제공됩니다.</li>\
                                        <li>기존에 크리에이터링크에서 만든 홈페이지가 있는 경우에도 새로 쇼핑몰을 만들 필요 없이 쇼핑 요금제만 적용하면 쇼핑몰로 전환할 수 있습니다.</li>\
                                        <li><a href=\\"https://www.creatorlink.net/shoppingevent\\">쇼핑 요금제 자세히 보기</a></li>\
                                    </ul>"\
                          }\
                        },\
                        {\
                          "@type": "Question",\
                          "name": "코딩을 몰라도 홈페이지를 만들 수 있나요?",\
                          "acceptedAnswer": {\
                            "@type": "Answer",\
                            "text": "네. 코딩을 전혀 몰라도 쉽게 만들 수 있는 모듈형 제작방식을 제공하고 있습니다."\
                          }\
                        },\
                        {\
                          "@type": "Question",\
                          "name": "홈페이지는 몇 개까지 만들 수 있나요?",\
                          "acceptedAnswer": {\
                            "@type": "Answer",\
                            "text": "계정 당 10개의 홈페이지를 만들 수 있습니다."\
                          }\
                        },\
                        {\
                          "@type": "Question",\
                          "name": "네이버나 다음에 노출시킬 수 있나요?",\
                          "acceptedAnswer": {\
                            "@type": "Answer",\
                            "text": "네. 사이트를 만드신 후 각 포털에 검색등록을 하실 수 있습니다."\
                          }\
                        }\
                      ]\
                    }\
                ';
                    break;
                }
            case 'carousel':
                {
                    jsonscript +=
                    '\
                    {\
                      "@context":"http://schema.org",\
                      "@type":"ItemList",\
                      "itemListElement":[\
                        {\
                          "@type": "ListItem",\
                          "name": "Dajeong",\
                          "image": "https://storage.googleapis.com/cr-resource/image/b79b620cbfea30807340cf90ed5e5bbe/rousefleur/rousefleur-bestsite.jpg",\
                          "url": "https://rousefleur.creatorlink.net",\
                          "position": "1"\
                        },\
                        {\
                          "@type": "ListItem",\
                          "name": "궁리",\
                          "image": "https://storage.googleapis.com/cr-resource/image/91cd3ae4e7326ec246d8ce207325311e/guungri/guungri-bestsite.jpg",\
                          "url": "https://guungri.creatorlink.net",\
                          "position": "2"\
                        },\
                        {\
                          "@type": "ListItem",\
                          "name": "운타",\
                          "image": "https://storage.googleapis.com/cr-resource/image/0a1afa78e08359fea268dc23cf25feba/unta/unta-bestsite.jpg",\
                          "url": "https://unta.creatorlink.net",\
                          "position": "3"\
                        },\
                        {\
                          "@type": "ListItem",\
                          "name": "HC DESIGN",\
                          "image": "https://storage.googleapis.com/cr-resource/image/8a3065df6f50178993b1d7d5ab5bb345/metafranchise/metafranchise-bestsite.jpg",\
                          "url": "https://metafranchise.creatorlink.net",\
                          "position": "4"\
                        },\
                        {\
                          "@type": "ListItem",\
                          "name": "에이캠스튜디오",\
                          "image": "https://storage.googleapis.com/cr-resource/image/17fbe9f7a0ddd0efddf0f34aeca01744/acamstudio/acamstudio-bestsite.jpg",\
                          "url": "https://acamstudio.creatorlink.net",\
                          "position": "5"\
                        },\
                        {\
                          "@type": "ListItem",\
                          "name": "미카엘",\
                          "image": "https://storage.googleapis.com/cr-resource/image/5fa6beb099367406036b7744fdf0d518/lawyerljw/lawyerljw-bestsite.jpg",\
                          "url": "https://lawyerljw.creatorlink.net",\
                          "position": "6"\
                        },\
                        {\
                          "@type": "ListItem",\
                          "name": "포씨드",\
                          "image": "//storage.googleapis.com/cr-resource/image/774baa5c985fc6eb5824f15d60130756/forseed/forseed-bestsite.jpg",\
                          "url": "https://forseed.creatorlink.net",\
                          "position": "7"\
                        },\
                        {\
                          "@type": "ListItem",\
                          "name": "snoworks",\
                          "image": "https://storage.googleapis.com/cr-resource/image/8bb728caf2a19b5f6263478d7eaaee24/whaledesign/whaledesign-bestsite.jpg",\
                          "url": "https://whaledesign.creatorlink.net",\
                          "position": "8"\
                        },\
                        {\
                          "@type": "ListItem",\
                          "name": "NARKO",\
                          "image": "https://storage.googleapis.com/cr-resource/image/a206b43e3689c50cb9affa3a7f76df8a/narko/narko-bestsite.jpg",\
                          "url": "https://narko.creatorlink.net",\
                          "position": "9"\
                        } \
                      ]\
                    }\
                ';
                    break;
                }
            case 'review':
                {
                    jsonscript +=
                    '\
                    {\
                      "@context": "https://schema.org",\
                      "@type": "Product",\
                      "aggregateRating": {\
                        "@type": "AggregateRating",\
                        "ratingValue": "5",\
                        "reviewCount": "70"\
                      },\
                      "name" : "Responsive Homepage",\
                      "review": [\
                        {\
                          "@type": "Review",\
                          "author": "soh******",\
                          "name": "써본것 중 제일 쉽고 편했어요",\
                          "reviewBody": "간단하게 사이트를 만들 수 있어 좋아요 :) 직접 코딩을 해서 제작해 본 적도 있고, 카***** 같은 유사 플랫폼을 이용한 적도 있는데 제가 시도해 본 것 중엔 사용방식이나 설정 방법이 제일 쉽고 편했어요. 웹사이트 제작 필요하신 분들께 추천드려봅니다.",\
                          "reviewRating": {\
                            "@type": "Rating",\
                            "bestRating": "5",\
                            "ratingValue": "5"\
                          }\
                        },\
                        {\
                          "@type": "Review",\
                          "author": "지**",\
                          "name": "디자인도 퀄리티가 너무 높아서.... 놀랐습니다.",\
                          "reviewBody": "홈페이지 제작 어렵게 생각했는데 이렇게 멋진 홈페이지가 간단하게 뚝딱 제작된다니...너무 놀랍네요...홈페이지가 필요하시거나 포폴필요하신분은 크리에이터링크로 작업하시면 너무 좋을듯합니다. 디자인도 퀄리티가 너무 높아서.... 놀랐습니다.",\
                          "reviewRating": {\
                            "@type": "Rating",\
                            "bestRating": "5",\
                            "ratingValue": "5"\
                          }\
                        },\
                        {\
                          "@type": "Review",\
                          "author": "fa***",\
                          "name": "창업 사이트도 크리에이터 링크를 이용하고 있답니다.",\
                          "reviewBody": "크리에이터 링크 사이트를 이용해서 사이트를 만들어 사용한지 벌써 일년이 넘었네요! 너무나 편리하고 필수적인 기능들이 잘 들어가 있어서, 초보자들도 바로 만들 수 있게끔 되어있어요. 저도 처음엔 개인 포트폴리오 사이트를 만드려고 크리에이터 링크를 이용하다가 너무 좋아서 지금은 창업 사이트도 크리에이터 링크를 이용하고 있답니다.",\
                          "reviewRating": {\
                            "@type": "Rating",\
                            "bestRating": "5",\
                            "ratingValue": "5"\
                          }\
                        },\
                        {\
                          "@type": "Review",\
                          "author": "이**",\
                          "name": "\\"쉽고 빠르게 홈페이지 제작은..크리에이터 링크가 답입니다.",\
                          "reviewBody": "\\"우리나라에서 제공하는 무료 홈페이지 중에서 \\"\\"아, 이게 제일 나다운 홈페이지다.\\"\\" 하고 느꼈네요. 내가 원하는 대로 만들려면 어려운 코딩 공부를 해야 되죠ㅠㅠ 하지만 크리에이터 링크는 척척! 잘 만들어주니까 너무 좋아요! 여러분.. 쉽고 빠르게 홈페이지 제작은..크리에이터 링크가 답입니다.\\"",\
                          "reviewRating": {\
                            "@type": "Rating",\
                            "bestRating": "5",\
                            "ratingValue": "5"\
                          }\
                        },\
                        {\
                          "@type": "Review",\
                          "author": "윤**",\
                          "name": "윅*에서 크리에이터링크로 갈아탔네요~",\
                          "reviewBody": "원래는 포트폴리오 사이트를 외국사이트 윅*로 만들어보려고 계획했었는데 우연히 크리에이터링크 사이트 발견하고 거기 작업하던거 포기하고 바로 갈아탔네요~ 쉽게 블럭으로 추가되는 것도 편리하고 편집하는 것도 직관적이고 무엇보다도 한글 서체가 다양해서 만족입니다~ " ,\
                          "reviewRating" : {\
                            "@type": "Rating",\
                            "bestRating": "5",\
                            "ratingValue": "5"\
                          }\
                        }\
                      ]\
                    }\
                ';
                    break;
                }

            default:
                {
                    break;
                }
        }
        $('body').prepend('<script type="application/ld+json">' + jsonscript + '</script>');
    }

    function arrayUnique(array) {
        var a = array.concat();
        for (var i = 0; i < a.length; ++i) {
            for (var j = i + 1; j < a.length; ++j) {
                if (a[i] === a[j])
                    a.splice(j--, 1);
            }
        }
        return a;
    }

    function arrayRemove(arr, value) {
        return arr.filter(function(ele) {
            return ele != value;
        });
    }

    function win_open(url, name, option) {
        var popup = window.open(rt_path + '/' + url, name, option);
        popup.focus();
    }

    // 쪽지 창
    function win_memo(url) {
        if (!url)
            url = "member/memo/lists";
        win_open(url, "winMemo", "left=50,top=50,width=620,height=460,scrollbars=1");
    }

    // 자기소개 창
    function win_profile(mb_id) {
        win_open("member/profile/qry/" + mb_id, 'winProfile', 'left=50,top=50,width=400,height=500,scrollbars=1');
    }

    // 우편번호 창
    function win_zip(frm_name, frm_zip1, frm_zip2, frm_addr1, frm_addr2) {
        url = "useful/zip/qry/" + frm_name + "/" + frm_zip1 + "/" + frm_zip2 + "/" + frm_addr1 + "/" + frm_addr2;
        win_open(url, "winZip", "left=50,top=50,width=616,height=460,scrollbars=1");
    }

    // POST 전송, 결과값 리턴
    function post_s(href, parm, del) {
        /*if (!del || confirm(  $.lang[LANG]['page.board.cts.msg.delete'] )) {
            $.post(rt_path + '/' + href, parm, function (req) {
                document.write(req);
            });
        }*/
        var confirm = false;
        var modal = $(this).showModalFlat('', $.lang[LANG]['page.board.cts.msg.delete'], true, true, function() {
            confirm = true;
            if (!del || confirm) {
                $.post(rt_path + '/' + href, parm, function(req) {
                    document.write(req);
                });
            }
        }, 'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn', '', '', function() {
            $(document).on('keydown', function(e) {
                if (e.keyCode == 27) modal.modal('hide');
            });
        });
    }

    // POST 이동
    function post_goto(url, parm, target) {
        var f = document.createElement('form');

        var objs, value;
        for (var key in parm) {
            value = parm[key];
            objs = document.createElement('input');
            objs.setAttribute('type', 'hidden');
            objs.setAttribute('name', key);
            objs.setAttribute('value', value);
            f.appendChild(objs);
        }

        if (target)
            f.setAttribute('target', target);

        f.setAttribute('method', 'post');
        f.setAttribute('action', rt_path + '/' + url);
        document.body.appendChild(f);
        f.submit();
    }

    // POST 창
    function post_win(name, url, parm, opt) {
        var temp_win = window.open('', name, opt);
        post_goto(url, parm, name);
    }

    // 일반 삭제 검사 확인
    function del(href) {
        if (confirm("한번 삭제한 자료는 복구할 방법이 없습니다.\n\n정말 삭제하시겠습니까?"))
            document.location.href = rt_path + '/' + href;
    }

    // 플래시에 변수 추가 fh
    function flash_movie(src, ids, width, height, wmode, fh) {
        var wh = "";
        if (parseInt(width) && parseInt(height))
            wh = " width='" + width + "' height='" + height + "' ";
        return "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' " + wh + " id=" + ids + "><param name=wmode value=" + wmode + "><param name=movie value=" + src + "><param name=quality value=high><param name=flashvars value=" + fh + "><embed src=" + src + " quality=high wmode=" + wmode + " flashvars=" + fh + " type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash' " + wh + "></embed></object>";
    }

    // 동영상 파일
    function obj_movie(src, ids, width, height, autostart) {
        var wh = "";
        if (parseInt(width) && parseInt(height))
            wh = " width='" + width + "' height='" + height + "' ";
        if (!autostart) autostart = false;
        return "<embed src='" + src + "' " + wh + " autostart='" + autostart + "'></embed>";
    }

    // 아이프레임 높이 자동조절
    function reSize(obj) {
        try {
            var objBody = frames[obj].document.body;
            var objFrame = document.getElementById(obj);
            ifrmHeight = objBody.scrollHeight + (objBody.offsetHeight - objBody.clientHeight);
            objFrame.style.height = ifrmHeight;
        } catch (e) {}
    }

    function sEncode(val) {
        return encodeURIComponent(val).replace(/%/g, '.');
    }

    // script 에서 js 파일 로드
    function importScript(FILES) {
        var _importScript = function(filename) {
            if (filename) {
                document.write('<script type="text/javascript" src="' + rt_path + '/js/' + filename + '.js"></s' + 'cript>');
            }
        };

        for (var i = 0; i < FILES.length; i++) {
            _importScript(FILES[i]);
        }
    }

    // jQuery textarea
    function txresize(tx, type, size) {
        var tx = $('#' + tx);
        if (type == 1)
            tx.animate({ 'height': '-=' + size + 'px' }, 'fast');
        else if (type == 2)
            tx.animate({ 'height': size }, 'fast');
        else if (type == 3)
            tx.animate({ 'height': '+=' + size + 'px' }, 'fast');
    }

    // 팝업 닫기
    function popup_close(id, onday) {
        if (onday) {
            var today = new Date();
            today.setTime(today.getTime() + (60 * 60 * 1000 * 24));
            document.cookie = id + "=" + escape(true) + "; path=/; expires=" + today.toGMTString() + ";";
        }

        if (window.parent.name.indexOf(id) != -1)
            window.close();
        else
            document.getElementById(id).style.display = 'none';
    }

    function checkcode(e) {
        var code = (window.event) ? event.keyCode : e.which; //IE : FF - Chrome both
        if (code > 31 && code < 45) nAllow(e);
        if (code > 45 && code < 48) nAllow(e);
        if (code > 57 && code < 65) nAllow(e);
        if (code > 90 && code < 97) nAllow(e);
        if (code > 122 && code < 127) nAllow(e);
    }

    function nAllow(e) {
        alert('특수문자 - 만 사용할수있습니다');
        if (navigator.appName != "Netscape") {
            //for not returning keycode value
            event.returnValue = false; //IE ,  - Chrome both
        } else {
            e.preventDefault(); //FF ,  - Chrome both
        }
    }

    function copyToClipboard(text) {
        if (window.clipboardData && window.clipboardData.setData) {
            // IE specific code path to prevent textarea being shown while dialog is visible.
            return clipboardData.setData("Text", text);

        } else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
            var textarea = document.createElement("textarea");
            textarea.textContent = text;
            textarea.style.position = "fixed"; // Prevent scrolling to bottom of page in MS Edge.
            document.body.appendChild(textarea);
            textarea.select();
            try {
                return document.execCommand("copy"); // Security exception may be thrown by some browsers.
            } catch (ex) {
                console.warn("Copy to clipboard failed.", ex);
                return false;
            } finally {
                document.body.removeChild(textarea);
            }
        }
    }

    function copyTextToClipboard(text) {
        var copyFrom = $('<textarea class="hide"/>');
        copyFrom.text(text);
        $('body').append(copyFrom);
        copyFrom.select();
        document.execCommand('copy');
        copyFrom.remove();
    }

    function trim(str) {
        str = str.replace(/^\s*/, '').replace(/\s*$/, '');
        return str; //변환한 스트링을 리턴.
    }

    jQuery.fn.center = function() {
        this.css("position", "absolute");
        this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + $(window).scrollTop()) + "px");
        this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) + $(window).scrollLeft()) + "px");
        return this;
    }

    function setCookie(cookieName, cookieValue, expireDate) {
        var today = new Date();
        today.setDate(today.getDate() + parseInt(expireDate));
        document.cookie = cookieName + "=" + escape(cookieValue) + "; path=/; expires=" + today.toGMTString() + ";";
    }

    function getCookie(cookieName) {
        var search = cookieName + "=";
        var cookie = document.cookie;

        // 현재 쿠키가 존재할 경우
        if (cookie.length > 0) {
            // 해당 쿠키명이 존재하는지 검색한 후 존재하면 위치를 리턴.
            startIndex = cookie.indexOf(cookieName);

            // 만약 존재한다면
            if (startIndex != -1) {
                // 값을 얻어내기 위해 시작 인덱스 조절
                startIndex += cookieName.length;

                // 값을 얻어내기 위해 종료 인덱스 추출
                endIndex = cookie.indexOf(";", startIndex);

                // 만약 종료 인덱스를 못찾게 되면 쿠키 전체길이로 설정
                if (endIndex == -1) endIndex = cookie.length;

                // 쿠키값을 추출하여 리턴
                return unescape(cookie.substring(startIndex + 1, endIndex));
            } else {
                // 쿠키 내에 해당 쿠키가 존재하지 않을 경우
                return false;
            }
        } else {
            // 쿠키 자체가 없을 경우
            return false;
        }
    }

    function deleteCookie(cookieName) {
        var expireDate = new Date();

        //어제 날짜를 쿠키 소멸 날짜로 설정한다.
        expireDate.setDate(expireDate.getDate() - 1);
        document.cookie = cookieName + "= " + "; expires=" + expireDate.toGMTString() + "; path=/";
    }

    function getRandom() {
        var result = Math.floor(Math.random() * 10) + 1;
        return result;
    }

    function strpos(haystack, needle, offset) {
        // From: http://phpjs.org/functions
        // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
        // +   improved by: Onno Marsman
        // +   bugfixed by: Daniel Esteban
        // +   improved by: Brett Zamir (http://brett-zamir.me)
        // *     example 1: strpos('Kevin van Zonneveld', 'e', 5);
        // *     returns 1: 14
        var i = (haystack + '').indexOf(needle, (offset || 0));
        return i === -1 ? false : i;
    }

    function htmlEntities(str) {
        return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
    }

    function htmlspecialchars_decode(string, quote_style) {
        var optTemp = 0,
            i = 0,
            noquotes = false;
        if (typeof quote_style === 'undefined') {
            quote_style = 2;
        }
        string = string.toString()
            .replace(/&lt;/g, '<')
            .replace(/&gt;/g, '>')
            .replace(/&amp;lt;/g, '<')
            .replace(/&amp;gt;/g, '>');

        var OPTS = {
            'ENT_NOQUOTES': 0,
            'ENT_HTML_QUOTE_SINGLE': 1,
            'ENT_HTML_QUOTE_DOUBLE': 2,
            'ENT_COMPAT': 2,
            'ENT_QUOTES': 3,
            'ENT_IGNORE': 4
        };
        if (quote_style === 0) {
            noquotes = true;
        }
        if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags
            quote_style = [].concat(quote_style);
            for (i = 0; i < quote_style.length; i++) {
                // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
                if (OPTS[quote_style[i]] === 0) {
                    noquotes = true;
                } else if (OPTS[quote_style[i]]) {
                    optTemp = optTemp | OPTS[quote_style[i]];
                }
            }
            quote_style = optTemp;
        }
        if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
            string = string.replace(/&#0*39;/g, "'"); // PHP doesn't currently escape if more than one 0, but it should
            // string = string.replace(/&apos;|&#x0*27;/g, "'"); // This would also be useful here, but not a part of PHP
        }
        if (!noquotes) {
            string = string.replace(/&quot;/g, '"');
        }
        // Put this in last place to avoid escape being double-decoded
        string = string.replace(/&amp;/g, '&');

        return string;
    }

    function explode(delimiter, string, limit) {
        //  discuss at: http://phpjs.org/functions/explode/
        // original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
        //   example 1: explode(' ', 'Kevin van Zonneveld');
        //   returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'}

        if (arguments.length < 2 || typeof delimiter === 'undefined' || typeof string === 'undefined') return null;
        if (delimiter === '' || delimiter === false || delimiter === null) return false;
        if (typeof delimiter === 'function' || typeof delimiter === 'object' || typeof string === 'function' || typeof string ===
            'object') {
            return {
                0: ''
            };
        }
        if (delimiter === true) delimiter = '1';

        // Here we go...
        delimiter += '';
        string += '';

        var s = string.split(delimiter);

        if (typeof limit === 'undefined') return s;

        // Support for limit
        if (limit === 0) limit = 1;

        // Positive limit
        if (limit > 0) {
            if (limit >= s.length) return s;
            return s.slice(0, limit - 1)
                .concat([s.slice(limit - 1)
                    .join(delimiter)
                ]);
        }

        // Negative limit
        if (-limit >= s.length) return [];

        s.splice(s.length + limit);
        return s;
    }

    function microtime(get_as_float) {
        var now = new Date()
            .getTime() / 1000;
        var s = parseInt(now, 10);

        return (get_as_float) ? now * 1000 : (Math.round((now - s) * 1000) / 1000) + ' ' + s;
    }

    function log(r) {
        console.log(r);
    }

    function pathinfo(path, options) {
        //        note: which makes it fully compliant with PHP syntax.
        //  depends on: basename
        //   example 1: pathinfo('/www/htdocs/index.html', 1);
        //   returns 1: '/www/htdocs'
        //   example 2: pathinfo('/www/htdocs/index.html', 'PATHINFO_BASENAME');
        //   returns 2: 'index.html'
        //   example 3: pathinfo('/www/htdocs/index.html', 'PATHINFO_EXTENSION');
        //   returns 3: 'html'
        //   example 4: pathinfo('/www/htdocs/index.html', 'PATHINFO_FILENAME');
        //   returns 4: 'index'
        //   example 5: pathinfo('/www/htdocs/index.html', 2 | 4);
        //   returns 5: {basename: 'index.html', extension: 'html'}
        //   example 6: pathinfo('/www/htdocs/index.html', 'PATHINFO_ALL');
        //   returns 6: {dirname: '/www/htdocs', basename: 'index.html', extension: 'html', filename: 'index'}
        //   example 7: pathinfo('/www/htdocs/index.html');
        //   returns 7: {dirname: '/www/htdocs', basename: 'index.html', extension: 'html', filename: 'index'}
        var opt = '',
            optName = '',
            optTemp = 0,
            tmp_arr = {},
            cnt = 0,
            i = 0;
        var have_basename = false,
            have_extension = false,
            have_filename = false;

        // Input defaulting & sanitation
        if (!path) {
            return false;
        }
        if (!options) {
            options = 'PATHINFO_ALL';
        }

        // Initialize binary arguments. Both the string & integer (constant) input is
        // allowed
        var OPTS = {
            'PATHINFO_DIRNAME': 1,
            'PATHINFO_BASENAME': 2,
            'PATHINFO_EXTENSION': 4,
            'PATHINFO_FILENAME': 8,
            'PATHINFO_ALL': 0
        };

        // PATHINFO_ALL sums up all previously defined PATHINFOs (could just pre-calculate)
        for (optName in OPTS) {
            OPTS.PATHINFO_ALL = OPTS.PATHINFO_ALL | OPTS[optName];
        }
        if (typeof options !== 'number') { // Allow for a single string or an array of string flags
            options = [].concat(options);
            for (i = 0; i < options.length; i++) {
                // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
                if (OPTS[options[i]]) {
                    optTemp = optTemp | OPTS[options[i]];
                }
            }
            options = optTemp;
        }

        // Internal Functions
        var __getExt = function(path) {
            var str = path + '';
            var dotP = str.lastIndexOf('.') + 1;
            return !dotP ? false : dotP !== str.length ? str.substr(dotP) : '';
        };

        function basename(path, suffix) {
            //  discuss at: http://phpjs.org/functions/basename/
            // original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
            // improved by: Ash Searle (http://hexmen.com/blog/)
            // improved by: Lincoln Ramsay
            // improved by: djmix
            // improved by: Dmitry Gorelenkov
            //   example 1: basename('/www/site/home.htm', '.htm');
            //   returns 1: 'home'
            //   example 2: basename('ecra.php?p=1');
            //   returns 2: 'ecra.php?p=1'
            //   example 3: basename('/some/path/');
            //   returns 3: 'path'
            //   example 4: basename('/some/path_ext.ext/','.ext');
            //   returns 4: 'path_ext'

            var b = path;
            var lastChar = b.charAt(b.length - 1);

            if (lastChar === '/' || lastChar === '\\') {
                b = b.slice(0, -1);
            }

            b = b.replace(/^.*[\/\\]/g, '');

            if (typeof suffix === 'string' && b.substr(b.length - suffix.length) == suffix) {
                b = b.substr(0, b.length - suffix.length);
            }
            return b;
        }

        // Gather path infos
        if (options & OPTS.PATHINFO_DIRNAME) {
            var dirName = path.replace(/\\/g, '/')
                .replace(/\/[^\/]*\/?$/, ''); // dirname
            tmp_arr.dirname = dirName === path ? '.' : dirName;
        }

        if (options & OPTS.PATHINFO_BASENAME) {
            if (false === have_basename) {
                have_basename = basename(path);
            }
            tmp_arr.basename = have_basename;
        }

        if (options & OPTS.PATHINFO_EXTENSION) {
            if (false === have_basename) {
                have_basename = basename(path);
            }
            if (false === have_extension) {
                have_extension = __getExt(have_basename);
            }
            if (false !== have_extension) {
                tmp_arr.extension = have_extension;
            }
        }

        if (options & OPTS.PATHINFO_FILENAME) {
            if (false === have_basename) {
                have_basename = basename(path);
            }
            if (false === have_extension) {
                have_extension = __getExt(have_basename);
            }
            if (false === have_filename) {
                have_filename = have_basename.slice(0, have_basename.length - (have_extension ? have_extension.length + 1 :
                    have_extension === false ? 0 : 1));
            }
            tmp_arr.filename = have_filename;
        }

        // If array contains only 1 element: return string
        cnt = 0;
        for (opt in tmp_arr) {
            cnt++;
        }
        if (cnt == 1) {
            return tmp_arr[opt];
        }

        // Return full-blown array
        return tmp_arr;
    }

    function isIE() {
        userAgent = window.navigator.userAgent;
        return userAgent.indexOf("MSIE ") > -1 || userAgent.indexOf("Trident/") > -1 || userAgent.indexOf("Edge/") > -1;
    }

    function isMobile() {
        return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) ? true : false;
    }

    $(document).on('click', '#goto-top-m', function(e) {
        e.preventDefault();
        $('body,html').animate({ scrollTop: 0 }, 400);
    });

    $(window).on('scroll', function() {
        if ($(this).scrollTop() > 50) {
            $('.site-cts-banner, .cl-cts-banner, #ch-plugin').addClass('up');
            $('#goto-top-m, #goto-top-s').addClass('show');
        } else {
            $('.site-cts-banner, .cl-cts-banner, #ch-plugin').removeClass('up');
            $('#goto-top-m, #goto-top-s').removeClass('show');
        }
    });

    $(document).on('click', '.tpl-share-snsPost', function(e) {
        var sns = $(this).attr('data-sns'),
            sid = (typeof SID == 'undefined') ? property.SID : SID,
            host = (typeof HOST == 'undefined') ? property.HOST : HOST,
            view = (typeof VIEW == 'undefined') ? property.VIEW : VIEW,
            page = (property.PAGE).split(','),
            hostname = (host.indexOf('addblock') > -1) ? window.location.host : window.location.hostname;
        url = window.location.protocol + '//' + hostname + '/' + page[0] + '/view/' + view,
            txt = (page[0] == 'forum') ? $('.tpl-forum-title').text() : $('[data-project-title]').text(),
            pageLang = sid.split('__');
        if (pageLang.length > 1) url = window.location.protocol + '//' + hostname + '/_lang/' + pageLang[1] + '/' + page[0] + '/view/' + view;
        sendSns(sns, url, txt);
    });

    function sendSns(sns, url, txt) {
        var img = $('meta[property="og:image"]').attr('content'),
            description = ($('meta[property="og:description"]').length > 0) ? $('meta[property="og:description"]').attr('content') : $('meta[name="description"]').attr('content');

        var o,
            _url = (typeof url == "undefined") ? encodeURIComponent("http://creatorlink.net") : encodeURIComponent(url),
            _txt = (typeof txt == "undefined") ? encodeURIComponent("Make your portfolio site as easily as stacking blocks") : encodeURIComponent(txt),
            _br = encodeURIComponent('\r\n'),
            _img = (typeof img == "undefined") ? 'https://storage.googleapis.com/i.addblock.net/config/aboutVideoImg00.png' : img,
            _kakaolinkurl = (typeof url == "undefined") ? "http://creatorlink.net" : url;

        switch (sns) {
            case 'facebook':
                o = {
                    method: 'popup',
                    url: 'https://www.facebook.com/sharer/sharer.php?u=' + _url + '&t=' + _txt
                };
                break;
            case 'twitter':
                o = {
                    method: 'popup',
                    url: 'http://twitter.com/intent/tweet?text=' + _txt + '&url=' + _url + '&source=' + _url
                };
                break;
            case 'google':
                o = {
                    method: 'popup',
                    url: 'https://plus.google.com/share?url=' + _url
                };
                break;
            case 'pinterest':
                o = {
                    method: 'popup',
                    url: 'http://pinterest.com/pin/create/button/?url=' + _url + '&media=' + _img + '&description=' + _txt
                };
                break;
            case "tumblr":
                o = {
                    method: 'popup',
                    url: 'http://www.tumblr.com/share?v=3&u=' + _url + '&t=creatorlink&s='
                };
                break;
            case "naverblog":
                o = {
                    method: 'popup',
                    url: 'http://share.naver.com/web/shareView.nhn?url=' + _url + '&title=' + _txt
                };
                break;
            case "kakaotalk":
                if (typeof property.SETTINGS.kakaolink != 'undefined') {
                    var kakaolink_key = property.SETTINGS.kakaolink_key;
                    console.log('txt: '+txt);
                    console.log('description: '+description);
                    kakaotalkShare(txt, description, _img, kakaolink_key, _kakaolinkurl);
                } else alert('카카오 API키 오류');
                o = {
                    method: ''
                };
                break;
            case "urlcopy":
                copyToUrlClipboard(url);
                o = {
                    method: ''
                };
                break;
            default:
                o = {
                    method: ''
                };
                break;
        }
        switch (o.method) {
            case "popup":
                var left = (screen.width / 2) - (575 / 2);
                var top = (screen.height / 2) - (575 / 2);
                window.open(o.url, 'Share', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=575, height=575, top=' + top + ', left=' + left);
                break;
            default:
                break;
        }
    }

    function kakaotalkShare(title, content, img, kakaolink_key, url) {
        Kakao.cleanup();
        Kakao.init(kakaolink_key);
        if(Kakao.isInitialized()) {
            Kakao.Share.sendDefault({
                objectType: 'feed',
                content: {
                    title: title,
                    description: content,
                    imageUrl: img,
                    link: {
                        mobileWebUrl: url,
                        webUrl: url
                    }
                },
                buttons: [{
                    title: '웹으로 보기',
                    link: {
                        mobileWebUrl: url,
                        webUrl: url
                    }
                }]
            });
        }
    }

    function copyToUrlClipboard(url) {
        if (window.clipboardData && window.clipboardData.setData) {
            // IE specific code path to prevent textarea being shown while dialog is visible.
            return clipboardData.setData("Text", url);

        } else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
            var textarea = document.createElement("textarea");
            textarea.textContent = url;
            textarea.style.position = "fixed"; // Prevent scrolling to bottom of page in MS Edge.
            document.body.appendChild(textarea);
            textarea.select();
            try {
                return document.execCommand("copy"); // Security exception may be thrown by some browsers.
            } catch (ex) {
                console.warn("Copy to clipboard failed.", ex);
                return false;
            } finally {
                document.body.removeChild(textarea);
                alert($.lang[LANG]['config.sns.urlcopy.alert']);
            }
        }
    }

    function stripslashes(str) {
        return (str + '')
            .replace(/\\(.?)/g, function(s, n1) {
                switch (n1) {
                    case '\\':
                        return '\\';
                    case '0':
                        return '\u0000';
                    case '':
                        return '';
                    default:
                        return n1;
                }
            });
    }

    function isNumber(s) {
        s += '';
        s = s.replace(/^\s*|\s*$/g, '');
        if (s == '' || isNaN(s)) return false;
        return true;
    }

    function saveSelection() {
        if (window.getSelection) {
            sel = window.getSelection();
            if (sel.getRangeAt && sel.rangeCount) {
                return sel.getRangeAt(0);
            }
        } else if (document.selection && document.selection.createRange) {
            return document.selection.createRange();
        }
        return null;
    }

    function restoreSelection(range) {
        if (range) {
            if (window.getSelection) {
                sel = window.getSelection();
                sel.removeAllRanges();
                sel.addRange(range);
            } else if (document.selection && range.select) {
                range.select();
            }
        }
    }

    function getBytes(string) {
        if(string == '') return 0;
        var cnt = 0,
            ch = "";
        for (var i = 0; i < string.length; i++) {
            ch = string.charAt(i);
            if (escape(ch).length > 4) {
                cnt += 2;
            } else {
                cnt += 1;
            }
        }
        return cnt;
    }

    function getWidthPercent(el) {
        var width = parseFloat($(el).css('width')) / parseFloat($(el).parent().css('width'));
        return Math.round(100 * width) + '%';
    }

    // smartresize
    (function($, sr) {

        // debouncing function from John Hann
        // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
        var debounce = function(func, threshold, execAsap) {
                var timeout;

                return function debounced() {
                    var obj = this,
                        args = arguments;

                    function delayed() {
                        if (!execAsap)
                            func.apply(obj, args);
                        timeout = null;
                    };

                    if (timeout)
                        clearTimeout(timeout);
                    else if (execAsap)
                        func.apply(obj, args);

                    timeout = setTimeout(delayed, threshold || 100);
                };
            }
            // smartresize 
        jQuery.fn[sr] = function(fn) { return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); };

    })(jQuery, 'smartresize');

    function emailcheck(email) {
        // var regExp = /[0-9a-zA-Z][_0-9a-zA-Z-]*@[_0-9a-zA-Z-]+(\.[_0-9a-zA-Z-]+){1,2}$/;
        var regExp = /^[a-zA-Z0-9+-\_.]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/;
        if (email.lenght == 0) return false;
        if (!email.match(regExp)) return false;
        return true;
    }

    function shareModal() {
        var title = $('meta[property="og:title"]').attr('content'),
            description = ($('meta[property="og:description"]').length > 0) ? $('meta[property="og:description"]').attr('content') : $('meta[name="description"]').attr('content');
        $(this).showModalFlat($.lang[LANG]['config.sns-share-btn'], snsPost(), false, false, '', '', '', 'cl-modal cl-cmmodal cl-p70 cl-s-btn cl-close-btn cl-t80 w320 share-modal');
    }

    var snsPost = function() {
        str = "" +
            "   <ul class='tpl-share-sns'>";
        if (property.SETTINGS.kakaolink == 'on') {
            str += "<li class='tpl-share-snsPost' data-sns='kakaotalk' id='kakao-link-btn'><span class='share-round'><svg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\"><path d=\"M12 1.89c-6.08 0-11 3.89-11 8.7 0 3.13 2.09 5.87 5.22 7.4 -0.23 0.86-0.83 3.11-0.95 3.59 -0.15 0.6 0.22 0.59 0.46 0.43 0.19-0.13 3.01-2.05 4.23-2.88 0.66 0.1 1.34 0.15 2.04 0.15 6.08 0 11-3.89 11-8.7C23 5.79 18.08 1.89 12 1.89\"/></svg></span> <span class='tpl-share-sns-name'>" + $.lang[LANG]["config.sns.kakaotalk"] + "</span></li>";
        }

        str += "<li class='tpl-share-snsPost' data-sns='facebook'><span class='share-round'><svg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\"><path d=\"M15.64 4.65l2.07 0v-3.5C17.35 1.11 16.12 1 14.69 1c-2.98 0-5.03 1.82-5.03 5.17v2.88H6.29v3.91h3.38V23h4.04V12.96h3.37l0.5-3.91H13.7v-2.5C13.7 5.42 14.02 4.65 15.64 4.65z\"/></svg></span> <span class='tpl-share-sns-name'>" + $.lang[LANG]["config.sns.facebook"] + "</span></li>" +
            "       <li class='tpl-share-snsPost' data-sns='twitter'><span class='share-round'><svg viewBox=\"0 0 20 20\" width=\"20\" height=\"20\"><path d=\"M14.21 16.71h1.53L5.86 3.2H4.22l9.98 13.52Zm.97-15.13h2.76l-6.03 7.14L19 18.43h-5.55L9.1 12.54l-4.98 5.89H1.36l6.45-7.63L1 1.58h5.7l3.93 5.38 4.55-5.38Z\"/></svg></span> <span class='tpl-share-sns-name'>" + $.lang[LANG]["config.sns.twitter"] + "</span></li>" +
            "       <li class='tpl-share-snsPost' data-sns='naverblog'><span class='share-round'><svg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\"><path d=\"M18.49 10.29c-0.48 0-0.87 0.39-0.87 0.87 0 0.48 0.39 0.87 0.87 0.87 0.48 0 0.87-0.39 0.87-0.87C19.36 10.68 18.97 10.29 18.49 10.29z\"/><path d=\"M13.3 10.29c-0.48 0-0.87 0.39-0.87 0.87 0 0.48 0.39 0.87 0.87 0.87 0.48 0 0.87-0.39 0.87-0.87C14.17 10.68 13.78 10.29 13.3 10.29z\"/><path d=\"M5.59 10.29c-0.48 0-0.87 0.39-0.87 0.87 0 0.48 0.39 0.87 0.87 0.87 0.48 0 0.87-0.39 0.87-0.87C6.45 10.68 6.07 10.29 5.59 10.29z\"/><path d=\"M19.53 3H4.47C2.56 3 1 4.56 1 6.49v8.27c0 1.93 1.56 3.49 3.47 3.49h5.18l1.77 2.88c0 0 0.02 0.03 0.06 0.08 0.1 0.18 0.29 0.3 0.51 0.3 0.22 0 0.41-0.12 0.51-0.29 0.04-0.05 0.06-0.09 0.06-0.09l1.77-2.88h5.18c1.92 0 3.47-1.56 3.47-3.49V6.49C23 4.56 21.44 3 19.53 3zM5.89 13.21c-0.81 0-1.13-0.58-1.13-0.58v0.44H3.39V7.46h1.35v2.14c0.54-0.53 1.14-0.53 1.14-0.53 1.83 0 1.9 2.05 1.9 2.05C7.78 13.14 5.89 13.21 5.89 13.21zM10.13 9.44v3.63h-1.3V9.75c0-1.14-0.61-1.12-0.61-1.12v-1.3C10.19 7.33 10.13 9.44 10.13 9.44zM15.58 11.16c0 2.05-2.28 2.05-2.28 2.05 -2.3 0-2.23-2.05-2.23-2.05 0-2.08 2.23-2.08 2.23-2.08C15.65 9.08 15.58 11.16 15.58 11.16zM20.61 13.01c0 2.13-1.97 2.1-1.97 2.1h-0.52v-1.19h0.32c0.95 0 0.86-0.98 0.86-0.98v-0.31c-0.42 0.54-1.18 0.51-1.18 0.51 -1.87 0-1.85-2-1.85-2 0-2.14 1.91-2.06 1.91-2.06 0.74 0 1.13 0.51 1.13 0.51V9.21h1.31V13.01z\"/></svg></span> <span class='tpl-share-sns-name'>" + $.lang[LANG]["config.sns.naverblog"] + "</span></li>" +
            "       <li class='tpl-share-snsPost' data-sns='urlcopy'><span class='share-round'><svg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\"><path d=\"M8.71 18.87c-0.48 0.48-1.11 0.74-1.79 0.74s-1.31-0.26-1.79-0.74c-0.99-0.99-0.99-2.59 0-3.58l4.15-4.15c0.48-0.48 1.11-0.74 1.79-0.74 0.68 0 1.31 0.26 1.79 0.74l0.98-0.98c-0.76-0.76-1.77-1.15-2.77-1.15s-2 0.38-2.77 1.15l-4.15 4.15c-1.53 1.53-1.53 4.01 0 5.54C4.91 20.62 5.91 21 6.92 21s2-0.38 2.77-1.15l2.08-2.08 -0.98-0.98L8.71 18.87z\"/><path d=\"M19.85 4.15C19.09 3.38 18.09 3 17.08 3c-1 0-2 0.38-2.77 1.15l-2.08 2.08 0.98 0.98 2.08-2.08c0.48-0.48 1.11-0.74 1.79-0.74s1.31 0.26 1.79 0.74c0.99 0.99 0.99 2.59 0 3.58l-4.15 4.15c-0.48 0.48-1.11 0.74-1.79 0.74 -0.68 0-1.31-0.26-1.79-0.74l-0.98 0.98c0.76 0.76 1.77 1.15 2.77 1.15s2-0.38 2.77-1.15l4.15-4.15C21.38 8.16 21.38 5.68 19.85 4.15z\"/></svg></span> <span class='tpl-share-sns-name'>" + $.lang[LANG]["config.sns.urlcopy"] + "</span></li>" +
            "       <!--<li class='tpl-share-snsPost' data-sns='google'><i class='fa fa-google-plus-square'></i> <span class='tpl-share-sns-name'>" + $.lang[LANG]["config.sns.google"] + "</span></li>" +
            "       <li class='tpl-share-snsPost' data-sns='pinterest'><i class='fa fa-pinterest-square'></i> <span class='tpl-share-sns-name'>" + $.lang[LANG]["config.sns.pinterest"] + "</span></li>" +
            "       <li class='tpl-share-snsPost' data-sns='tumblr'><i class='fa fa-tumblr-square'></i> <span class='tpl-share-sns-name'>" + $.lang[LANG]["config.sns.tumblr"] + "</span></li>-->" +
            "   </ul>" +
            "";
        return str;
    }

    var displayPageToolbar = function(option, settings) {
        var deferred = $.Deferred();
        if (typeof option == 'undefined') option = '';
        if (typeof settings == 'undefined') settings = '';

        var menu_lock = (PAGE_MODE == 'c') ? '' : property.ISLOCK,
            toolbar_class = (typeof menu_lock != 'undefined' && menu_lock == 'true') ? 'hide' : '';
        var like = getLike();
        var heart = '';
        var like_id = '';
        var likeCnt = 0;
        like.done(function(data) {
            // console.log(data);
            if (typeof data.own != 'undefined' && data.own) {
                like_id = data.view;
                heart = 'active';
            }
            likeCnt = data.cnt;
        });

        if ($('.tpl-forum-list-footer').length) { //forum
            var f_lang = (typeof settings.chlang != 'undefined' && settings.chlang)? settings.chlang : LANG;
            var str = '\
                <ul class="tpl-page-toolbar ' + toolbar_class + '" data-page-option="' + option + '">' +
                '<li class="tpl-forum-toolbar-button like hide">\
                        <button type="button" class="btn btn-default btn-round ' + heart + '" data-like="' + like_id + '">\
                            <svg viewBox="0 0 28 28" width="28" height="28"><path d="m22.76 14.7-8.74 8.97-8.75-8.97m0 0c-2.31-2.32-2.37-6.14-.13-8.53 2.24-2.4 5.93-2.46 8.24-.14.23.23.44.48.63.75 1.93-2.67 5.59-3.2 8.16-1.2s3.09 5.79 1.16 8.45c-.18.24-.37.47-.58.68"></path><path d="M14.01 24.57c-.24 0-.48-.1-.64-.27l-8.74-8.97c-2.64-2.66-2.71-7.04-.15-9.78a6.576 6.576 0 0 1 4.74-2.12c1.79-.01 3.5.67 4.8 1.96a6.576 6.576 0 0 1 3.74-1.86c1.77-.25 3.54.22 4.97 1.34 2.95 2.29 3.55 6.64 1.33 9.69-.2.28-.42.54-.66.78l-.06.06-8.68 8.9c-.17.17-.4.27-.65.27zm-8.1-10.51c0 .01.01.01 0 0l8.1 8.32 8.1-8.31.06-.06c.15-.16.3-.33.43-.52 1.65-2.27 1.21-5.51-.98-7.22a4.723 4.723 0 0 0-3.61-.97c-1.31.2-2.47.91-3.27 2a.91.91 0 0 1-.73.37c-.29 0-.56-.14-.73-.38-.16-.22-.34-.44-.54-.64a4.78 4.78 0 0 0-3.49-1.43A4.83 4.83 0 0 0 5.8 6.78c-1.91 2.04-1.86 5.31.11 7.28z"></path></svg>\
                            <span class="forum-like-cnt">' + likeCnt + '</span>\
                        </button>\
                    </li>' +
                // '<li class="tpl-forum-toolbar-button"><i class="fa fa-thumb-tack"></i></li>' +
                '<li class="tpl-forum-toolbar-button share hide"><button type="button" class="btn btn-default btn-round">' + $.lang[f_lang]['board.button.share'] + '</span></button></li>\
                </ul>\
            ';
            if ($('.tpl-forum-list-footer .tpl-forum-toolbar-button').length == 0) $('.tpl-forum-list-footer').prepend(str);
        } else { //gallery
            var g_btn_prev = ($('.data-page-prev').hasClass('active')) ? 'active' : '',
                g_btn_next = ($('.data-page-next').hasClass('active')) ? 'active' : '',
                g_toolbar = '\
                    <div class="tpl-page-toolbar ' + toolbar_class + '" data-page-option="' + option + '" style="width: 100%;">\
                        <div class="pull-left tpl-forum-toolbar-button share hide">\
                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="28" height="28"><path d="M21 17c-1.24 0-2.33.58-3.07 1.46l-7.05-3.53c.07-.3.12-.61.12-.93s-.05-.63-.12-.93l7.05-3.53c.74.88 1.83 1.46 3.07 1.46 2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4c0 .32.05.63.12.93l-7.05 3.53C9.33 10.58 8.24 10 7 10c-2.21 0-4 1.79-4 4s1.79 4 4 4c1.24 0 2.33-.58 3.07-1.46l7.05 3.53c-.07.3-.12.61-.12.93 0 2.21 1.79 4 4 4s4-1.79 4-4-1.79-4-4-4zm0-12.2c1.21 0 2.2.99 2.2 2.2s-.99 2.2-2.2 2.2-2.2-.99-2.2-2.2.99-2.2 2.2-2.2zM7 16.2c-1.21 0-2.2-.99-2.2-2.2s.99-2.2 2.2-2.2 2.2.99 2.2 2.2-.99 2.2-2.2 2.2zm14 7c-1.21 0-2.2-.99-2.2-2.2s.99-2.2 2.2-2.2 2.2.99 2.2 2.2-.99 2.2-2.2 2.2z"></path></svg>\
                        </div>\
                        <div class="pull-left tpl-forum-toolbar-button like hide ' + heart + '" data-like="' + like_id + '">\
                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="28" height="28">\
                                <path d="m22.76 14.7-8.74 8.97-8.75-8.97m0 0c-2.31-2.32-2.37-6.14-.13-8.53 2.24-2.4 5.93-2.46 8.24-.14.23.23.44.48.63.75 1.93-2.67 5.59-3.2 8.16-1.2s3.09 5.79 1.16 8.45c-.18.24-.37.47-.58.68"></path>\
                                <path d="M14.01 24.57c-.24 0-.48-.1-.64-.27l-8.74-8.97c-2.64-2.66-2.71-7.04-.15-9.78a6.576 6.576 0 0 1 4.74-2.12c1.79-.01 3.5.67 4.8 1.96a6.576 6.576 0 0 1 3.74-1.86c1.77-.25 3.54.22 4.97 1.34 2.95 2.29 3.55 6.64 1.33 9.69-.2.28-.42.54-.66.78l-.06.06-8.68 8.9c-.17.17-.4.27-.65.27zm-8.1-10.51c0 .01.01.01 0 0l8.1 8.32 8.1-8.31.06-.06c.15-.16.3-.33.43-.52 1.65-2.27 1.21-5.51-.98-7.22a4.723 4.723 0 0 0-3.61-.97c-1.31.2-2.47.91-3.27 2a.91.91 0 0 1-.73.37c-.29 0-.56-.14-.73-.38-.16-.22-.34-.44-.54-.64a4.78 4.78 0 0 0-3.49-1.43A4.83 4.83 0 0 0 5.8 6.78c-1.91 2.04-1.86 5.31.11 7.28z"></path>\
                            </svg>\
                            <span class="forum-like-cnt">' + likeCnt + '</span>\
                        </div>\
                        <div class="bottom-navigation hide">\
                            <div class="pull-right tpl-project-toolbar-button data-page-next ' + g_btn_next + '"><svg viewBox="0 0 24 24" width="24" height="24"><path d="M10.64 18.64l-1.28-1.28L14.73 12 9.36 6.64l1.28-1.28L17.27 12z"/></svg></div>\
                            <div class="pull-right tpl-project-toolbar-button data-page-prev ' + g_btn_prev + '"><svg viewBox="0 0 24 24" width="24" height="24"><path d="M13.36 18.64L6.73 12l6.63-6.64 1.28 1.28L9.27 12l5.37 5.36z"/></svg></div>\
                            <div class="pull-right tpl-project-toolbar-button data-page-back"><svg viewBox="0 0 24 24" width="24" height="24"><g><path d="M4 6h16v2H4zM4 11h16v2H4zM4 16h16v2H4z"/></g></svg></div>\
                        </div>\
                    </div>\
                ';

            var $wrap = $('<div class="tpl-page-footer hide">');
            $wrap.append('<div class="container"><div class="row"><div class="col-md-12 col-sm-12 col-xs-12 tpl-page-footer-wrap"></div></div></div>');
            $wrap.find('.tpl-page-footer-wrap').append(g_toolbar);
            $wrap.css({
                'background-color': 'transparent',
                'padding': '30px 0px'
            });

            if (PAGE_MODE == 'c') {
                $lastEl = ($('.el-footer_ctrl').length) ? $('.el-footer_ctrl') : $('.add-footer-information');
                $lastEl.before($wrap);
                if($('.el-fixedcontact').length) {
                    var fixedContactEL = $('.el-fixedcontact').attr('data-el');
                    $('.el-footer_ctrl').before($('.' + fixedContactEL + '_ctrl'));
                    $('.el-footer_ctrl').before($('.el-fixedcontact'));
                }
            } else {
                $('.el-footer').before($wrap);
            }

            var parentMode = (PAGE_MODE == 'c') ? PARENT.mode : property.PARENT.mode;
            var checkGalleryProjectClass = (parentMode == 'project') ? 'galProjectBg' : '';
            var g_color = (typeof $('.dsgn-body').attr('data-gcolor') != 'undefined') ? $('.dsgn-body').attr('data-gcolor') : '';
            if (g_color) {
                var galProjectCssStr = ($('.galProjectCss').length > 0) ? $('.galProjectCss').text() : '';
                galProjectCssStr += '.dsgn-body[data-gcolor="' + g_color + '"] .galProjectBg svg {fill: '+Coloris.getChangeColorVal(g_color,'a',0.6)+';}\n';
                $('.galProjectCss').text(galProjectCssStr);
            }
        }

        var f_color = ($('.forum-view').attr('data-fcolor')) ? $('.forum-view').attr('data-fcolor') : '#000000';
        $('.forum-write .tpl-forum-list-footer button').css('border-color', Coloris.getChangeColorVal(f_color,'a',0.4));
        $('.forum-write .tpl-forum-list-footer button').css('color', Coloris.getChangeColorVal(f_color,'a',0.8));

        if ($('.tpl-forum-list-footer .tpl-page-toolbar li.like').length > 0) {
            var f_like_color = ($('.forum-view').attr('data-fcolor-like')) ? $('.forum-view').attr('data-fcolor-like') : f_color;
            $('.tpl-forum-list-footer .tpl-page-toolbar li.like button').css('border-color', Coloris.getChangeColorVal(f_like_color,'a',0.4));
            $('.tpl-forum-list-footer .tpl-page-toolbar li.like button').css('color', Coloris.getChangeColorVal(f_like_color,'a',0.8));
        }

        deferred.resolve($('.tpl-page-footer'));
        return deferred.promise();
    }

    var getLike = function(view) {
        var deferred = $.Deferred();
        var lSID = (PAGE_MODE == 'c') ? SID : property.SID,
            lPARENT = (PAGE_MODE == 'c') ? PARENT : property.PARENT,
            lVIEW = (PAGE_MODE == 'c') ? VIEW : property.VIEW;
        var type = (lPARENT.mode) ? 'P' : 'F';

        if (view !== undefined && view) {
            type = 'P';
            lPARENT = '';
            lVIEW = view;
        }

        $.ajax({
            type: 'post',
            url: '/template/like/get',
            data: { type: type, view: lVIEW, sid: lSID },
            dataType: 'json',
            async: false,
            success: function(data) {
                deferred.resolve(data);
            }
        });

        return deferred.promise();
    }

    var setLike = function(el, mode) {
        if (typeof MODE !== 'undefined' && MODE == 'demo') return false;
        var umemberActivate = (PAGE_MODE == 'c') ? Number(UMEMBER_ACTIVATE) : Number(property.UMEMBER_ACTIVATE);
        var checkLogin = (PAGE_MODE == 'c') ? true : false;
        var view = (PAGE_MODE == 'c') ? VIEW : property.VIEW;
        var parent = (PAGE_MODE == 'c') ? PARENT : property.PARENT;
        var sid = (PAGE_MODE == 'c') ? SID : property.SID;

        var cm_id = '';
        var elsettings = {};
        var $this = el;

        if (PAGE_MODE == 's') {
            var umember = property.UMEMBER;
            checkLogin = umember.check_login;

            if (umemberActivate == 0 && umember.id_type == 'creatorlink') { //creatorlink login
                checkLogin = (umember.id !== undefined && umember.id) ? true : false;
            }

            if ($('#write-login').length > 0) $('#write-login').remove();

            if (parent.page) {
                elsettings = JSON.parse(parent.settings);
            } else {
                var parent_id = ($this.hasClass('gallery-like')) ? $this.closest('.blueimp-gallery').attr('id').replace('gframe-', '') : $this.closest('.element').attr('data-id');
                var el_idx = $('.element[data-id="' + parent_id + '"]').attr('data-el').replace('el_', '')
                var el_target = property.INITPAGE[el_idx];
                elsettings = JSON.parse(el_target.elsettings);
            }

            var like_level = (elsettings.like_level !== undefined && elsettings.like_level) ? elsettings.like_level : 'A';
            if (mode == 'comment') {
                like_level = (elsettings.likeComment_level !== undefined && elsettings.likeComment_level) ? elsettings.likeComment_level : 'A';
            }

            if (like_level == 'M' && checkLogin == false) {
                if (confirm($.lang[LANG]['config.like.onlylogin'])) {
                    var action = (property.VALIDTYPE == 'SM') ? '/_login' : '/_cllogin';
                    var url = $(location).attr('pathname');
                    var html = '<form name="write_login_form" id="write-login" method="post" action="' + action + '" style="display:none;">\
                                    <input type="hidden" name="status" value="like">\
                                    <input type="hidden" name="sid" value="' + property.SID + '">\
                                    <input type="hidden" name="url" value="' + url + '">\
                                </form>';
                    $('body').append(html);
                    document.write_login_form.submit();
                }
                return false;
            }
        }

        var like_id = $this.attr('data-like');
        var cnt = 0;

        if (mode == 'list') {
            like_id = $this.closest('.figure.like').attr('data-like');
        }
        $this.addClass('disabled');
        var type = (parent.mode)? 'P':'F';
        var pid = parent.pid;
        switch (mode) {
            case 'gallery':
                type = 'P';
                pid = '';
                view = $this.attr('data-seq');
                break;
            case 'list':
                type = 'P';
                pid = '';
                view = $this.closest('.gallery-item').attr('data-seq');
                break;
            case 'comment':
                type += 'C';
                view = $this.closest('.page-comments').attr('data-id');
                cm_id = $this.attr('data-id');
                break;
        }

        if (like_id !== undefined && like_id) { //delete like
            $.ajax({
                type: 'post',
                url: '/template/like/delete',
                data: { type: type, view: like_id, sid: sid, pid: pid, cm_id: cm_id },
                dataType: 'json',
                async: true,
                success: function(data) {
                    $this.removeClass('disabled');
                    switch (mode) {
                        case 'list':
                            $this.closest('.figure.like').removeClass('active').removeAttr('data-like');
                            $this.closest('.figure.like').find('.figure-like-cnt').text(data.cnt);
                            break;

                        case 'gallery':
                            $this.removeClass('active').removeAttr('data-like');
                            view = $this.attr('data-seq');
                            var $figureLike = $('.gallery-item[data-seq="' + view + '"] .figure.like');
                            cnt = $figureLike.find('.figure-like-cnt').text();
                            // console.log('$figureLike', $figureLike, cnt);
                            $figureLike.removeClass('active').removeAttr('data-like');
                            $figureLike.find('.figure-like-cnt').text(data.cnt);
                            break;

                        case 'project':
                            $this.removeClass('active').removeAttr('data-like');
                            $this.find('.forum-like-cnt').text(data.cnt);
                            break;

                        case 'forum':
                            $this.removeClass('active').removeAttr('data-like');
                            $this.find('.forum-like-cnt').text(data.cnt);

                            if ($('.page-bottomlist').length > 0) {
                                $('.tpl-forum-list-like[data-id="' + view + '"]').removeClass('active').removeAttr('data-like');
                                if ($('.tpl-forum-list-like[data-id="' + view + '"]').is('td') && $('.tpl-forum-list-like[data-id="' + view + '"] .forum-like-cnt').length == 0) {
                                    $('.tpl-forum-list-like[data-id="' + view + '"]').text(data.cnt);
                                } else {
                                    $('.tpl-forum-list-like[data-id="' + view + '"] .forum-like-cnt').text(data.cnt);
                                }
                            }
                            break;

                        case 'comment':
                            $this.removeClass('active').removeAttr('data-like');
                            $this.find('.cm-like-cnt').text(data.cnt);

                            break;

                        default:
                            break;
                    }
                }
            });
        } else { //insert like
            $.ajax({
                type: 'post',
                url: '/template/like/update',
                data: { type: type, view: view, sid: sid, pid: pid, cm_id: cm_id },
                dataType: 'json',
                async: true,
                success: function(data) {
                    $this.removeClass('disabled');
                    switch (mode) {
                        case 'list':
                            $this.closest('.figure.like').addClass('active').attr('data-like', view);
                            $this.closest('.figure.like').find('.figure-like-cnt').text(data.cnt);

                            break;

                        case 'gallery':
                            $this.addClass('active').attr('data-like', view);

                            var $figureLike = $('.gallery-item[data-seq="' + view + '"] .figure.like');
                            cnt = $figureLike.find('.figure-like-cnt').text();

                            $figureLike.addClass('active').attr('data-like', view);
                            $figureLike.find('.figure-like-cnt').text(data.cnt);

                            break;

                        case 'project':
                            $this.addClass('active').attr('data-like', view);
                            $this.find('.forum-like-cnt').text(data.cnt);
                            break;

                        case 'forum':
                            $this.addClass('active').attr('data-like', view);
                            $this.find('.forum-like-cnt').text(data.cnt);

                            if ($('.page-bottomlist').length > 0) {
                                $('.tpl-forum-list-like[data-id="' + view + '"]').addClass('active').attr('data-like', view);
                                if ($('.tpl-forum-list-like[data-id="' + view + '"]').is('td') && $('.tpl-forum-list-like[data-id="' + view + '"] .forum-like-cnt').length == 0) {
                                    $('.tpl-forum-list-like[data-id="' + view + '"]').text(data.cnt);
                                } else {
                                    $('.tpl-forum-list-like[data-id="' + view + '"] .forum-like-cnt').text(data.cnt);
                                }
                            }
                            break;

                        case 'comment':
                            $this.addClass('active').attr('data-like', view);
                            $this.find('.cm-like-cnt').text(data.cnt);

                            break;

                        default:
                            break;
                    }
                }
            });
        }
    }

    var imgPopupFrame = function (el) {
        $('#imgPopupFrame').remove();
        var href = (typeof el == 'string')? el : $(el).attr('href');
        var imgSrc = (href.indexOf('googleusercontent') > -1)? getServeImage(href, 0, '') : href;
        var str = '\
            <div id="imgPopupFrame">\
                <div class="image-popup"><img src="'+imgSrc+'" onerror="this.src=\'//storage.googleapis.com/i.addblock.net/img_broken_fill_500.png\'"></div>\
                <div class="zoomable hide"></div>\
                <a class="close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22" width="22" height="22"><polygon points="22 1.06 20.94 0 11 9.94 1.06 0 0 1.06 9.94 11 0 20.94 1.06 22 11 12.06 20.94 22 22 20.94 12.06 11 "/></svg></a>\
                <a class="zoom-in" data-toggle="tooltip" data-placement="bottom" data-html="true" data-original-title="확대"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M24 22.94l-6.42-6.42C19.08 14.76 20 12.49 20 10c0-5.52-4.48-10-10-10S0 4.48 0 10s4.48 10 10 10c2.49 0 4.76-0.92 6.52-2.42L22.94 24 24 22.94zM1.5 10c0-4.69 3.81-8.5 8.5-8.5 4.69 0 8.5 3.81 8.5 8.5s-3.81 8.5-8.5 8.5C5.31 18.5 1.5 14.69 1.5 10z"/><polygon points="10.75 6 9.25 6 9.25 9.25 6 9.25 6 10.75 9.25 10.75 9.25 14 10.75 14 10.75 10.75 14 10.75 14 9.25 10.75 9.25 "/></svg></a>\
                <a class="zoom-out disabled" data-toggle="tooltip" data-placement="bottom" data-html="true" data-original-title="축소"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 23 23" width="23" height="23"><g><path d="m23 21.98-6.16-6.16a9.566 9.566 0 0 0 2.32-6.24C19.17 4.29 14.88 0 9.58 0S0 4.29 0 9.58s4.29 9.58 9.58 9.58c2.39 0 4.57-.88 6.24-2.32L21.98 23 23 21.98zM1.44 9.58c0-4.49 3.65-8.15 8.15-8.15 4.49 0 8.15 3.65 8.15 8.15s-3.65 8.15-8.15 8.15-8.15-3.66-8.15-8.15z"/><path d="M5.75 8.86h7.67v1.44H5.75z"/></g></svg></a>\
                <a class="view-original disabled" data-toggle="tooltip" data-placement="bottom" data-html="true" data-original-title="화면 크기에 맞춰 확대">\
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 27 27" width="27" height="27"><g><path d="M1 4.12v18.75h25V4.12H1zm23.5 17.26h-22V5.62h22v15.76z"/><path d="M8.03 18.19h1.56V8.81H6.47v1.57h1.56zM12.72 10.38h1.56v1.56h-1.56zM12.72 15.06h1.56v1.56h-1.56zM18.19 18.19h1.56V8.81h-3.13v1.57h1.57z"/></g></svg>\
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 27 27" width="27" height="27"><path d="M24.03 4.03 24 4V3h-1l-.03-.03-.03.03H13.5v1.5h7.94L4.5 21.44V13.5H3v9.44l-.03.03L3 23v1h1l.03.03.03-.03h9.44v-1.5H5.56L22.5 5.56v7.94H24V4.06z"/></svg>\
                </a>\
            </div>\
        ';
        
        $('.dsgn-body').append(str);

        setTimeout(function(){
            $('#imgPopupFrame').addClass('imgPopup-display');

            var currentWidth = $('#imgPopupFrame .image-popup img').width();
            if(currentWidth >= $(window).width()) {
                $('#imgPopupFrame .view-original').addClass('disabled');
            } else {
                $('#imgPopupFrame .view-original').removeClass('disabled');
            }
            setImgPopupIconTooltip($('#imgPopupFrame'));
        }, 500);
    }

    var setImgPopupIconTooltip = function(el){
        $(el).find('.zoom-in, .zoom-out, .view-original, .view-original.fullscreen').attr({
            'data-toggle': 'tooltip',
            'data-placement': 'bottom',
            'data-html': 'true',
        });

        $(el).find('.zoom-in').attr('data-original-title', $.lang[LANG]['gallery.slide.tooltip.zoom-in']);
        $(el).find('.zoom-out').attr('data-original-title', $.lang[LANG]['gallery.slide.tooltip.zoom-out']);

        $(el).find('.view-original').attr('data-original-title', $.lang[LANG]['gallery.slide.view-fullscreen']);
        if($(el).find('.view-original').hasClass('fullscreen')) {
            $(el).find('.view-original').attr('data-original-title', $.lang[LANG]['gallery.slide.tooltip.view-original']);
        } else {
            $(el).find('.view-original').attr('data-original-title', $.lang[LANG]['gallery.slide.tooltip.view-fullscreen']);
        }
    }

    var setPopupImgScale = function(el, scale) {
        var $img = el.find('img');
        var currentWidth = $img.width();
        var currentHeight = $img.height();

        var zoomable = el.find('.zoomable');

        if(zoomable.find('img').length == 0) {
            var $cloneImg = el.find('img').clone();
            $cloneImg.addClass('clone').attr('data-width', currentWidth).attr('data-height', currentHeight);
            zoomable.append($cloneImg);
        }
        var zoomableImg = zoomable.find('img');

        var windowWidth = $(window).width();
        var windowHeight = $(window).height();
        var scaledWidth = currentWidth * scale;
        var scaledHeight = currentHeight * scale;

        var scrollTop = zoomable.scrollTop();
        var scrollLeft = zoomable.scrollLeft();

        var offsetX = ((windowWidth - currentWidth) > 0) ? (windowWidth - currentWidth) * 0.5 : 0;
        var offsetY = ((windowHeight - currentHeight) > 0) ? (windowHeight - currentHeight) * 0.5 : 0;
        var scaledOffsetX = ((windowWidth - scaledWidth - 8) > 0) ? (windowWidth - scaledWidth - 8) * 0.5 : 0;
        var scaledOffsetY = ((windowHeight - scaledHeight) > 0) ? (windowHeight - scaledHeight) * 0.5 : 0;
        var offset = {top: scaledOffsetY + 'px', left: scaledOffsetX + 'px'};
        var isScroll = false;
        var centerX = 0;
        var centerY = 0;
        var scrollPositionX = 0;
        var scrollPositionY = 0;

        zoomable.removeClass('scroll');
        if(scaledWidth > windowWidth) {
            zoomable.css('width', scaledWidth);
            isScroll = true;
            offset = {top: scaledOffsetY+'px', left: 0};
        }

        if(scaledHeight > windowHeight) {
            zoomable.css('height', scaledHeight);
            isScroll = true;
            offset = {top: 0, left: scaledOffsetX+'px'};
        } 

        if(scaledWidth >= windowWidth && scaledHeight >= windowHeight) {
            offset = {top: 0, left: 0};
        }

        if(isScroll) {
            zoomable.addClass('scroll');
            var scrollOffsetX = scaledWidth - windowWidth;
            var scrollOffsetY = scaledHeight - windowHeight;
            centerX = (scrollOffsetX - 8) * 0.5;
            centerY = (scrollOffsetY - 8) * 0.5;
            
            scrollPositionX = (zoomable.attr('data-scroll-left') !== undefined)? Number(zoomable.attr('data-scroll-left')) * scrollOffsetX : centerX;
            scrollPositionY = (zoomable.attr('data-scroll-top') !== undefined)? Number(zoomable.attr('data-scroll-top')) * scrollOffsetY : centerY;
        }

        var scaleAnimation = Object.assign({}, offset, {width: scaledWidth+'px', height: scaledHeight+'px', scrollLeft: scrollPositionX, scrollTop: scrollPositionY});

        if (scale > 1) {    
            $('#imgPopupFrame a.zoom-out').removeClass('disabled');
            zoomable.removeClass('hide');
            var zoomWidth = zoomableImg.attr('data-width');
            var zoomHeight = zoomableImg.attr('data-height');
            var initialWidth = zoomableImg.width();
            var initialHeight = zoomableImg.height();

            if(Number(zoomWidth) == currentWidth) {
                zoomableImg.css({width: currentWidth+'px', height: currentHeight+'px', top: offsetY+'px', left: offsetX+'px'});
            }

            zoomable.addClass('visible');
            setTimeout(function(){
                el.addClass('fullscreen');
                
                zoomableImg.animate(scaleAnimation, 200);
                // console.log(initialWidth, scaledWidth);
                if(initialWidth < windowWidth && scaledWidth > windowWidth) {
                    scrollPositionX = centerX;
                    var scrollLeft = centerX / (scaledWidth - windowWidth);
                    zoomable.attr({'data-scroll-left': scrollLeft});
                }
                if(initialHeight < windowHeight && scaledHeight > windowHeight) {
                    scrollPositionY = centerY;
                    var scrollTop = centerY / (scaledHeight - windowHeight);
                    zoomable.attr({'data-scroll-top': scrollTop});
                }

                zoomable.animate({scrollLeft: scrollPositionX, scrollTop: scrollPositionY}, 200); //scroll

                // if(scaledWidth >= windowWidth && scaledHeight >= windowHeight) zoomable.animate({scrollLeft: scrollPositionX, scrollTop: scrollPositionY}, 500);

                zoomableImg.attr('data-scale', scale).attr('data-width', scaledWidth).attr('data-height', scaledHeight);

                var isDragging = false;
                var lastX, lastY;
                zoomable.off('mousedown mousemove mouseup scroll');
                zoomable.on("mousedown", function(e) {
                    isDragging = true;
                    lastX = e.clientX;
                    lastY = e.clientY;
                    $(this).addClass('dragging');
                    e.preventDefault();
                    e.stopPropagation();

                }).on("mousemove", function(e) {
                    if (isDragging) {
                        var deltaX = e.clientX - lastX;
                        var deltaY = e.clientY - lastY;
                        $(this).scrollLeft($(this).scrollLeft() - deltaX);
                        $(this).scrollTop($(this).scrollTop() - deltaY);
                        lastX = e.clientX;
                        lastY = e.clientY;
                        e.preventDefault();
                        e.stopPropagation();
                    }
                }).on("mouseup", function() {
                    isDragging = false;
                    $(this).removeClass('dragging');

                    var scrollLeft = (($(this)[0].scrollWidth - $(this)[0].clientWidth) > 0) ? $(this).scrollLeft() / ($(this)[0].scrollWidth - $(this)[0].clientWidth) : 0;  // 가로 스크롤 좌표
                    var scrollTop = (($(this)[0].scrollHeight - $(this)[0].clientHeight) > 0) ? $(this).scrollTop() / ($(this)[0].scrollHeight - $(this)[0].clientHeight) : 0;    // 세로 스크롤 좌표

                    zoomable.attr({'data-scroll-top': scrollTop, 'data-scroll-left': scrollLeft});
                    // console.log("가로 스크롤 좌표: " + scrollLeft);
                    // console.log("세로 스크롤 좌표: " + scrollTop);
                });

                zoomable.on('mousewheel', function(e){
                    var scrollLeft = (($(this)[0].scrollWidth - $(this)[0].clientWidth) > 0) ? $(this).scrollLeft() / ($(this)[0].scrollWidth - $(this)[0].clientWidth) : 0;  // 가로 스크롤 좌표
                    var scrollTop = (($(this)[0].scrollHeight - $(this)[0].clientHeight) > 0) ? $(this).scrollTop() / ($(this)[0].scrollHeight - $(this)[0].clientHeight) : 0;    // 세로 스크롤 좌표

                    zoomable.attr({'data-scroll-top': scrollTop, 'data-scroll-left': scrollLeft});
                    // console.log("가로 스크롤 좌표: " + scrollLeft);
                    // console.log("세로 스크롤 좌표: " + scrollTop);
                });
            }, 100);
        } else { //원본 크기
            zoomableImg.animate(scaleAnimation, 200);
            zoomable.animate({scrollLeft: scrollPositionX, scrollTop: scrollPositionY}, 200);

            $('#imgPopupFrame a.zoom-out').addClass('disabled');
            $('#imgPopupFrame a.view-original').removeClass('fullscreen');

            if(scaledWidth == $(window).width()) {
                $('#imgPopupFrame a.view-original').addClass('disabled');
            }

            setTimeout(function(){
                el.removeClass('fullscreen');
            }, 100);
            setTimeout(function(){
                zoomable.removeClass('visible').addClass('hide');
                zoomable.removeAttr('data-scroll-top data-scroll-left')
                zoomableImg.remove();
            }, 200);
        }
    
        
    }

    var drawBadgeList = function(use_badge, badge_settings) {
        var badgeList = '';
        if(typeof badge_settings == 'undefined' || !badge_settings) {
            badge_settings = {}
        }
        if(typeof use_badge != 'undefined' && use_badge) {
            var badgeCnt = use_badge.length;
            $.each(use_badge, function(idx, b){
                var bsettings = (typeof badge_settings[b] != 'undefined')? badge_settings[b] : {};
                var badgeType = (typeof bsettings.type != 'undefined' && bsettings.type)? bsettings.type : 'edit';
                var badgeStyle = (typeof bsettings.style != 'undefined' && bsettings.style)? bsettings.style : 'default-1 small';
                var badgeText = (typeof bsettings.badge_text != 'undefined' && bsettings.badge_text)? bsettings.badge_text : $.lang[LANG]['gallery.shopping.badge.'+b];
                var badgeBorderColor = (typeof bsettings.border_color != 'undefined' && bsettings.border_color)? bsettings.border_color : '';
                var badgeBackgroundColor = (typeof bsettings.background_color != 'undefined' && bsettings.background_color)? bsettings.background_color : '';
                var badgeFontColor = (typeof bsettings.font_color != 'undefined' && bsettings.font_color)? bsettings.font_color : '';
                var $badge = (badgeType == 'edit')? $('<span class="product-badge ' + badgeStyle + '">' + badgeText + '</span>') : $('<span class="product-badge"><img class="badge-img" src="' + bsettings.image_src + '"></span>');
                
                if(badgeBorderColor) $badge.css('border-color', badgeBorderColor);
                if(badgeBackgroundColor) $badge.css('background-color', badgeBackgroundColor);
                if(badgeFontColor) $badge.css('color', badgeFontColor);
                // if(typeof PAGE_MODE != 'undefined' && PAGE_MODE == 'c') $badge.attr('data-type', b);
                $badge.attr('data-type', b);

                badgeList += $badge[0].outerHTML;
            });
        }
        
        return badgeList;
    }

    var getBadgeSize = function(badge_settings) {
        var small = 0;
        var medium = 0;
        var large = 0;
        var cnt = 0;
        if(typeof badge_settings != 'undefined' && badge_settings) {
            $.each(badge_settings, function(t, b){
                if(b.type == 'edit') {
                    cnt++;
                    if(b.style.indexOf('small') > -1) small++;
                    if(b.style.indexOf('medium') > -1) medium++;
                    if(b.style.indexOf('large') > -1) large++;
                }
            });
        }
        
        var flag = false;
        if(cnt == small) flag = 'badge-small';
        if(cnt == medium) flag = 'badge-medium';
        if(cnt == large) flag = 'badge-large';

        return flag;
    }

    $(document).on('click', '#imgPopupFrame .close, #imgPopupFrame .image-popup', function(e){
        if(!$(e.target).is('img')) $('#imgPopupFrame').fadeOut(500);
    });

    $(document).on('dblclick','#imgPopupFrame .image-popup img, #imgPopupFrame .zoomable img', function(e) {
        e.preventDefault();
        e.stopPropagation();
        $('#imgPopupFrame a.view-original').toggleClass('fullscreen');

        var el = $('#imgPopupFrame');
        var $img = $('#imgPopupFrame .image-popup img');

        if($('#imgPopupFrame a.view-original').hasClass('fullscreen')) {
            var img = $img[0];

            var currentWidth = $img.width();
            var currentHeight = $img.height();
            var windowWidth = $(window).width()-8;
            var windowHeight = $(window).height();
            var naturalWidth = img.naturalWidth,
                naturalHeight = img.naturalHeight;
            
            scale = (windowWidth / currentWidth).toFixed(15);
        } else {
            scale = 1;
        }

        setImgPopupIconTooltip(el);
        setPopupImgScale(el, scale);
    });

    $(document).on('click','#imgPopupFrame a.view-original', function(e) {
        e.preventDefault();
        e.stopPropagation();
        $(this).toggleClass('fullscreen');

        var el = $('#imgPopupFrame');
        setImgPopupIconTooltip(el);
        $('#imgPopupFrame .view-original[data-toggle="tooltip"]').tooltip('show');

        var $img = el.find('img');
        if($(this).hasClass('fullscreen')) {
            var img = $img[0];

            var currentWidth = $img.width();
            var currentHeight = $img.height();
            var windowWidth = $(window).width()-8;
            var windowHeight = $(window).height();
            var naturalWidth = img.naturalWidth,
                naturalHeight = img.naturalHeight;
            
            scale = (windowWidth / currentWidth).toFixed(15);
        } else {
            scale = 1;
        }
        setPopupImgScale(el, scale);
    });

    $(document).on('click','#imgPopupFrame a.zoom-in, #imgPopupFrame a.zoom-out', function(e) {
        e.stopPropagation();

        var scale = $('#imgPopupFrame .zoomable img').attr('data-scale');
        if(scale === undefined) scale = 1;

        if($(this).hasClass('zoom-in')) {
            $('#imgPopupFrame a.view-original').removeClass('disabled').addClass('fullscreen');

            scale = Number(scale) + 0.5;
        } else {
            if(scale > 1) scale = Number(scale) - 0.5;
            if(scale < 1) scale = 1;
            if(scale == 1) {
                $('#imgPopupFrame a.view-original').removeClass('fullscreen');
            }
        }
        
        // setImgPopupIconTooltip(el);
        setPopupImgScale($('#imgPopupFrame'), scale);
        
    });

    $(document).on('click', '.data-feed-load-more', function() {
        var feed = $(this).attr('data-feed-el');
        if ($('.' + feed + ' .listprogress').length) {
            $(this).showModalFlat('INFORMATION', 'Please wait...', true, false, '', 'ok');
            return false;
        }
        $('.' + feed + ' .social-feed-element').addClass('show-posts');
        if (typeof $('.' + feed + ' .social-feed-element:eq(0)').first().attr('social-feed-id') != 'undefined') $(this).hide();
    });

    var loadingElement = function(el, msg) {
        $('.' + el + ' .listprogress').remove();
        if ($('.' + el).find('.social-feed-container').hasClass('listprogress-end')) return false;
        msg = (typeof msg == "undefined") ? "" : msg;
        var p = (msg) ? "<p class='text-center'>" + msg + "</p>" : "";
        $('.' + el + ' .social-feed-container').append('<div class="listprogress" style="width: 100%; text-align:center; padding:50px 0;"><svg version="1.1" xmlns="http://www.w3.org/svg/2000" viewBox="0 0 30 30" width="60" style="width:20px; height: 20px;"><circle cy="15" cx="15" r="14" style="stroke:#00baff;"></circle></svg>' + p + '</div>');
    }

    var setCustomPagination = function(config) {

        var $obj = config['$obj'],
            total = config['total'],
            view = (config['view']) ? config['view'] : 10,
            page_num = (config['page_num']) ? config['page_num'] : 1,
            page_view = (config['page_view']) ? config['page_view'] : 5,
            pagingContainer = config['pagingContainer'],
            section = config['section'],
            base_url = config['base_url'];

        start = Math.floor((page_num - 1) / page_view) * page_view,
            pages = Math.ceil(total / view),
            end = (Math.floor((page_num - 1) / page_view) + 1) * page_view,
            end = (end > pages) ? pages : end,
            prev = (start > 0) ? start : 1,
            next = ((end + 1) > pages) ? pages : end + 1,
            page_class = section + '-page';

        $obj.empty();

        for (i = start; i < end; i++) {
            var active = ((i + 1) == page_num) ? "active" : "",
                pageHref = base_url + (i + 1);

            $obj.append($("<li class='" + page_class + " " + active + "' data-view='" + view + "' data-page-num='" + (i + 1) + "'><a href='" + pageHref + "'>" + (i + 1) + "</a></li>"));
        }

        var prevHref = base_url + prev,
            nextHref = base_url + next,
            firstHref = base_url + '1',
            lastHref = base_url + pages,
            $prev = "" +
            "<li class='" + page_class + " prev' data-view='" + view +
            "' data-page-num='" + (start) + "'>" +
            "<a href='" + prevHref + "' aria-label='Previous'>" +
            "<span aria-hidden='true'>" +
            "<i class='fa fa-angle-left'></i>" +
            "</span>" +
            "</a>" +
            "</li>",
            $next = "" +
            "<li class='" + page_class + " next' data-view='" + view +
            "' data-page-num='" + (i + 1) + "'>" +
            "<a href='" + nextHref + "' aria-label='Previous'>" +
            "<span aria-hidden='true'>" +
            "<i class='fa fa-angle-right'></i>" +
            "</span>" +
            "</a>" +
            "</li>",
            $first = "" +
            "<li class='" + page_class + " prev' data-view='" + view +
            "' data-page-num='1'>" +
            "<a href='" + firstHref + "' aria-label='First'>" +
            "<span aria-hidden='true'>" +
            "<i class='fa fa-angle-double-left'></i>" +
            "</span>" +
            "</a>" +
            "</li>",
            $last = "" +
            "<li class='" + page_class + " prev' data-view='" + view +
            "' data-page-num='" + pages + "'>" +
            "<a href='" + lastHref + "' aria-label='Last'>" +
            "<span aria-hidden='true'>" +
            "<i class='fa fa-angle-double-right'></i>" +
            "</span>" +
            "</a>" +
            "</li>";

        if (start != 0)
            $obj.prepend($prev);

        if (end != pages)
            $obj.append($next);

        if (pages > 5) {
            if (page_num > 5) $obj.prepend($first);
            $obj.append($last);
        }

    }

    function memberLogin() {
        location.href = "/";
    }


    Number.prototype.format = function(n, x) {
        var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\.' : '$') + ')';
        return this.toFixed(Math.max(0, ~~n)).replace(new RegExp(re, 'g'), '$&,');
    };

    // 뎁스가 있는 값을 확인하기
    var checkNested = function(obj) {
        var args = Array.prototype.slice.call(arguments, 1);

        for (var i = 0; i < args.length; i++) {
            if (!obj || !obj.hasOwnProperty(args[i])) {
                return false;
            }
            obj = obj[args[i]];
        }
        return true;
    }

    Number.prototype.format = function() {
        if (this == 0) return 0;

        var reg = /(^[+-]?\d+)(\d{3})/;
        var n = (this + '');

        while (reg.test(n)) n = n.replace(reg, '$1' + ',' + '$2');

        return n;
    };


    String.prototype.format = function() {
        var num = parseFloat(this);
        if (isNaN(num)) return "0";

        return num.format();
    };

    function selectionRect() {
        var s = window.getSelection();
        oRange = s.getRangeAt(0); //get the text range
        oRect = oRange.getBoundingClientRect();
        return oRect;
    }

    function isHangulKey(event) {
        return (event.keyCode >= 12593 && event.keyCode <= 12622) || // 자모음 범위
        (event.keyCode >= 44032 && event.keyCode <= 55203) || // 완성형 범위
        (event.keyCode >= 12592 && event.keyCode <= 12687);
    }            

    function placeCaretAtEnd(el) {
        el.focus();
        if (typeof window.getSelection != "undefined" &&
            typeof document.createRange != "undefined") {
            var range = document.createRange();
            range.selectNodeContents(el);
            range.collapse(false);
            var sel = window.getSelection();
            sel.removeAllRanges();
            sel.addRange(range);
        } else if (typeof document.body.createTextRange != "undefined") {
            var textRange = document.body.createTextRange();
            textRange.moveToElementText(el);
            textRange.collapse(false);
            textRange.select();
        }
    }

    var insertVideo = function(sUrl, mode) {
        if (typeof sUrl == 'object') {
            var result = [];
            $.each(sUrl, function(i, v) {
                var r = insertVideo(v);
                if (typeof r != 'undefined') result.push(r);
            });
            return (sUrl.length == result.length) ? result : false;
        }

        sUrl = sUrl.replace('www.', '');
        var img = 'https://storage.googleapis.com/i.addblock.net/video-icon.jpg';
        // video url patterns(youtube, instagram, vimeo, dailymotion)
        var ytRegExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
        var ytMatch = sUrl.match(ytRegExp);

        var igRegExp = /\/\/instagram.com\/p\/(.[a-zA-Z0-9]*)/;
        var igMatch = sUrl.match(igRegExp);

        var vRegExp = /\/\/vine.co\/v\/(.[a-zA-Z0-9]*)/;
        var vMatch = sUrl.match(vRegExp);

        var vimRegExp = /\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/;
        var vimMatch = sUrl.match(vimRegExp);

        var dmRegExp = /.+dailymotion.com\/(video|hub|embed)\/([^_]+)[^#]*(#video=([^_&]+))?/;
        var dmMatch = sUrl.match(dmRegExp);

        var mcRegExp = /\/\/metacafe.com\/watch\/(.[a-zA-Z0-9]*)\/(.[a-zA-Z0-9\-]*)\//;
        var mcMatch = sUrl.match(mcRegExp);

        var kakaoExp = /\/\/tv.kakao.com\/(channel|embed)\/([0-9]{6,11}|player)\/cliplink\/([0-9]{6,11})/;
        var kaMatch = sUrl.match(kakaoExp);

        var kakaoExp2 = /\/\/tv.kakao.com\/(v|l)\/([0-9]{6,11})/;
        var kaMatch2 = sUrl.match(kakaoExp2);

        var naverExp = /\/\/serviceapi.rmcnmv.naver.com\/(.*)/;
        var naMatch = sUrl.match(naverExp);

        var sound = sUrl.search('soundcloud.com');
        var $video, src;
        if (ytMatch && ytMatch[2].length === 11) {
            var youtubeId = ytMatch[2];
            src = '//www.youtube.com/embed/' + youtubeId;
            src = src.replace('watch?v=', 'v/');

            $video = $('<iframe>')
                .attr({ 'src': src + '?wmode=transparent', 'frameborder': '0' });
            img = '//img.youtube.com/vi/' + youtubeId + '/default.jpg';
            /*        
            } else if (igMatch && igMatch[0].length > 0) {
                $video = $('<iframe>')
                .attr('src', igMatch[0] + '/embed/')
                .attr('width', '612').attr('height', '710')
                .attr('scrolling', 'no')
                .attr('allowtransparency', 'true');
            } else if (vMatch && vMatch[0].length > 0) {
                $video = $('<iframe>')
                .attr('src', vMatch[0] + '/embed/simple')
                //.attr('width', '600').attr('height', '600')
                .attr('class', 'vine-embed');
                src = vMatch[0] + '/embed/simple';
            */
        } else if (vimMatch && vimMatch[3].length > 0) {
            $video = $('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen>')
                .attr('src', '//player.vimeo.com/video/' + vimMatch[3]);
            //.attr('width', '640').attr('height', '360');
            src = '//player.vimeo.com/video/' + vimMatch[3];
            $.getJSON('https://vimeo.com/api/oembed.json?url=https://player.vimeo.com/video/' + vimMatch[3] + '&width=640', function(data) {
                if (typeof data.thumbnail_url != 'undefined' && data.thumbnail_url) {
                    img = data.thumbnail_url;
                }
            });
        } else if (dmMatch && dmMatch[2].length > 0) {
            dmMatch[2] = dmMatch[2].replace("video/", "");
            $video = $('<iframe>')
                .attr('src', '//www.dailymotion.com/embed/video/' + dmMatch[2]);
            //.attr('width', '640').attr('height', '360');
            src = '//www.dailymotion.com/embed/video/' + dmMatch[2];
            img = '//dailymotion.com/thumbnail/video/' + dmMatch[2];
        }
        /* else if (mcMatch && mcMatch[1].length > 0) {
                    $video = $('<iframe>')
                    .attr('src', 'http://www.metacafe.com/embed/' + mcMatch[1] + '/' + mcMatch[2]);
                    //.attr('width', '640').attr('height', '360');
                    src = 'http://www.metacafe.com/embed/' + mcMatch[1] + '/' + mcMatch[2];
                }*/
        else if (sound > -1) {
            $.getJSON('https://soundcloud.com/oembed?format=json&url=' + sUrl, function(data) {
                if (typeof data.html == 'undefined') {
                    alert('get Soundcloud API error');
                    return;
                }
                $video = $(data.html);
                src = $video.prop('src');
                img = data.thumbnail_url;
            }).fail(function(response) {
                console.log(response);
                alert('get Soundcloud API error');
                $video = false;
                src = false;
            });
        } else if (kaMatch && kaMatch[3].length > 0) {
            $video = $('<iframe>')
                .attr('src', '//tv.kakao.com/embed/player/cliplink/' + kaMatch[3] + '?service=kakao_tv');
            src = '//tv.kakao.com/embed/player/cliplink/' + kaMatch[3] + '?service=kakao_tv';
            // img = file_get_contents('//tv.kakao.com/v/' + kaMatch[3]);
        } else if (kaMatch2 && kaMatch2[2].length > 0) {
            var kakao_tv_iframe = {
                    'l': '//play-tv.kakao.com/embed/player/livelink?liveLinkId=',
                    'v': '//play-tv.kakao.com/embed/player/cliplink/'
                },
                kakao_tv_parameter = {
                    'l': '&service=player_share',
                    'v': '?service=player_share'
                }
            kakao_tv_src = kakao_tv_iframe[kaMatch2[1]] + kaMatch2[2] + kakao_tv_parameter[kaMatch2[1]];

            $video = $('<iframe>')
                .attr('src', kakao_tv_src)
                .attr('scrolling', 'no')
                .attr('allow', 'autoplay');
            src = kakao_tv_src;
        }
        /* else if(naMatch && naMatch[1].length > 0) {
                   $video = $('<iframe>')
                   .attr('src', '//serviceapi.rmcnmv.naver.com/' + naMatch[1]);
                   src = '//serviceapi.rmcnmv.naver.com/' + naMatch[1];
               } */
        else {
            // this is not a known video link. Now what, Cat? Now what?
        }

        if ($video) {
            $video.attr('frameborder', 0);
        }

        switch (mode) {
            case "src":
                return src;
                break;
            case "img":
                return img;
                break;
            default:
                return $video;
                break;
        }
    }

    function setForumWrap() {
        var width = $('body').width(),
            margin = 0,
            size = $('.fr-view').width(),
            sidebar = $('.dsgn-body').hasClass('sidebar');

        width = (sidebar) ? width - $('header.sidebar').width() : width;
        $.each($('.f-align-full, .f-align-wide'), function(i, v) {
            if ($(this).hasClass('f-align-full')) {
                margin = (width - size) / 2;
            } else {
                container = (size == 720) ? (size + 240) : (size + 220);
                if (width <= container) container = width;
                width = container;
                margin = (container - size) / 2;
            }
            $(this).css('cssText', 'width: ' + width + 'px !important; margin-left:-' + margin + 'px; max-width:' + width + 'px !important;');
        });
    }

    function doGetCaretPosition(oField) {

        // Initialize
        var iCaretPos = 0;

        // IE Support
        if (document.selection) {

            // Set focus on the element
            oField.focus();

            // To get cursor position, get empty selection range
            var oSel = document.selection.createRange();

            // Move selection start to 0 position
            oSel.moveStart('character', -oField.value.length);

            // The caret position is selection length
            iCaretPos = oSel.text.length;
        }

        // Firefox support
        else if (oField.selectionStart || oField.selectionStart == '0')
            iCaretPos = oField.selectionStart;


        // Return results
        return iCaretPos;
    }

    function resetForm($obj) {
        $.each($obj.find('.tpl-form-element'), function(i, v) {
            var type = $(this).prop('type');
            switch (type) {
                case 'text':
                case 'tel':
                case 'number':
                case 'textarea':
                    $(this).val('');
                    break;

                case 'radio':
                case 'checkbox':
                    $(this).prop('checked', false);
                    break;

                case 'select-one':
                case 'select-multi':
                    $(this).val('');
                    $(this)[0].selectIndex = -1;
                    break;
            }
        });
    }

    function getRecommendInfo($el, $img, mode) {
        // alert('el: ' + $el + ', img:' + $img + ', mode:' + mode);
        if (typeof mode == 'undefined' || $el.hasClass('el-footer')) mode = true;

        var width = '';
        if (mode == false) {
            width = ($('#element-display > div').is('[data-width]')) ? $('#element-display > div').attr('data-width') : $el.attr('data-width');
        } else {
            if (typeof $el.attr('data-width') != 'undefined' && $el.attr('data-type2') != 'logo') width = $el.attr('data-width');
            else if ($el.attr('data-type2') == 'logo' && $el.attr('data-case') == 'slideshow69') width = '160';
            else if ($el.attr('data-type2') == 'logo' && $el.attr('data-case') == 'slideshow68') width = '100';
            else width = 0;
        }

        var src = $img.prop('src'),
            img_resolution = '',
            img = new Image(),
            nWidth = 0,
            nHeight = 0,
            txt_img_click = (mode) ? $.lang[LANG]['editor.image.click.change'] + '<br>' : '',
            recomm_str = '',
            footerlogo = (selectEL == 'el-footer') ? $img[0].src.split(':')[1] : '',
            isfooterAttach = typeof $('img[src="' + footerlogo + '"]').is('[data-footer-attach]') == 'undefined' ? false : $('img[src="' + footerlogo + '"]').is('[data-footer-attach]');

        img.src = (typeof src == 'undefined') ? '' : src;

        if (width == 0) {

            if (selectEL == 'el-menu' || (selectEL == 'el-footer' && isfooterAttach)) {
                var el_img = $('.' + selectEL).find('img[data-attach="true"]');
                if (typeof el_img.attr('src') != "undefined" && src.match(el_img.attr('src')) !== null) {
                    // HTML[data-max-width] > CSS max-width > HTML ELEMENT width()
                    nWidth = (typeof el_img.css('max-width') != 'undefined' && el_img.css('max-width').match(/px/gi) !== null) ? el_img.css('max-width').replace('px', '') : el_img.width();
                    nHeight = (typeof el_img.css('max-height') != 'undefined' && el_img.css('max-height').match(/px/gi) !== null) ? el_img.css('max-height').replace('px', '') : el_img.height();

                    img_resolution = (typeof el_img.closest('.navbar-brand').attr('data-recommend') != 'undefined') ? el_img.closest('.navbar-brand').attr('data-recommend') : nWidth + ' X ' + nHeight;
                    // return '<div class="text-left">' + txt_img_click + '<span class="txt-recomm">' + $.lang[LANG]['editor.image.recomm.menu'] + '<br>' + img_resolution + '</span></div>';
                    return "<div class=\'text-left\'>" + txt_img_click + "</div>";
                }
            } else {
                img.onload = function() {
                    nWidth = this.width;
                    nHeight = this.height;
                    img_resolution = ((nWidth) ? nWidth : $img.width()) + ' X ' + ((nHeight) ? nHeight : $img.height());

                    recomm_str = "<div class=\'text-left\'>" + txt_img_click + "<span class=\'txt-recomm\'>" + $.lang[LANG]['editor.image.recomm'] + "<br>" + img_resolution + "</span></div>";

                    if (mode) {
                        var this_src = src.substr(src.lastIndexOf('/') + 1);
                        $('.bc-resource').find('img[src$="' + this_src + '"]').attr('data-original-title', recomm_str);
                    } else {
                        if ($('.recomm-image-text').length > 0) $('.recomm-image-text').html(recomm_str).show();
                        else $('body').append(recomm_str);
                    }
                }
                return "<div class=\'text-left\'>" + txt_img_click + "<span class=\'txt-recomm\' data-loading=\'true\'>Loading...</span></div>";
            }


            // if(mode) return '<div class="text-left">' + $.lang[LANG]['editor.image.click.change'] + '<br><span class="txt-recomm">' + $.lang[LANG]['editor.image.recomm'] + '<br>' + img_resolution + '</span></div>';
            // else return '<div class="text-left"><span class="txt-recomm">' + $.lang[LANG]['editor.image.recomm'] + '<br>' + img_resolution + '</span></div>';
        } else {
            switch (width) {
                case '1920':
                    img_resolution = '1920 X FREE';
                    break;
                case '800':
                    img_resolution = '800 X FREE';
                    break;
                case '700':
                    img_resolution = '700 X 500';
                    break;
                case '670':
                    img_resolution = '670 X 980';
                    break;
                case '650':
                    img_resolution = '650 X 370';
                    break;
                case '600':
                    img_resolution = '600 X 600';
                    break;
                case '250':
                    img_resolution = '250 X 250';
                    break;
                case '160':
                    img_resolution = '160 X 100';
                    break;
                case '100':
                    img_resolution = '100 X 100';
                    break;
                case '60':
                    img_resolution = '60 X 60';
                    break;
            }
            var gallery_check = ($el.attr('data-type2') == 'premium' && $el.attr('data-type') == 'gallery' && $el.find('.gjs').attr('data-js-code') == 1) ? true : false;
            if(!gallery_check) {
              if(width > 1000) {
                nWidth = this.width;
                nHeight = this.height;
                img_resolution = ((nWidth) ? nWidth : $img[0].naturalWidth) + ' X ' + ((nHeight) ? nHeight : $img[0].naturalHeight);
              } else {
                //현재 블럭의 이미지 영역의 2배 사이즈
                var $el_img = $('.' + selectEL).find('[data-attach="true"]');
                var img_width = ($el_img[0].width) ? $el_img[0].width : $el_img[0].clientWidth,
                    img_height = ($el_img[0].height) ? $el_img[0].height : $el_img[0].clientHeight;
                img_resolution = (img_width * 2) + ' X ' + (img_height * 2);
              }
            }

            return "<div class=\'text-left\'>" + txt_img_click + "<span class=\'txt-recomm\'>" + $.lang[LANG]['editor.image.recomm'] + "<br>" + img_resolution + "</span></div>";
        }

    }

    var getRatio = function(w) {
        var r = '';
        switch (w) {
            case "1920":
                r = '&w=1920&fit=crop';
                break;
            case "800":
                r = '&w=800&fit=crop';
                break;
            case "700":
                r = '&w=700&h=500&crop=face&fit=crop';
                break;
            case "670":
                r = '&w=670&h=980&crop=face&fit=crop';
                break;
            case "650":
                r = '&w=600&h=370&crop=face&fit=crop';
                break;
            case "600":
                r = '&w=600&h=600&crop=face&fit=crop';
                break;
            case "250":
                r = '&w=250&h=250&crop=face&fit=crop';
                break;
            case "60":
                r = '&w=60&h=60&crop=face&fit=crop';
                break;
            case "0":
                r = '';
                break;
        }
        return r;
    }

    var tplFormitem = function(type, idx, val) {
        var tpl = '';
        if (typeof val == 'undefined' || val == '') {
            if (type != 'file.download' && type != 'file.upload')
                val = ['A', 'B'];
        } else {
            if (type != 'file.download' && type != 'file.upload')
                val = val.split('`');
            else
                val = val.split('||');
        }

        var blang = (typeof $('.' + selectEL).attr('data-blocklang') == 'undefined') ? $('#element-display[data-ref="' + selectEL + '"]').attr('data-blocklang') : $('.' + selectEL).attr('data-blocklang'),
            sdefault = '';
        if (typeof blang == 'undefined') {
            blang = getLanguage(true);
        }

        if (blang == 'ko') {
            sdefault = '선택하세요';
            datePlaceholder = '날짜 선택';
            date2Placeholder = '날짜/시간 선택';
        } else if (blang == 'en') {
            sdefault = 'Select';
            datePlaceholder = 'Date';
            date2Placeholder = 'Date/Time';
        } else if (blang == 'ja') {
            sdefault = '選択してください';
            datePlaceholder = 'Date';
            date2Placeholder = 'Date/Time';
        } else {
            sdefault = 'Select';
            datePlaceholder = 'Date';
            date2Placeholder = 'Date/Time';
        }
        switch (type) {
            case 'text':
                tpl = '<input class="form-control" type="text">';
                break;
            case 'memo':
                tpl = '<textarea class="form-control"></textarea>';
                break;
            case 'select':
                tpl = '<select class="form-control">';
                tpl = tpl + '<option value="">' + sdefault + '</option>';
                $.each(val, function(i, v) {
                    tpl = tpl + '<option value="' + replaceQuote(v) + '">' + v + '</option>';
                });
                tpl = tpl + '</select>';
                break;
            case 'check':
                tpl = '<div>';
                $.each(val, function(i, v) {
                    tpl = tpl + '<label class="checkbox-inline"><input type="checkbox" class="forms-item-check" name="' + (type + idx) + '" value="' + replaceQuote(v) + '">' + v + '</label>';
                });
                tpl = tpl + '</div>';
                break;
            case 'radio':
                tpl = '<div>';
                $.each(val, function(i, v) {
                    tpl = tpl + '<label class="radio-inline"><input type="radio" class="forms-item-radio" name="' + (type + idx) + '" value="' + replaceQuote(v) + '">' + v + '</label>';
                });
                tpl = tpl + '</div>';
                break;
            case 'date':
                tpl = '<div>';
                tpl = tpl + '<input class="form-control form-date date-ymd" type="text" readonly placeholder="' + datePlaceholder + '"/><svg viewBox="0 0 14 16" width="14" height="16"><path d="M12 2h-1V1c0-0.55-0.45-1-1-1S9 0.45 9 1v1H5V1c0-0.55-0.45-1-1-1S3 0.45 3 1v1H2C0.9 2 0 2.9 0 4v10c0 1.1 0.9 2 2 2h10c1.1 0 2-0.9 2-2V4C14 2.9 13.1 2 12 2zM13 14c0 0.55-0.45 1-1 1H2c-0.55 0-1-0.45-1-1V6h12V14z"></path><rect x="3" y="8" width="2" height="2"></rect><rect x="6" y="8" width="2" height="2"></rect><rect x="9" y="8" width="2" height="2"></rect><rect x="3" y="11" width="2" height="2"></rect><rect x="6" y="11" width="2" height="2"></rect><rect x="9" y="11" width="2" height="2"></rect></svg>';
                tpl = tpl + '</div>';
                break;
            case 'date2':
                tpl = '<div>';
                tpl = tpl + '<input class="form-control date-ymd form-date" type="text" readonly placeholder="' + date2Placeholder + '"/><svg viewBox="0 0 14 16" width="14" height="16"><path d="M12 2h-1V1c0-0.55-0.45-1-1-1S9 0.45 9 1v1H5V1c0-0.55-0.45-1-1-1S3 0.45 3 1v1H2C0.9 2 0 2.9 0 4v10c0 1.1 0.9 2 2 2h10c1.1 0 2-0.9 2-2V4C14 2.9 13.1 2 12 2zM13 14c0 0.55-0.45 1-1 1H2c-0.55 0-1-0.45-1-1V6h12V14z"></path><rect x="3" y="8" width="2" height="2"></rect><rect x="6" y="8" width="2" height="2"></rect><rect x="9" y="8" width="2" height="2"></rect><rect x="3" y="11" width="2" height="2"></rect><rect x="6" y="11" width="2" height="2"></rect><rect x="9" y="11" width="2" height="2"></rect></svg>';
                tpl = tpl + '</div>';
                break;
            case 'file.upload':
                tpl = '<div>';
                tpl = tpl + '<input type="text" class="hide" value="" /><label class=""><input type="file" class="hide" />' + clSVG('paperclip', '16', '16', false, '') + $.lang[blang]['config.form.btn.attachment'] + ' <span class="file-uploaded-number">(0/10)</span></label><p class="file-title text">' + $.lang[blang]['config.form.file.attachment.none'] + '</p></div>';
                break;
            case 'file.download':
                tpl = '<div>';
                tpl = tpl + '<p class="file-title text">' + clSVG('paperclip', '16', '16', false, '') + (val[0] ? val[0] : $.lang[blang]['config.form.file.attachment.none']) + '</p>';
                tpl = tpl + '</div>';
                break;
        }

        return tpl;
    }

    function replaceQuote(str) {
        // str = str.replace(/\\/g, '\\\\');
        // str = str.replace(/\'/g, '\\\'');
        str = str.replace(/\"/g, '&quot;');
        // str = str.replace(/\0/g, '\\0');
        return str;
    }

    var captchaContainer = null;
    var loadCaptcha = function() {
        $('#recaptcha').attr('data-res', '');
        captchaContainer = grecaptcha.render('recaptcha', {
            'sitekey': '6LfZjyIUAAAAAIMcTzt0XriAdVXHExtrVsNUaiHz',
            'callback': loadCaptchaCallback
        });
    }
    var loadCaptchaCallback = function(res) { $('#recaptcha').attr('data-res', res); }
    var recaptchCallback = function() {}
    var checkCaptcha = function() {
        var s = $('#recaptcha').attr('data-res');
        var res = $.post('/fm/recaptcha', { r: s }, function(data) {
            return data;
        }, 'json');
        return res;
    }

    var load_kcaptcha = function() {
        $('#kcaptcha').attr('src', 'https://storage.googleapis.com/i.addblock.net/js/load_kcaptcha.gif');
        $('#kcaptcha').attr('title', $.lang[LANG]['page.reset-password.captcha-tip']);
        $.post(rt_path + '/check/kcaptcha/session?_' + new Date().getTime(), function(data) {
            md5_norobot_key = data;
            var tmpImg = new Image(),
                t = (new Date).getTime();
            tmpImg.src = rt_path + '/check/kcaptcha/image?_' + t;
            tmpImg.onload = function() {
                $('#kcaptcha').attr('src', rt_path + '/check/kcaptcha/image?_' + t);
            };
        });
    }

    var load_form_kcaptcha = function($formEL, pid) {
        $formEL.find('.kcaptcha-box img').attr('src', '//storage.googleapis.com/i.addblock.net/js/load_kcaptcha.gif');
        $.post(rt_path + '/check/kcaptcha/session/' + pid + '?_' + new Date().getTime(), function(data) {
            // md5_norobot_pid = data;
            var tmpImg = new Image(),
                t = (new Date).getTime();
            tmpImg.src = rt_path + '/check/kcaptcha/image/' + pid;
            tmpImg.onload = function() {
                $formEL.find('.kcaptcha-box img').attr('src', rt_path + '/check/kcaptcha/image/' + pid + '?_' + new Date().getTime());
            };          
        });
    }

    $('.element[data-type="form"] .form-group .view-privacy').live('click', function(){
        $(this).toggleClass('active');
        if($(this).hasClass('active')) {
            $(this).closest('.form-privacy').find('textarea').show();
        } else {
            $(this).closest('.form-privacy').find('textarea').hide();
        }
    });

    $('.element[data-type="contact"][data-type2="franchise bar"] .form-group .view-privacy').live('click', function(){
        let $el = $(this).closest('.element');
        let blocklang = (typeof $el.attr('data-blocklang') != 'undefined')? $el.attr('data-blocklang') : LANG;
        let slang = (typeof SLANG != 'undefined' && typeof SLANG.select_code != 'undefined' && SLANG.select_code != 'ko')? 'en' : 'ko';
        let privacyTxt = $(this).closest('.form-privacy').find('textarea').val();

        // if(PAGE_MODE == 'c') slang = LANG;
        if(!privacyTxt) privacyTxt = $.lang[blocklang]['contact.privacy.text.default'];

        let modal_content = '<div class="textarea-container">' + privacyTxt + '</div>';
        $(this).showModalFlat($.lang[blocklang]['contact.consult.privacy.view.title'], modal_content, true, false, '', $.lang[slang]['config.close'], '', 'cl-cmmodal cl-s-btn cover cl-p70 cl-t80 cl-modal w560 cl-okbtn-pbt70 cl-close-btn contact-privacy-view');
    });

    var loadMapDropdown = function ($el, selected, index) {
        if(typeof selected == 'undefined') selected = '';
        if(typeof index == 'undefined') index = 0;
        var blocklang = (typeof $el.attr('data-blocklang') != 'undefined')? $el.attr('data-blocklang') : LANG;
        var area0 = {
            [$.lang[blocklang]['contact.map.search.sido']] : '',
            [$.lang[blocklang]['contact.map.search.sido.1']]: '서울',
            [$.lang[blocklang]['contact.map.search.sido.2']]: '인천',
            [$.lang[blocklang]['contact.map.search.sido.3']]: '대전',
            [$.lang[blocklang]['contact.map.search.sido.4']]: '광주',
            [$.lang[blocklang]['contact.map.search.sido.5']]: '대구',
            [$.lang[blocklang]['contact.map.search.sido.6']]: '울산',
            [$.lang[blocklang]['contact.map.search.sido.7']]: '부산',
            [$.lang[blocklang]['contact.map.search.sido.8']]: '경기',
            [$.lang[blocklang]['contact.map.search.sido.9']]: '강원',
            [$.lang[blocklang]['contact.map.search.sido.10']]: '충북',
            [$.lang[blocklang]['contact.map.search.sido.11']]: '충남',
            [$.lang[blocklang]['contact.map.search.sido.12']]: '전북',
            [$.lang[blocklang]['contact.map.search.sido.13']]: '전남',
            [$.lang[blocklang]['contact.map.search.sido.14']]: '경북',
            [$.lang[blocklang]['contact.map.search.sido.15']]: '경남',
            [$.lang[blocklang]['contact.map.search.sido.16']]: '제주'
        };
        var areaObj = {
            area1: ["강남구","강동구","강북구","강서구","관악구","광진구","구로구","금천구","노원구","도봉구","동대문구","동작구","마포구","서대문구","서초구","성동구","성북구","송파구","양천구","영등포구","용산구","은평구","종로구","중구","중랑구"],
            area2: ["계양구","남구","남동구","동구","부평구","서구","연수구","중구","강화군","옹진군"],
            area3: ["대덕구","동구","서구","유성구","중구"],
            area4: ["광산구","남구","동구","북구","서구"],
            area5: ["남구","달서구","동구","북구","서구","수성구","중구","달성군"],
            area6: ["남구","동구","북구","중구","울주군"],
            area7: ["강서구","금정구","남구","동구","동래구","부산진구","북구","사상구","사하구","서구","수영구","연제구","영도구","중구","해운대구","기장군"],
            area8: ["고양시","과천시","광명시","광주시","구리시","군포시","김포시","남양주시","동두천시","부천시","성남시","수원시","시흥시","안산시","안성시","안양시","양주시","오산시","용인시","의왕시","의정부시","이천시","파주시","평택시","포천시","하남시","화성시","가평군","양평군","여주군","연천군"],
            area9: ["강릉시","동해시","삼척시","속초시","원주시","춘천시","태백시","고성군","양구군","양양군","영월군","인제군","정선군","철원군","평창군","홍천군","화천군","횡성군"],
            area10: ["제천시","청주시","충주시","괴산군","단양군","보은군","영동군","옥천군","음성군","증평군","진천군","청원군"],
            area11: ["계룡시","공주시","논산시","보령시","서산시","아산시","천안시","금산군","당진군","부여군","서천군","연기군","예산군","청양군","태안군","홍성군"],
            area12: ["군산시","김제시","남원시","익산시","전주시","정읍시","고창군","무주군","부안군","순창군","완주군","임실군","장수군","진안군"],
            area13: ["광양시","나주시","목포시","순천시","여수시","강진군","고흥군","곡성군","구례군","담양군","무안군","보성군","신안군","영광군","영암군","완도군","장성군","장흥군","진도군","함평군","해남군","화순군"],
            area14: ["경산시","경주시","구미시","김천시","문경시","상주시","안동시","영주시","영천시","포항시","고령군","군위군","봉화군","성주군","영덕군","영양군","예천군","울릉군","울진군","의성군","청도군","청송군","칠곡군"],
            area15: ["거제시","김해시","마산시","밀양시","사천시","양산시","진주시","진해시","창원시","통영시","거창군","고성군","남해군","산청군","의령군","창녕군","하동군","함안군","함양군","합천군"],
            area16: ["서귀포시","제주시","남제주군","북제주군"]
        };

        var areaObj_en = {
            area1: ["Gangnam District", "Gangdong District", "Gangbuk District", "Gangseo District", "Gwanak District", "Gwangjin District", "Guro District", "Geumcheon District", "Nowon District", "Dobong District", "Dongdaemun District", "Dongjak District", "Mapo District", "Seodaemun District", "Seocho District", "Seongdong District", "Seongbuk District", "Songpa District", "Yangcheon District", "Yeongdeungpo District", "Yongsan District", "Eunpyeong District", "Jongno District", "Jung District", "Jungnang District"],
            area2: ["Gyeyang District", "Nam District", "Namdong District", "Dong District", "Bupyeong District", "Seo District", "Yeonsu District", "Jung District", "Ganghwa County", "Ongjin County"],
            area3: ["Daedeok District", "Dong District", "Seo District", "Yuseong District", "Jung District"],
            area4: ["Gwangsan District", "Nam District", "Dong District", "Buk District", "Seo District"],
            area5: ["Nam District", "Dalseo District", "Dong District", "Buk District", "Seo District", "Suseong District", "Jung District", "Dalseong County"],
            area6: ["Nam District", "Dong District", "Buk District", "Jung District", "Ulju County"],
            area7: ["Gangseo District", "Geumjeong District", "Nam District", "Dong District", "Dongnae District", "Busanjin District", "Buk District", "Sasang District", "Saha District", "Seo District", "Suyeong District", "Yeonje District", "Yeongdo District", "Jung District", "Haeundae District", "Gijang County"],
            area8: ["Goyang City", "Gwacheon City", "Gawngmyeong City", "Gwangju City", "Guri City", "Gunpo City", "Gimpo City", "Namyangju City", "Dongducheon City", "Bucheon City", "Seongnam City", "Suwon City", "Siheung City", "Ansan City", "Anseong City", "Anyang City", "Yangju City", "Osan City", "Yongin City", "Uiwang City", "Uijeongbu City", "Icheon City", "Paju City", "Pyeongtaek City", "Pocheon City", "Hanam City", "Hwaseong City", "Gapyeong City", "Yangpyeong County", "Yeoju County", "Yeoncheon County"],
            area9: ["Gangneung City", "Donghae City", "Samcheok City", "Sokcho City", "Wonju City", "Chuncheon City", "Taebaek City", "Goseong County", "Yanggu County", "Yangyang County", "Yeongwol County", "Inje County", "Jeongseon County", "Cheorwon County", "Pyeongchang County", "Hongcheon County", "Hwacheon County", "Hoengseong County"],
            area10: ["Jecheon City", "Cheongju City", "Chungju City", " Goesan County", "Danyang County", "Boeun County", "Yeongdong County", "Okcheon County", "Eumseong County", "Jeungpyeong County", "Jincheon County", "Cheongwon County"],
            area11: ["Gyeryong City", "Gongju City", "Nonsan City", "Boryeong City", "Seosan City", "Asan City", "Cheonan City", "Geumsan County", "Dangjin County", "Buyeo County", "Seocheon County", "Yeongi County", "Yesan County", "Cheongyang County", "Taean County", "Hongseong County"],
            area12: ["Gunsan City", "Gimje City", "Namwon City", "Iksan City", "Jeonju City", "Jeongeup City", "Gochang County", "Muju County", "Buan County", "Sunchang County", "Wanju County", "Imsil County", "Jangsu County", "Jinan County"],
            area13: ["Gwangyang City", "Naju City", "Mokpo City", "Suncheon City", "Yeosu City", "Gangjin County", "Goheung County", "Gokseong County", "Gurye County", "Damyang County", "Muan County", "Boseong County", "Sinan County", "Yeonggwang County", "Yeongam County", "Wando County", "Jangseong County", "Jangheung County", "Jindo County", "Hampyeong County", "Haenam County", "Hwasun County"],
            area14: ["Gyeongsan City", "Gyeongju City", "Gumi City", "Gimcheon City", "Mungyeong City", "Sangju City", "Andong City", "Yeongju City", "Yeongcheon City", "Pohang City", "Goryeong County", "Gunwi County", "Bonghwa County", "Seongju County", "Yeongdeok County", "Yeongyang County", "Yecheon County", "Ulleung County", "Uljin County", "Uiseong County", "Cheongdo County", "Cheongsong County", "Chilgok County"],
            area15: ["Geoje City", "Gimhae City", "Masan City", "Miryang City", "Sacheon City", "Yangsan City", "Jinju City", "Jinhae-gu", "Changwon City", "Tongyeong City", "Geochang County", "Goseong County", "Namhae County", "Sancheong County", "Uiryeong County", "Changnyeong County", "Hadong County", "Haman County", "Hamyang County", "Hapcheon County"],
            area16: ["Seogwipo City", "Jeju City", "Namjeju County", "Bukjeju County"]
        };

        var sido = '';
        var gungu = '<li class="empty"><a href="javascript:;">' + $.lang[blocklang]['contact.map.search.gungu'] + '</a></li>';

        var idx = 0
        $.each(area0, function(k, v){
            var active = (selected == k)? 'active' : '';  
            sido += '<li class="' + active + '"><a href="javascript:;" data-idx="' + idx + '" data-val="' + v + '">' + k + '</a></li>';
            idx ++;
        });

        $el.find('.select-si-do .dropdown-menu').html(sido);

        var area = 'area' + index;
        if(index > 0) {
            var num = 0;
            $.each(areaObj[area], function(k, v) {
                let gunguTxt = (blocklang == 'en')? areaObj_en[area][k] : v;
                gungu += '<li><a href="javascript:;" data-idx="' + num + '" data-val="' + v + '">' + gunguTxt + '</a></li>';
                num ++;
            });
        }

        $el.find('.select-gun-gu .dropdown-menu').html(gungu);
    }

    var searchByStoreAddr = function ($el, val, mode) {
        if(typeof mode == 'undefined') mode = '';
        let total = 0;

        $el.find('.map-item-list .map-item-empty').remove();
        $el.find('.item').each(function(idx, v){
            if(mode == 'gungu' && $(v).hasClass('not-result')) {
                return true;
            }
            var addr = $(v).attr('data-addr');
            if(typeof addr != 'undefined' && addr.indexOf(val) === -1) {
                $(v).addClass('hide not-result');
            } else {
                $(v).removeClass('hide not-result');
                total ++;
            }
        });

        if(val) searchResultEmpty($el, total);
        if ($('body').width() <= 991) fmapMobilePaging($el);
    }

    var searchByStorename = function ($el) {
        var val = $el.find('.searchby-storename input').val().trim().toLowerCase();
        let total = 0;

        $el.find('.map-item-list .map-item-empty').remove();
        $el.find('.item').removeClass('hide not-result');
        
        if($el.find('.select-si-do .selected').length) {
            let selectedIdx1 = $el.find('.select-si-do .selected').attr('data-selected-idx');
            searchByStoreAddr($el, $el.find('.select-si-do li a[data-idx="' + selectedIdx1 + '"]').attr('data-val'));

            if($el.find('.select-gun-gu .selected').length) {
                let selectedIdx2 = $el.find('.select-gun-gu .selected').attr('data-selected-idx');
                searchByStoreAddr($el, $el.find('.select-gun-gu li a[data-idx="' + selectedIdx2 + '"]').attr('data-val'), 'gungu');
            }
        }
        
        if(typeof val != 'undefined' && val) {
            $el.find('.item').each(function(idx, v){
                if($(v).hasClass('not-result')) {
                    return true;
                }
                var itemName = $(v).find('.item-name').text().toLowerCase();
                if(typeof itemName != 'undefined' && itemName.indexOf(val) === -1) {
                    $(v).addClass('hide not-result');
                } else {
                    $(v).removeClass('hide not-result');
                    total ++;
                }
            });

            searchResultEmpty($el, total);
        }
        
        $el.find('.searchby-storename input').blur();
        if ($('body').width() <= 991) fmapMobilePaging($el);
    }

    var searchResultEmpty = function ($el, total) {
        let blocklang = ($el.attr('data-blocklang'))? $el.attr('data-blocklang') : LANG;
        let emptyHTML = '<div class="map-item-empty">' + $.lang[blocklang]['contact.map.search.results.empty'] + '</div>';
        let searchCnt = $el.find('.map-item-list .item:not(.hide)').length;

        if(total == 0) {
            $el.find('.map-item-list .map-item-empty').remove();
            $el.find('.map-item-list').append(emptyHTML);
        }
    }

    $('[data-type="contact"][data-type2="franchise map"] .select-si-do .dropdown-toggle').live('click', function(e){
        e.preventDefault();

        var $el = $(this).closest('.element');
        var $btn = $(this).find('span');
        var val = $(this).find('span').text();
        var idx = ($btn.attr('data-selected-idx'))? $btn.attr('data-selected-idx') : 0;
        loadMapDropdown($el, val, idx);
    });

    $('[data-type="contact"][data-type2="franchise map"] .select-si-do li a').live('click', function(e){
        var $el = $(this).closest('.element');
        var $btn = $(this).closest('.dropdown').find('button.dropdown-toggle > span');
        var idx = $(this).attr('data-idx');
        var val = $(this).attr('data-val');
        var valTxt = $(this).text();
        var blocklang = (typeof $el.attr('data-blocklang') != 'undefined')? $el.attr('data-blocklang') : LANG;

        $(this).closest('.map-search').find('.select-gun-gu .dropdown-toggle > span').removeClass('selected');
        $(this).closest('.map-search').find('.select-gun-gu .dropdown-toggle > span').text($.lang[blocklang]['contact.map.search.gungu']);

        $el.find('.searchby-storename input').val('');
        $btn.text(valTxt);

        $el.find('.item').removeClass('hide not-result');
        $btn.removeClass('selected');

        if(typeof val != 'undefined' && val) {
            $btn.addClass('selected');
            $btn.attr('data-selected-idx', idx);
            searchByStoreAddr($el, val);
        } else {
            $el.find('.map-item-list .map-item-empty').remove();
            $el.find('.item').removeClass('hide not-result');
            if ($('body').width() <= 991) fmapMobilePaging($el);
        }

        loadMapDropdown($el, val, $(this).attr('data-idx'));
    });

    $('[data-type="contact"][data-type2="franchise map"] .select-gun-gu .dropdown-toggle').live('click', function(e){
        e.preventDefault();

        var $el = $(this).closest('.element');
        var blocklang = (typeof $el.attr('data-blocklang') != 'undefined')? $el.attr('data-blocklang') : LANG;
        
        if($el.find('.select-si-do .selected').length == 0) {
            $el.find('.select-gun-gu .dropdown-menu').html('<li class="empty"><a href="javascript:;">' + $.lang[blocklang]['contact.map.search.gungu'] + '</a></li>');
        }
    });

    $('[data-type="contact"][data-type2="franchise map"] .select-gun-gu li a').live('click', function(e){
        var $el = $(this).closest('.element');
        var $li = $(this).closest('li');
        var $btn = $(this).closest('.dropdown').find('button.dropdown-toggle > span');
        var idx = $(this).attr('data-idx');
        var val = $(this).attr('data-val');
        var valTxt = $(this).text();

        $el.find('.searchby-storename input').val('');
        $btn.text(valTxt);
        $btn.removeClass('selected');
        // console.log('gungu', val, $el.find('.select-si-do .selected'));
        // if(typeof val != 'undefined' && val) {
        //     $btn.addClass('selected');
        //     $btn.attr('data-selected-idx', idx);
        //     searchByStoreAddr($el, val);
        // } else {
        //     if($el.find('.select-si-do .selected')) {
        //         let selectedIdx = $('.select-si-do .selected').attr('data-selected-idx');
        //         searchByStoreAddr($el, $el.find('.select-si-do li a[data-idx="' + selectedIdx + '"]').attr('data-val'));
        //     } else {
        //         $el.find('.item').removeClass('hide not-result');                
        //     }
        // }
        if($el.find('.select-si-do .selected').length) {
            let selectedIdx = $('.select-si-do .selected').attr('data-selected-idx');
            searchByStoreAddr($el, $el.find('.select-si-do li a[data-idx="' + selectedIdx + '"]').attr('data-val'));

            if(typeof val != 'undefined' && val) {
                $btn.addClass('selected');
                $btn.attr('data-selected-idx', idx);
                searchByStoreAddr($el, val, 'gungu');
            }
        } else {
            $el.find('.map-item-list .map-item-empty').remove();
            $el.find('.item').removeClass('hide not-result');
            if ($('body').width() <= 991) fmapMobilePaging($el);
        }
    });

    $('[data-type="contact"][data-type2="franchise map"] .searchby-storename input[type="text"]').live('keyup', function(e){
        if(e.keyCode == 13) {
            var $el = $(this).closest('.element');
            searchByStorename($el);
        }
    });
    $('[data-type="contact"][data-type2="franchise map"] .searchby-storename .map-search-btn').live('click', function(e){
        var $el = $(this).closest('.element');
        searchByStorename($el);
    });

    $('[data-type="contact"][data-type2="franchise map"] .map-item-list > .item:not(.selected)').live('click', function(){
        var $el = $(this).closest('.element');
        var mapKind = $(this).attr('data-map_kind');
        $el.find('.map-item-list > .item').removeClass('selected');
        $(this).addClass('selected');

        drawMap($(this), $el);

        if($el.find('.map-info').length > 0) {
            var idx = (typeof $(this).attr('data-idx') == 'undefined')? 0 : $(this).attr('data-idx');
            // console.log('idx', idx);
            $el.find('.map-info').addClass('hide');
            $el.find('.map-info[data-idx="'+idx+'"]').removeClass('hide');
        }
    });

    var drawMap = function($item, $el){
        var iVALIDPLAN = (PAGE_MODE == 'c') ? VALIDPLAN : property.VALIDPLAN;
        var id = $el.attr('data-id');
        var mapKind = $item.attr('data-map_kind');
        var zoomInOut = $item.attr('data-zoominout');
        var mapTitle = $item.attr('data-maptitle');
        var mapContent = $item.attr('data-mapcontent');
        var useTitle = $item.attr('data-usetitle');
        var useContent = $item.attr('data-usecontent');
        var lat = $item.attr("data-lat");
        var lng = $item.attr("data-lng");

        if(typeof zoomInOut == 'undefined' || !zoomInOut) zoomInOut = false;
        if(typeof mapTitle == 'undefined' || !mapTitle) mapTitle = '';
        if(typeof mapContent == 'undefined' || !mapContent) mapContent = '';
        if(typeof useTitle == 'undefined' || !useTitle) useTitle = false;
        if(typeof useContent == 'undefined' || !useContent) useContent = false;

        zoomInOut = JSON.parse(zoomInOut);
        useTitle = JSON.parse(useTitle);
        useContent = JSON.parse(useContent);

        $el.find('.map-wrap').html('<div id="map-container-'+id+'" class="map-container"></div>')

        $el.find('.map-container').attr('data-map_kind', mapKind);
        $el.find('.map-container').attr('data-zoominout', zoomInOut);
        $el.find('.map-container').attr('data-maptitle', mapTitle);
        $el.find('.map-container').attr('data-mapcontent', mapContent);
        $el.find('.map-container').attr('data-usetitle', useTitle);
        $el.find('.map-container').attr('data-usecontent', useContent);

        var container = 'map-container-'+id;

        switch(mapKind) {
            case 'google':
                var mapUrl = $item.attr('data-map_url');
                var map_set = (mapUrl.match(/^@/) !== null) ? 'html' : 'link';
                var map_iframe = '';
                if(map_set == 'html') {
                    map_iframe = decodeURIComponent(atob(mapUrl.replace(/^@/,'')));
                    console.log(map_iframe);
                } else {
                    map_iframe = getMapURL(mapUrl, 'html');
                }
                $el.find('.map-wrap').html(map_iframe);
                break;
            case 'kakao':
                if($el.find('.map-container[data-map_kind="kakao"]').length && (typeof kakao == 'undefined' || typeof kakao.maps == 'undefined' || kakao.maps == null || iVALIDPLAN == '')) {
                    $el.find('.map-wrap').html('지도연결해제됨. Javascript키 확인');
                    $el.find('.map-wrap').html('<iframe class="google-map" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3165.5659473821083!2d127.0282496015659!3d37.494568!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x357ca1598c361b2b%3A0xdbf9af292beff3c!2z6rCV64Ko!5e0!3m2!1sko!2skr!4v1637303748377!5m2!1sko!2skr" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy"></iframe>');
                } else {
                    var options = { center: new kakao.maps.LatLng(lat, lng), level: 3};
                    var c_map = new kakao.maps.Map($('#' + container).get(0), options);
                    var marker = new kakao.maps.Marker({ position: new kakao.maps.LatLng(lat, lng), map: c_map});

                    if(zoomInOut == true) {
                        var zoomControlHtml = '';
                        zoomControlHtml += '\
                            <div class="zoom-control" style="margin-top: 8px; margin-right: 8px; right: 0; width: 30px; position: absolute; background-color: #fff; z-index: 1; border-radius: 3px; box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.16);">\
                                <div class="btn-zoom-control" data-inout="I" style="cursor: pointer; width: 30px; height: 30px;">\
                                    <svg style="fill: #6b6b6b; margin: 3px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M17 11h-4V7c0-.55-.45-1-1-1s-1 .45-1 1v4H7c-.55 0-1 .45-1 1s.45 1 1 1h4v4c0 .55.45 1 1 1s1-.45 1-1v-4h4c.55 0 1-.45 1-1s-.45-1-1-1z"/></svg>\
                                </div>\
                                <div class="slider-wrap-container" style="height: 130px;">\
                                    <div class="slider-wrap small" style="text-align: center; height: 100%;">\
                                        <div style="max-height: 100%;" class="zoom-control-slider"></div>\
                                    </div>\
                                </div>\
                                <div class="btn-zoom-control" data-inout="O" style="cursor: pointer; width: 30px; height: 30px;">\
                                    <svg style="fill: #6b6b6b; margin: 3px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M17 13H7c-.55 0-1-.45-1-1s.45-1 1-1h10c.55 0 1 .45 1 1s-.45 1-1 1z"/></svg>\
                                </div>\
                            </div>\
                        ';
                        var $zoomController = $(zoomControlHtml);
                        $('#' + container).append($zoomController);
                        var zoom_slider = $zoomController.find('.zoom-control-slider').slider({
                            'orientation': 'vertical',
                            'min' : 1,
                            'max' : 14,
                            'step' : 1,
                            'value' : 3,
                            'handle' : 'square',
                            'tooltip' : 'hide',
                        }).on('slide', function(data) {
                            c_map.setLevel(data.value);
                            c_map.setCenter(marker.getPosition());
                        }).on('slideStop', function(data) {
                            c_map.setLevel(data.value);
                            c_map.setCenter(marker.getPosition());
                        });

                        $zoomController.find('.btn-zoom-control').on('click', function() {
                            if($(this).data('inout') == 'I') {
                                c_map.setLevel(c_map.getLevel() - 1);
                                zoom_slider.slider('setValue', c_map.getLevel());
                            } else if($(this).data('inout' == 'O')) {
                                c_map.setLevel(c_map.getLevel() + 1);
                                zoom_slider.slider('setValue', c_map.getLevel());
                            }
                        });

                        kakao.maps.event.addListener(c_map, 'zoom_changed', function() {
                            zoom_slider.slider('setValue', c_map.getLevel());
                        });
                    }
                        
                    if(useTitle == true || useContent == true) {
                        var iwContent = '';

                        if(!mapTitle) mapTitle = $.lang[LANG]['config.contact.map.placeholder.place'];
                        if(!mapContent) mapContent = $.lang[LANG]['config.contact.map.placeholder.content'];

                        if(useTitle == true) {
                            iwContent = '<div class="title">' + mapTitle + '</div>';
                        }
                        if(useContent == true) {
                            iwContent += '<div class="content">' + mapContent + '</div>';
                        }
                        // console.log('iwContent', iwContent);
                        if(iwContent) {
                            iwContent = '<div class="contact-map-info-window"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 0C4.69 0 2 2.69 2 6s1 4 6 10c5-6 6-6.69 6-10s-2.69-6-6-6zm0 8.3a2.3 2.3 0 1 1 0-4.6 2.3 2.3 0 0 1 0 4.6z"/></svg>' + iwContent + '</div>';
                            var infoWindow = $(iwContent);
                            $('#' + container).append(infoWindow);
                        }
                    }

                    $(window).on("resize", function() {
                        c_map.setCenter(marker.getPosition());
                    });
                    c_map.relayout();
                }
                break;
            case 'naver':
                if($el.find('.map-container[data-map_kind="naver"]').length && (typeof naver == 'undefined' || typeof naver.maps == 'undefined' || naver.maps == null || iVALIDPLAN == '')) {
                    $el.find('.map-wrap').html('지도연결해제됨. Client ID 확인');
                    $el.find('.map-wrap').html('<iframe class="google-map" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3165.5659473821083!2d127.0282496015659!3d37.494568!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x357ca1598c361b2b%3A0xdbf9af292beff3c!2z6rCV64Ko!5e0!3m2!1sko!2skr!4v1637303748377!5m2!1sko!2skr" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy"></iframe>');
                } else {       
                    var options = { center: new naver.maps.LatLng(lat, lng), zoom: 17};
                    var c_map = new naver.maps.Map(container, options);
                    var marker = new naver.maps.Marker({ position: new naver.maps.LatLng(lat, lng), map: c_map});

                    if(zoomInOut == true) {
                        var zoomControlHtml = '';
                        zoomControlHtml += '\
                            <div class="zoom-control" style="margin-top: 8px; margin-right: 8px; right: 0; width: 30px; position: absolute; background-color: #fff; z-index: 1; border-radius: 3px; box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.16);">\
                                <div class="btn-zoom-control" data-inout="I" style="cursor: pointer; width: 30px; height: 30px;">\
                                    <svg style="fill: #6b6b6b; margin: 3px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M17 11h-4V7c0-.55-.45-1-1-1s-1 .45-1 1v4H7c-.55 0-1 .45-1 1s.45 1 1 1h4v4c0 .55.45 1 1 1s1-.45 1-1v-4h4c.55 0 1-.45 1-1s-.45-1-1-1z"/></svg>\
                                </div>\
                                <div class="slider-wrap-container" style="height: 130px;">\
                                    <div class="slider-wrap small" style="text-align: center; height: 100%;">\
                                        <div style="max-height: 100%;" class="zoom-control-slider"></div>\
                                    </div>\
                                </div>\
                                <div class="btn-zoom-control" data-inout="O" style="cursor: pointer; width: 30px; height: 30px;">\
                                    <svg style="fill: #6b6b6b; margin: 3px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M17 13H7c-.55 0-1-.45-1-1s.45-1 1-1h10c.55 0 1 .45 1 1s-.45 1-1 1z"/></svg>\
                                </div>\
                            </div>\
                        ';
                        var $zoomController = $(zoomControlHtml);
                        $('#' + container).append($zoomController);
                        var zoom_slider = $zoomController.find('.zoom-control-slider').slider({
                            'orientation': 'vertical',
                            'min' : 6,
                            'max' : 21,
                            'step' : 1,
                            'value' : 17,
                            'handle' : 'square',
                            'reversed' : true,
                            'tooltip' : 'hide',
                        }).on('slide', function(data) {
                            c_map.setZoom(data.value);
                            c_map.setCenter(marker.getPosition());
                        }).on('slideStop', function(data) {
                            c_map.setZoom(data.value);
                            c_map.setCenter(marker.getPosition());
                        });
                        $zoomController.find('.btn-zoom-control').on('click', function() {
                            if($(this).data('inout') == 'I') {
                                c_map.setZoom(c_map.getZoom() + 1);
                                zoom_slider.slider('setValue', c_map.getZoom());
                            } else if($(this).data('inout' == 'O')) {
                                c_map.setZoom(c_map.getZoom() - 1);
                                zoom_slider.slider('setValue', c_map.getZoom());
                            }
                        });

                        naver.maps.Event.addListener(c_map, 'zoom_changed', function(zoom) {
                            zoom_slider.slider('setValue', c_map.getZoom());
                        });
                    }

                    if(useTitle == true || useContent == true) {
                        var iwContent = '';
                        
                        if(!mapTitle) mapTitle = $.lang[LANG]['config.contact.map.placeholder.place'];
                        if(!mapContent) mapContent = $.lang[LANG]['config.contact.map.placeholder.content'];

                        if(useTitle == true) {
                            iwContent = '<div class="title">' + mapTitle + '</div>';
                        }
                        if(useContent == true) {
                            iwContent += '<div class="content">' + mapContent + '</div>';
                        }

                        if(iwContent) {
                            iwContent = '<div class="contact-map-info-window"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 0C4.69 0 2 2.69 2 6s1 4 6 10c5-6 6-6.69 6-10s-2.69-6-6-6zm0 8.3a2.3 2.3 0 1 1 0-4.6 2.3 2.3 0 0 1 0 4.6z"/></svg>' + iwContent + '</div>';
                            var infoWindow = $(iwContent);
                            $('#' + container).append(infoWindow);
                            // infoWindow.css('bottom', 'calc(-100% + ' + (infoWindow.outerHeight() + 36) + 'px)');  
                        }
                    }
                    $(window).on("resize", function() {
                        c_map.setCenter(marker.getPosition());
                    });
                }
                break;
        }
    }

    var setDefaultFranchiseMap = function($el) {
        let blocklang = (typeof $el.attr('data-blocklang') != 'undefined')? $el.attr('data-blocklang') : LANG;
        $el.find('.map-search-dropdown .dropdown-menu').html('');
        $el.find('.map-search-dropdown .dropdown-toggle > span').removeClass('selected');
        $el.find('.select-si-do .dropdown-toggle > span').text($.lang[blocklang]['contact.map.search.sido']);
        $el.find('.select-gun-gu .dropdown-toggle > span').text($.lang[blocklang]['contact.map.search.gungu']);
        $el.find('.searchby-storename input').val('');

        $el.find('.map-item-list > .item').removeAttr('style');
        $el.find('.map-item-list > .item').removeClass('__matrix_focus');
        $el.find('.map-item-list > .item').removeClass('hide');
        $el.find('.map-item-list > .item').removeClass('selected');
        $el.find('.map-item-list > .item').eq(0).addClass('selected');
        $el.find('.map-item-list .map-item-empty').remove();

        if($el.find('.map-info').length > 0) {
            $el.find('.map-info').addClass('hide');
            $el.find('.map-info').eq(0).removeClass('hide');
        }

        drawMap($el.find('.map-item-list > .item').eq(0), $el);
    }

    var paginatedItems = new Array();
    var fmapMobilePaging = function($el) { //init
        var $items = $el.find('[data-fmap-loop="true"] > .item:not(.not-result)');
        var itemArr = $items.get();
        var itemsPerPage = ($('body').width() <= 767)? 3 : 8;
        // console.log('itemArr', itemArr);
        if($('body').width() <= 767) {
            if($el.find('[data-fmap-loop="true"]').attr('data-view-m')) itemsPerPage = $el.find('[data-fmap-loop="true"]').attr('data-view-m') * 1;
        } else if($('body').width() <= 991) {
            if($el.find('[data-fmap-loop="true"]').attr('data-view-t')) itemsPerPage = $el.find('[data-fmap-loop="true"]').attr('data-view-t') * 1;
        } else {
            $items.removeClass('hide');
        }
        // console.log('itemsPerPage', itemsPerPage);

        // 전체 페이지 수 계산
        var totalPages = Math.ceil(itemArr.length / itemsPerPage);

        // console.log('totalPages', totalPages);
        if ($('body').width() <= 991) {

            if(totalPages > 1) {
                // 배열을 페이지당 나누기
                var pageNumHTML = '';
                var elname = $el.attr('data-name');
                paginatedItems[elname] = [];
                // console.log(paginatedItems);
                for (var i = 0; i < totalPages; i++) {
                    var start = i * itemsPerPage;
                    var end = start + itemsPerPage;
                    // console.log(start, end);
                    paginatedItems[elname].push(itemArr.slice(start, end));
                }

                var endPage = paginatedItems[elname].length - 1;
                // console.log('paginatedItems[elname]', paginatedItems[elname]);
                $.each(paginatedItems[elname], function(idx, v){
                    var pageNum = idx + 1;
                    pageNumHTML += '<li class="' + (pageNum == 1? 'active' : '') + '" data-item-page="' + idx + '">'+pageNum+'</li>'
                });

                var paginationHTML = '\
                <ul class="display-flex align-items-center">\
                    <li class="go-start disabled" data-item-page="0"><i class="fa fa-angle-double-left" aria-hidden="true"></i></li>\
                    <li class="go-prev disabled" data-item-page="prev"><i class="fa fa-angle-left" aria-hidden="true"></i></li>\
                    ' + pageNumHTML + '\
                    <li class="go-next" data-item-page="next"><i class="fa fa-angle-right" aria-hidden="true"></i></li>\
                    <li class="go-end" data-item-page="' + endPage + '"><i class="fa fa-angle-double-right" aria-hidden="true"></i></li>\
                </ul>\
                ';

                $el.find('.m-map-pagination').html(paginationHTML);

                $items.addClass('hide');
                $.each(paginatedItems[elname][0], function(idx, v){
                    $(v).removeClass('hide');
                });
            } else {
                $el.find('.m-map-pagination').html('');
            }

            $('.m-map-pagination > ul > li:not(.disabled)').die('click');
            $('.m-map-pagination > ul > li:not(.disabled)').live('click', function(){
                let $this = (typeof isElviewPage != 'undefined' && isElviewPage === true)? $(this).closest('.el_viewblock') : $(this).closest('.element');
                let page = $(this).attr('data-item-page');
                let currentElName = $this.attr('data-name');
                let endPage = $this.find('li.go-end').attr('data-item-page') * 1;
                let activated = $this.find('.m-map-pagination > ul > li.active').attr('data-item-page') * 1;
                let currentItems = new Array();

                $this.find('.m-map-pagination > ul > li').removeClass('active');
                $this.find('.m-map-pagination > ul > li').removeClass('disabled');

                if(isNaN(activated)) activated = endPage;
                // console.log(activated, endPage, paginatedItems[currentElName]);
                switch (page) {
                    case 'prev':
                        if(activated > 0) {
                            page = activated - 1;
                        } else {
                            page = 0;
                        }
                        break;
                    case 'next':
                        if(activated < endPage) {
                            page = activated + 1;
                        } else {
                            page = endPage;
                        }
                        break;
                    default:
                        page = page * 1;
                        break;
                }

                if(page == 0) {
                    $this.find('.m-map-pagination > ul > li.go-start').addClass('disabled');
                    $this.find('.m-map-pagination > ul > li.go-prev').addClass('disabled');
                }
                if(page == endPage) {
                    $this.find('.m-map-pagination > ul > li.go-end').addClass('disabled');
                    $this.find('.m-map-pagination > ul > li.go-next').addClass('disabled');
                }

                currentItems = paginatedItems[currentElName][page];
                // console.log('currentItems', page, currentItems);
                $this.find('[data-fmap-loop="true"] > .item').addClass('hide');
                if(typeof currentItems != 'undefined') {
                    $.each(currentItems, function(idx, v){
                        // console.log($(v));
                        $(v).removeClass('hide');
                    });
                }

                $this.find('.m-map-pagination > ul > li[data-item-page="' + page + '"]:not(.go-start):not(.go-end)').addClass('active');
            });
        }
    }

    $('#comm-name,#comm-pass').live('blur', function(e) {
        if ($(this).hasClass('guestbook-pass')) return false;
        window.scrollTo(0, 0);
    });
    var getLocation = function(url) {
        var parser = document.createElement('a');
        parser.href = url;
        parser.href = parser.href;

        if (parser.host === '') {
            var newProtocolAndHost = window.location.protocol + '//' + window.location.host;
            if (url.charAt(1) === '/') {
                parser.href = newProtocolAndHost + url;
            } else {
                var currentFolder = ('/' + parser.pathname).match(/.*\//)[0];
                parser.href = newProtocolAndHost + currentFolder + url;
            }
        }
        var properties = ['host', 'hostname', 'hash', 'href', 'port', 'protocol', 'search'];
        for (var i = 0, n = properties.length; i < n; i++) {
            this[properties[i]] = parser[properties[i]];
        }
        this.pathname = (parser.pathname.charAt(0) !== '/' ? '/' : '') + parser.pathname;
    }


    var setResizeImageFolder = function(w, content_image) {
        var magic_type = (PAGE_MODE == 'c') ? SETTINGS.magic_type : property.SETTINGS.magic_type,
            check_magic_type = (typeof magic_type != 'undefined' && magic_type == 'webp') ? true : false;
        t = (check_magic_type) ? '-rw' : '';

        var r = '';
        if (content_image && content_image.lastIndexOf('=') > -1) {
            var image_index = content_image.lastIndexOf('=');
            content_image = content_image.substr(0, image_index);

            switch (w) {

                case "0":
                    r = content_image + '=s0' + t;
                    break;
                case "60":
                    r = content_image + '=w60-h60-n' + t;
                    break;
                case "250":
                    r = content_image + '=w250-h250-n' + t;
                    break;
                case "300":
                    r = content_image + '=w300-h300-n' + t;
                    break;
                case "600":
                    r = content_image + '=w600-h600-n' + t;
                    break;
                case "650":
                    r = content_image + '=w650-h370-n' + t;
                    break;
                case "670":
                    r = content_image + '=w670-h980-n' + t;
                    break;
                case "700":
                    r = content_image + '=w700-h500-n' + t;
                    break;
                case "800":
                    r = content_image + '=w800' + t;
                    break;
                    //case "1920": break;
                default:
                    r = content_image;
                    break;
            }
        }

        return r;
    }

    function changeLanguage(code, mode) {
        var isSYNC = false;

        if (typeof mode != 'undefined' && typeof mode == 'object') isSYNC = false;
        else isSYNC = (typeof mode != 'undefined' && mode && mode.match(/^sync_/gi) !== null) ? true : false;
        var sid = (typeof SID == 'undefined') ? property.SID : SID,
            type = '';

        if (typeof mode == 'undefined') {
            type = (typeof property !== 'undefined' && property.LOAD == 'RENDER') ? 'render' : 'publish';
        } else if (typeof mode == 'object') {
            type = 'board';
        } else {
            type = 'config';

            if (isSYNC) type = mode.replace(/^sync_/gi, '');
        }

        $.post('/language/' + code, { sid: sid, type: type }, function(data) {
            if (isSYNC) {
                // console.log('change language');
                return false;
            } else {
                if (typeof mode == 'undefined') {
                    if (typeof property !== 'undefined' && property.LOAD == 'RENDER') location.href = '/render';
                    else location.href = '/';
                } else if (typeof mode == 'object') {
                    var url = $(mode).attr('data-url');
                    var checkDashboard = '/dashboard';
                    if (window.location.href.indexOf(checkDashboard) > -1) { //dashboard         
                        window.open(url, '_blank').focus();
                    } else {
                        location.href = url;
                    }
                } else {
                    if (mode == 'end_config') {
                        console.log('change language');
                        return false;
                    }
                    location.href = '/' + CONFIG_URL + 'config';
                }
            }
        }, 'json');
    }


    $(document).on('click', '.bizcommpop-open', function(e) {
        var url = 'http://www.ftc.go.kr/bizCommPop.do?wrkr_no=1148687877';
        window.open(url, 'bizCommPop', 'width=750, height=700;');
    });


    function setMadeWithCreatorlink() {
        var s_service = (typeof SERVICE == 'undefined') ? ((typeof property == 'undefined') ? '' : property.SERVICE) : SERVICE,
            s_plantype = (typeof VALIDTYPE == 'undefined') ? ((typeof property == 'undefined') ? '' : property.VALIDTYPE) : VALIDTYPE;

        var checkGabia = (s_service.indexOf('gabia') > -1) ? true : false,
            made_width = (checkGabia && LANG == 'ko') ? 'w-2' : '',
            go_to_link = (checkGabia) ? 'http://creatorlink-gabia.com' : 'http://creatorlink.net?utm_source=FreeSite&utm_medium=banner&utm_campaign=powered_by_Creatorlink&utm_term=sitebanner&utm_content=free',
            go_to_txt = (checkGabia) ? 'footer.made-mark.description.gabia' : 'footer.made-mark.description',
            made_txt = $.lang[LANG]['footer.made-mark.description.title'];
        // upgrade_href = (checkGabia) ? 'href="https://www.gabia.com/mygabia/service" target="_blank"' : 'href="/upgrade/site/"';

        if ($('.dsgn-body').find('.made-with-creatorlink').length > 0) {
            $('.dsgn-body').find('.made-with-creatorlink').show().attr('style', 'display: block!important');
        } else {
            var svg_logo = '<svg class="made-with-creatorlink-logo logo-b logo-p" alt="Creatorlink logo" role="img" viewBox="0 0 168 38"><path class="st11" d="M70.71 12.36c-3.48 0-5.9 2.19-5.9 5.34v4.11c0 3.34 2.17 5.25 5.96 5.25 2.06 0 3.98-0.58 5.41-1.64l0.14-0.11 -1.03-1.95 -0.2 0.1c-1.67 0.85-2.74 1.15-4.11 1.15 -2.23 0-3.23-0.87-3.23-2.83v-0.94h8.62v-3.08C76.37 14.13 74.52 12.36 70.71 12.36zM73.52 18.45h-5.77v-0.92c0-1.91 1.53-2.78 2.96-2.78 2.02 0 2.81 0.78 2.81 2.78V18.45z"></path><path class="st11" d="M84.38 12.36c-1.52 0-3.34 0.55-4.87 1.47l-0.17 0.1 1.11 1.95 0.19-0.1c1.41-0.69 2.48-0.98 3.59-0.98 2.22 0 2.93 0.51 2.93 2.1v1.29h-3.64c-3.09 0-4.65 1.47-4.65 4.37 0 1.22 0.39 2.33 1.09 3.12 0.76 0.85 1.84 1.3 3.12 1.3 0.09 0 0.18 0 0.26-0.01 1.37-0.06 2.71-0.51 3.97-0.99l0.04 0.79h2.76v-9.76C90.11 13.76 88.39 12.36 84.38 12.36zM87.17 23.79l-0.01 0c-0.83 0.32-1.87 0.72-3.2 0.73h-0.06c-1.46 0-2.08-0.6-2.08-2.01 0-1.37 0.55-1.92 1.89-1.92h3.47V23.79z"></path><path class="st11" d="M101.06 24.31c-0.95 0.23-1.63 0.33-2.26 0.33 -1.16 0-1.27-0.36-1.27-1.31v-8.47h3.9l0-2.22h-3.9V9.26l-2.94 0.01v3.38h-2.56v2.22h2.56v8.86c0 2.31 1.18 3.34 3.82 3.34 1.04 0 2.14-0.18 3.11-0.52l0.17-0.06 -0.4-2.23L101.06 24.31z"></path><path class="st11" d="M109.95 12.36c-3.88 0-6.11 1.96-6.11 5.36v3.97c0 3.41 2.23 5.36 6.11 5.36 3.88 0 6.11-1.96 6.11-5.36v-3.97C116.06 14.32 113.84 12.36 109.95 12.36zM113.12 21.78c0 1.89-1.04 2.8-3.17 2.8 -2.13 0-3.17-0.92-3.17-2.8v-4.14c0-1.89 1.04-2.8 3.17-2.8 2.13 0 3.17 0.92 3.17 2.8V21.78z"></path><path class="st11" d="M59.07 14.72l0.01-2.07H56.3v14.13h2.94v-9.04c1.75-1.89 4.2-3.24 4.2-3.24l-1.4-1.84C62.04 12.65 60.26 13.76 59.07 14.72z"></path><path class="st11" d="M121.93 14.72l0.01-2.07h-2.77v14.13h2.94v-9.04c1.75-1.89 4.2-3.24 4.2-3.24l-1.4-1.84C124.91 12.65 123.12 13.76 121.93 14.72z"></path><path class="st11" d="M51.54 22.93c-0.96 1.11-2.12 1.66-3.56 1.66 -2.13 0-3.17-0.92-3.17-2.8v-4.14c0-1.89 1.04-2.8 3.17-2.8 1.73 0 2.83 0.77 3.68 1.52l0.13 0.12 1.99-1.39 -0.13-0.17c-0.76-0.95-2.5-2.55-5.67-2.55 -3.88 0-6.11 1.96-6.11 5.36v3.97c0 3.41 2.23 5.36 6.11 5.36 3.03 0 4.76-1.58 5.68-2.91l0.13-0.18 -2.13-1.18L51.54 22.93z"></path><rect x="128.71" y="6.68" class="st11" width="1.2" height="20.07"></rect><rect x="134.41" y="12.69" class="st11" width="1.2" height="14.06"></rect><rect x="134.41" y="8.29" class="st11" width="1.2" height="2.18"></rect><path class="st11" d="M148.67 13.44c-1.68-0.98-5.06-0.52-7.21 0.71V12.5h-1.2v14.25h1.2V15.33c1.74-1.3 5.26-1.79 6.61-1 1.38 0.81 1.38 2.37 1.38 2.43v9.99h1.2v-9.99C150.65 16.67 150.63 14.59 148.67 13.44z"></path><polygon class="st11" points="158.27 18.97 164.05 12.69 162.6 12.69 156 19.89 156 6.68 154.8 6.68 154.8 26.75 156 26.75 156 21.44 157.54 19.77 163.6 26.75 165 26.75 "></polygon><path class="st11" d="M3 10.79L3 10.79l0 16.42 14.22 8.21 14.22-8.21V10.79L17.22 2.58 3 10.79zM26.7 13.53L26.7 13.53 26.7 13.53l-4.74 2.74h0l-4.74-2.74 -4.74 2.74v5.47l4.74 2.74 4.74-2.74 4.74 2.74 -9.48 5.47 -9.48-5.47V13.53l9.48-5.47L26.7 13.53 26.7 13.53z"></path></svg>',
                svg_logo_m = '<svg class="made-with-creatorlink-logo logo-b logo-m" alt="Creatorlink logo" viewBox="0 0 26 30" width="26" height="30"><path class="st11" d="M1 8.1L1 8.1V22l12 6.9L25 22V8.1L13 1.2 1 8.1zM21 10.5L21 10.5 21 10.5l-4 2.3 0 0 -4-2.3 -4 2.3v4.6l4 2.3 4-2.3 4 2.3 -8 4.6L5 19.7v-9.2l8-4.6L21 10.5 21 10.5z"/></svg>',
                str = '\
                    <div class="made-with-creatorlink ' + made_width + '" alt="' + made_txt + '" title="' + made_txt + '">\
                        <a class="made-creatorlink-link" href="' + go_to_link + '" target="_blank">\
                            <div class="inner-logo">' + svg_logo + svg_logo_m + '</div>\
                            <div class="inner-txt">\
                                <ul>\
                                    <li>' + $.lang[LANG][go_to_txt + '.1'] + '</li>\
                                    <li>' + $.lang[LANG][go_to_txt + '.2'] + '</li>\
                                </ul>\
                            </div>\
                            <div class="inner-btn"><span>' + $.lang[LANG]['footer.made-mark.btn'] + '</span></div>\
                        </a>\
                    </div>\
                ';
            $('.dsgn-body').append(str);

            var mwcRollingId = new Interval(mwcRollingStart, 3000);
            mwcRollingId.start();
        }
    }

    function setMadeWithCreatorlinkOld() {
        var host = (typeof SERVICE == 'undefined') ? property.SERVICE : SERVICE,
            made_width = (host.indexOf('gabia') > -1 && LANG == 'ko') ? 'w-2' : '',
            go_to_link = (host.indexOf('gabia') > -1) ? 'http://creatorlink-gabia.com' : 'http://creatorlink.net?utm_source=FreeSite&utm_medium=banner&utm_campaign=powered_by_Creatorlink&utm_term=sitebanner&utm_content=free',
            go_to_txt = (host.indexOf('gabia') > -1) ? 'footer.made-mark.description.gabia' : 'footer.made-mark.description',
            made_txt = $.lang[LANG]['footer.made-mark.description.title'];

        if ($('.dsgn-body').find('.made-with-creatorlink').length > 0) {
            $('.dsgn-body').find('.made-with-creatorlink').show().attr('style', 'display: block!important');
        } else {
            var svg_logo = '<svg class="made-with-creatorlink-logo" viewBox="0 0 26 30" width="26" height="30"><path class="st11" d="M1 8.1L1 8.1V22l12 6.9L25 22V8.1L13 1.2 1 8.1zM21 10.5L21 10.5 21 10.5l-4 2.3 0 0 -4-2.3 -4 2.3v4.6l4 2.3 4-2.3 4 2.3 -8 4.6L5 19.7v-9.2l8-4.6L21 10.5 21 10.5z"/></svg>',
                str = '\
                    <div class="made-with-creatorlink ' + made_width + '" alt="' + made_txt + '" title="' + made_txt + '">\
                        <a class="made-creatorlink-link" href="' + go_to_link + '" target="_blank">\
                            <div class="inner-logo">' + svg_logo + '</div>\
                            <div class="inner-txt">\
                                <ul>\
                                    <li>' + $.lang[LANG][go_to_txt + '.1'] + '</li>\
                                    <li>' + $.lang[LANG][go_to_txt + '.2'] + '</li>\
                                </ul>\
                            </div>\
                        </a>\
                    </div>\
                ';
            $('.dsgn-body').append(str);

            var mwcRollingId = new Interval(mwcRollingStart, 3000);
            mwcRollingId.start();
        }
    }

    function mwcRollingStart() {
        var $mwcUl = $('.made-with-creatorlink').find('ul'),
            $mwcHeight = $mwcUl.children().outerHeight(),
            $length = $mwcUl.children().length;

        $mwcUl.css('height', $mwcHeight + 'px');
        $mwcUl.animate({ top: -$mwcHeight + 'px' }, 1000, 'easeInOutQuart', function() {
            $(this).append($(this).find('li:first').clone().wrapAll('<li/>').parent().html());

            $(this).find('li:first').remove();
            $(this).css('top', 0);
        });
    }

    function Interval(fn, time) {
        var timer = false;
        this.start = function() {
            if (!this.isRunning())
                timer = setInterval(fn, time);
        };
        this.stop = function() {
            clearInterval(timer);
            timer = false;
        };
        this.isRunning = function() {
            return timer !== false;
        };
    }

    function siteNotice(fn, checkDouble, mode, sidchk) {
        var s_service = (typeof SERVICE == 'undefined') ? ((typeof property == 'undefined') ? '' : property.SERVICE) : SERVICE,
            s_plantype = (typeof VALIDTYPE == 'undefined') ? ((typeof property == 'undefined') ? '' : property.VALIDTYPE) : VALIDTYPE;

        var mode = (mode) ? mode : 'dashbord',
            checkDouble = (typeof checkDouble != 'undefined' && checkDouble) ? checkDouble : '',
            checkGabia = (s_service.indexOf('gabia') > -1) ? true : false,
            checkGabiaOther = ['manager', 'nickname', 'language', 'chmod', 'chmod.group', 'chmod.commentLevel', 'siteclone'],
            description_other = (checkGabia) ? (($.inArray(fn, checkGabiaOther) > -1) ? '.GA' : '') : '',
            upgrade_url = (checkGabia) ? 'https://www.gabia.com/mygabia/service" target="_blank' : ((fn == 'shopping') ? '/shoppingevent' : '/upgrade/site/'),
            sidchk = (sidchk) ? sidchk : '';

        // if(fn == 'gabia.bn.chmod') {
        //     fn = 'chmod';
        //     description_other = '.GA';
        //     upgrade_url = '/manager/member';

        var modal_title = $.lang[LANG]['dashbord.upgrade.' + fn + '.title' + description_other];
            modal_description = $.lang[LANG]['dashbord.upgrade.' + fn + '.description' + description_other],
            modal_class = 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0';

        if (fn == 'kakao_onlynumber') {
            modal_title = $.lang[LANG]['site.delete.process.end.title'];
            modal_description = $.lang[LANG]['shopping.dashboard.kakaoNotice.onlynumber']
        };
        if (fn == 'kakao_number_length') {
            modal_title = $.lang[LANG]['site.delete.process.end.title'];
            modal_description = $.lang[LANG]['shopping.dashboard.kakaoNotice.numlength']
        };
        if (fn == 'kakao_dupnumber') {
            modal_title = $.lang[LANG]['site.delete.process.end.title'];
            modal_description = $.lang[LANG]['shopping.dashboard.kakaoNotice.dupnumber']
        };
        if (fn == 'notificationtalkmail') {
            modal_title = $.lang[LANG]['dashbord.upgrade.kakaoemail.title'];
            modal_description = $.lang[LANG]['dashbord.upgrade.kakaoemail.description']
        };
        if (fn == 'notificationtalkmailgabia') {
            modal_title = $.lang[LANG]['dashbord.upgrade.kakaoemail.title'];
            modal_description = $.lang[LANG]['dashbord.upgrade.kakaoemailgabia.description']
        };        
        if (fn == 'kakaoShoppingDisable') {
            modal_title = $.lang[LANG]['dashbord.upgrade.kakaodisable.title'];
            modal_description = $.lang[LANG]['dashbord.upgrade.kakaodisable.description']
        };
        if (fn == 'go_upgradepage') {
            modal_title = $.lang[LANG]['dashbord.upgrade.transfer.title'];
            modal_description = $.lang[LANG]['dashbord.upgrade.transfer.description']
        };

        switch(fn) {
            case 'metaDetail':
            case 'metaPlus':
            case 'metaOnepage':
                modal_title = $.lang[LANG]['dashbord.upgrade.meta.title'];
                break;
            case 'sitelimit':
                modal_title = $.lang[LANG]['dashbord.upgrade.siteclone.title'];
                break;
            case 'chmod.group':
                if (s_plantype == 'BN') modal_description = $.lang[LANG]['dashbord.upgrade.chmod.group.description.bn'];
                break;
            case 'chmod.commentLevel':
                if (checkGabia && $('.' + selectEL).is('[data-type="gallery"]')) modal_title = $.lang[LANG]['dashbord.upgrade.chmod.commentLevel.gallery.title.GA'];
                break;
            case 'cert':
                modal_class = 'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0 site-not-cert-modal';
                break;
            case 'menufixbtn':
            case 'menufixlang':
                modal_title = $.lang[LANG]['config.upgrade.'+fn+'.title'];
                modal_description = (checkGabia) ? $.lang[LANG]['config.upgrade.' + fn + '.description.gabia'] : $.lang[LANG]['config.upgrade.' + fn + '.description'];
                break;
            case 'kakao_onlynumber':
                modal_title = $.lang[LANG]['site.delete.process.end.title']; 
                modal_description = $.lang[LANG]['shopping.dashboard.kakaoNotice.onlynumber'];
                break;
            case 'kakao_number_length':
                modal_title = $.lang[LANG]['site.delete.process.end.title']; 
                modal_description = $.lang[LANG]['shopping.dashboard.kakaoNotice.numlength'];
                break;
            case 'kakao_dupnumber':
                modal_title = $.lang[LANG]['site.delete.process.end.title']; 
                modal_description = $.lang[LANG]['shopping.dashboard.kakaoNotice.dupnumber'];
                break;
            case 'notificationtalkmail':
                modal_title = $.lang[LANG]['dashbord.upgrade.kakaoemail.title']; 
                modal_description = $.lang[LANG]['dashbord.upgrade.kakaoemail.description'];
                break;
            case 'kakaoShoppingDisable':
                modal_title = $.lang[LANG]['dashbord.upgrade.kakaodisable.title']; 
                modal_description = $.lang[LANG]['dashbord.upgrade.kakaodisable.description'];
                break;
            case 'go_upgradepage':
                modal_title = $.lang[LANG]['dashbord.upgrade.transfer.title'];
                modal_description = $.lang[LANG]['dashbord.upgrade.transfer.description'];  
                break;
            default:
                break;
        }


        var btnstr = '\
                <div class="btn-box">\
                    <a href="' + upgrade_url + '" id="upgrade-usemember-link" class="btn" target="_blank">\
                    <svg viewBox="0 0 18 18" width="18" height="18"><polygon points="9 0 1 8 5 8 5 11 13 11 13 8 17 8 "/><rect x="5" y="13" width="8" height="2"/><rect x="5" y="17" width="8" height="1"/></svg>' + $.lang[LANG]['dashbord.toolbar.upgrade-site'] + '</a>\
                    <button type="button" class="btn btn-default btn-sm close-button-dialog" data-dismiss="modal">' + $.lang[LANG]['config.close'] + '</button>\
                </div>\
        ';
        if (fn == 'sitelimit') {
            btnstr = '\
                <div class="btn-box btn-closeOnly">\
                    <button type="button" class="btn btn-default btn-sm close-button-dialog" data-dismiss="modal">' + $.lang[LANG]['config.close'] + '</button>\
                </div>\
            ';
        } else if (fn == 'kakaoShoppingDisable') {
            btnstr = '\
                    <div class="btn-box">\
                        <a href="' + upgrade_url + '" id="upgrade-usemember-link" class="btn" target="">\
                        <svg viewBox="0 0 18 18" width="18" height="18"><polygon points="9 0 1 8 5 8 5 11 13 11 13 8 17 8 "/><rect x="5" y="13" width="8" height="2"/><rect x="5" y="17" width="8" height="1"/></svg>' + $.lang[LANG]['dashbord.toolbar.upgrade-site'] + '</a>\
                        <button type="button" class="btn btn-default btn-sm close-button-dialog" data-dismiss="modal">' + $.lang[LANG]['config.close'] + '</button>\
                    </div>\
            ';
        } else if (fn == 'go_upgradepage' || fn == 'siteclone') {
            btnstr = '\
                    <div class="btn-box">\
                        <a href="' + upgrade_url + sidchk + '" id="upgrade-usemember-link" class="btn" target="">\
                        <svg viewBox="0 0 18 18" width="18" height="18"><polygon points="9 0 1 8 5 8 5 11 13 11 13 8 17 8 "/><rect x="5" y="13" width="8" height="2"/><rect x="5" y="17" width="8" height="1"/></svg>' + $.lang[LANG]['dashbord.toolbar.upgrade-site'] + '</a>\
                        <button type="button" class="btn btn-default btn-sm close-button-dialog" data-dismiss="modal">' + $.lang[LANG]['config.close'] + '</button>\
                    </div>\
            ';
        } else if (fn == 'kakao_number_length' || fn == 'kakao_onlynumber' || fn == 'kakao_dupnumber') {
            btnstr = '\
                <div class="btn-box btn-closeOnly">\
                    <button type="button" class="btn btn-default btn-sm close-button-dialog" data-dismiss="modal">' + $.lang[LANG]['config.close'] + '</button>\
                </div>\
            ';
        }
        var str = '\
            <div class="site-upgrade-notice">\
                <p><span class="text-centermodal">' + modal_description + '</span></p>\
                ' + btnstr +
            '</div>\
        ';

        // $(this).showModalFlat(modal_title, str, false, false, '', '', '', modal_class, '', '', '', function() {
        //     if (checkDouble) $('.modal.modal-default.fade.in').css('zIndex', '');

        $(this).showModalFlat(modal_title, str,false,false,'','','',modal_class,'','','',function(){
            if(checkDouble) {$('.modal.modal-default.fade.in').css('zIndex','');}
        });
    }

    function hideMadeWithCreatorlink() {
        $('.goto-top').removeClass('moved');
        $('#cl-music-player-icon').removeClass('moved');
        $('.made-with-creatorlink').hide();
    }

    function sites(s) {
        var sites_deferred = $.Deferred();
        if (typeof s == 'undefined') sites_deferred.reject('sid Undefined :(');
        else {
            $.ajax({
                url: '/template/publishSites',
                data: { sid: s },
                type: 'POST',
                dataType: 'json',
                async: true,
                cashe: false,
                success: function(data) {
                    if (typeof data.error != 'undefined' && data.error) {
                        sites_deferred.reject(data.error);
                        return false;
                    }

                    sites_deferred.resolve(data);
                }
            });
        }
        return sites_deferred.promise();
    }

    function pbSite(s, onoff) {
        var pbSite_deferred = $.Deferred();
        if (typeof s == 'undefined') pbSite_deferred.reject('sid Undefined :(');
        else {
            $.ajax({
                url: '/template/publish1',
                data: { sid: s, onoff: onoff },
                type: 'POST',
                dataType: 'json',
                async: true,
                cashe: false,
                success: function(data) {
                    if (typeof data.error != 'undefined' && data.error) {
                        pbSite_deferred.reject(data.error);
                        return false;
                    }

                    pbSite_deferred.resolve(data);
                }
            });
        }
        return pbSite_deferred.promise();
    }

    function pbGallery(s, onoff, count, p, sCount, i) {
        var pbGallery_deferred = $.Deferred();
        if (typeof s == 'undefined') pbGallery_deferred.reject('sid Undefined :(');
        else {
            $.ajax({
                url: '/template/publish2',
                data: { sid: s, onoff: onoff, count: count, p: p + 1, sCount: sCount, i: i },
                type: 'POST',
                dataType: 'json',
                async: true,
                cashe: false,
                success: function(data) {
                    if (typeof data.error != 'undefined' && data.error) {
                        pbGallery_deferred.reject(data.error);
                        return false;
                    }

                    pbGallery_deferred.resolve(data);
                }
            });
        }
        return pbGallery_deferred.promise();
    }

    function pbPages(s, onoff, count, p, sCount, i) {
        var pbPages_deferred = $.Deferred();
        if (typeof s == 'undefined') pbPages_deferred.reject('sid Undefined :(');
        else {
            $.ajax({
                url: '/template/publish3',
                data: { sid: s, onoff: onoff, count: count, p: p + 1, sCount: sCount, i: i },
                type: 'POST',
                dataType: 'json',
                async: true,
                cashe: false,
                success: function(data) {
                    if (typeof data.error != 'undefined' && data.error) {
                        pbPages_deferred.reject(data.error);
                        return false;
                    }

                    pbPages_deferred.resolve(data);
                }
            });
        }
        return pbPages_deferred.promise();
    }

    function clearData(type, s, onoff, count, p) {
        return $.ajax({
            url: '/template/clear',
            data: { type: type, sid: s, count: count, p: p + 1, onoff: onoff },
            type: 'POST',
            dataType: 'json',
            async: true,
            cashe: false,
            success: function(data) {
                console.log(data);
            }
        });
    }

    function user_location() {
        var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                var ip = this.responseText,
                    sid = (typeof property.SID) ? property.SID : '',
                    refer = (typeof property.VIREFER) ? property.VIREFER : '';
                if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ip) && sid) {
                    $.ajax({
                        type: 'POST',
                        url: '/template/visitor/' + sid,
                        data: { ip: ip, refer: refer },
                        dataType: 'json',
                        async: true,
                        cache: false,
                        success: function(r) {
                            // console.log(r);
                        }
                    });
                }
            }
        };
        xhttp.open('GET', '//api.ip.pe.kr', true);
        // xhttp.open('GET', '//api.ipify.org', true);
        xhttp.send();
    }

    function getProgressWidth() {
        var $p = $('.progress-bar');
        return $p.width() / $p.parent().width() * 100;
    }

    var checkError = function(data) {
        if (typeof data.error != "undefined" && data.error) {
            // alert(data.error);
            if (data.error == "No user data") {
                internalLink = true;
                // location.replace('/member/login');
                if (CONFIG_URL) location.replace('/_admin');
                setTimeout(function() {
                    if (typeof hideAllModal == 'function') hideAllModal();
                    var modal = $(this).showModalFlat('<img src="https://storage.googleapis.com/i.addblock.net/modal-logo-dark.png" alt="creaotrlink logo"/>', loginForm(), true, true, function() {}, 'cancel', 'w450');
                    $('.flat-modal .modal-footer').hide();
                    $('.modal-default[id*=flat-modal] .modal-dialog .modal-body').css('margin', '55px 45px 35px');
                    $('.modal-default[id*=flat-modal]').css('z-index', '1041');
                    $('.flat-modal').next('.modal-backdrop').css('z-index', '1040');
                }, 500);
            } else {
                $.processOFF();
                alert(data.error);
            }
            return false;
        } else {
            internalLink = false;
            return true;
        }
    }

    $(document)
        .off('keypress', 'input[expComma]')
        .on('keypress', 'input[expComma]', function(e) {
            var key = (e.which) ? e.which : e.keyCode;
            if (key == 44) return false;
    });

    $(document)
        .off('blur', 'input[numberOnly]')
        .on('blur', 'input[numberOnly]', function(e) {
            var val = $(this).val();
            var r = val.replace(/[^\d,]/g, '');

            if ($(this).hasClass('isFloat')) {
                r = val.replace(/[^\d.,]/g, '');
            } else if ($(this).attr('class').indexOf('price') > -1) {
                r = val.replace(/[^\d.,-]/g, '');
            }

            $(this).val(r);
        });

    $(document)
        .off('keypress', 'input[numberOnly]')
        .on('keypress', 'input[numberOnly]', function(e) {
            var key = (e.which) ? e.which : e.keyCode,
                sign = ($(this).hasClass('sign')) ? true : false,
                float = $(this).hasClass('isFloat') ? true : false;
            if (key > 47 && key < 58) {
                return true;
            } else if (sign && (key == 43 || key == 45)) {
                return true;
            } else if (float && key == 46 && $(this).val().indexOf('.') == -1) {
                return true;
            } else {
                return false;
            }
        });

    $(document)
        .off('keyup', 'input[numberOnly]')
        .on('keyup', 'input[numberOnly]', function(e) {
            var n = addCommas($(this).val().replace(/[^0-9.+-]/g, ""));
            $(this).val(n);
        });

    function addCommas(x) {
        if (x.length == 0) return '';
        x = String(x);
        var l = x.split(""),
            zero = true;
        $.each(l, function(i, v) {
            if (x.charAt(0) == '+' || x.charAt(0) == '-') {
                var sign = x.charAt(0);
                if (x.charAt(1) == "0") {
                    x = x.substr(2);
                    x = sign + x;
                } else if (x.charAt(1) == '+' || x.charAt(1) == '-') {
                    x = x.substr(1);
                }
            } else if (x.charAt(0) == "0" && x.length > 1 && x.indexOf('.') == -1) {
                x = x.substr(1);
            }
        });

        if (x.length > 0 && x.indexOf('.') > -1) return x;
        return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
    }

    function removeCommas(x) {
        if (!x || x.length == 0) return "";
        if (x == "0" || x == 0) return 0;
        else return x.split(",").join("");
    }


    function inputNumberFormat(obj) {
        obj.value = comma(uncomma(obj.value));
    }

    function comma(str) {
        str = String(str);
        return str.replace(/(\d)(?=(?:\d{3})+(?!\d))/g, '$1,');
    }

    function uncomma(str) {
        str = String(str);
        return str.replace(/[^\d]+/g, '');
    }


    function formTranslate(l) {
        if (l != 'ko') {
            $('select[form-type="select"] option:selected').text('Select');
        }
    }

    function changeFavicon(src) {
        document.head = document.head || document.getElementsByTagName('head')[0];
        var link = document.createElement('link'),
            oldLink = document.getElementById('dynamic-favicon');

        link.id = 'dynamic-favicon';
        link.type = 'image/x-icon';
        link.rel = 'icon';
        link.href = src;
        if (oldLink) {
            document.head.removeChild(oldLink);
        }
        document.head.appendChild(link);
    }

    function occurrences(string, subString, allowOverlapping) {
        string += "";
        subString += "";
        if (subString.length <= 0) return (string.length + 1);

        var n = 0,
            pos = 0,
            step = allowOverlapping ? 1 : subString.length;

        while (true) {
            pos = string.indexOf(subString, pos);
            if (pos >= 0) {
                ++n;
                pos += step;
            } else break;
        }
        return n;
    }

    function errorTag(tag) {
        var divStart = occurrences(tag, '<div', false),
            divEnd = occurrences(tag, '</div>', false);

        if (divStart != divEnd) return true;
        return false;
    }


    function errorWorkingEmojisModal(closecallback, showcallback, hidecallback) {
        if ($('.cl-cmmodal.error-emoji').length > 0) return false;

        if (typeof showcallback == 'undefined' || showcallback == '') {
            showcallback = function() {
                $('.modal-dialog.error-emoji').closest('.flat-modal').next('.modal-backdrop').attr('style', 'display: block; z-index: 1042!important;');
                $('.modal-dialog.error-emoji').closest('.modal').attr('style', 'display: block; z-index: 1043');
            }
        }

        $(this).showModalFlat($.lang[LANG]['config.information'], $.lang[LANG]['config.working.emoji'], true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-okbtn-pbt70 error-emoji', '', closecallback, showcallback, hidecallback);
    }

    function errorEmojisModal(modal_zindex, closecallback, showcallback, hidecallback) {
        if ($('.cl-cmmodal.error-emoji').length > 0) return false;
        var modal_size = (typeof modal_zindex != 'undefined' && modal_zindex) ? 'zindex'+modal_zindex : 'zindex1043';
        $(this).showModalFlat($.lang[LANG]['config.information'], $.lang[LANG]['config.unable.emoji'], true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-okbtn-pbt70 error-emoji '+modal_size, '', closecallback, showcallback, hidecallback);
    }

    function checkEmojis(str) {
        var regex = /(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff]|&zwj;)/g;
        return regex.test(str);
    }

    function removeEmojis(str) {
        var regex = /(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff]|&zwj;)/g;
        return str.replace(regex, '');
    }



    function changeEmoji(str, op, usedDeferred) {
        if (typeof op == 'undefined' || (op != 'encode' && op != 'decode')) return str;
        if (typeof usedDeferred != 'boolean') usedDeferred = false;

        if (usedDeferred) {
            var deferred = $.Deferred();
            $.post('/template/emoji', { str: str, op: op }, function(data) {
                deferred.resolve(data.str);
            }, 'json');
            return deferred.promise();
        } else {
            $.post('/template/emoji', { str: str, op: op }, function(data) {
                return data.str;
            }, 'json');
        }
    }


    function strReplace(str, searchStr, replaceStr) {
        return str.split(searchStr).join(replaceStr);
    }

    function checkBase64Encode(str) {
        var regExp = /^(?:[A-Z0-9+\/]{4})*(?:[A-Z0-9+\/]{2}==|[A-Z0-9+\/]{3}=|[A-Z0-9+\/]{4})$/i;
        return (str.length % 4 == 0) && regExp.test(str);
    }

    function number_format(val) {
        return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
    }
//
    function checkTemplateSite(sid) {
        var checkTemp = (PAGE_MODE == 'c') ? CHECKTEMP : property.CHECKTEMP;
        if(typeof checkTemp == 'undefined') return false;
        if (!sid || !checkTemp) return false;
        var templates_lang = ['ko', 'en'],
            // 라이브 백업 코드 
            // templates_org = ["pardinus","otocyon","fulica","phocoena","tremarctos","mysticetus","nigripes","pteromys","guanicoe","civettina","viverra","simensis", "euryzona", "leopardus", "gryphus", "rubicola", "wintoni", "iliensis", "javan", "acinonyx", "ochotona", "tayra", "fennec", "beluga", "itatsi", "pennantii", "luscinius", "kidogo", "rourei", "graysoni", "pagensis", "lilliae", "inscinius", "diazi", "gerpi", "lutreola", "walie", "gambieri", "saola", "waldeni", "indri", "jefferyi"],        
            templates_org = [
                "aves","habroptila","vultur","pardinus","otocyon","fulica","phocoena","tremarctos","mysticetus","nigripes","pteromys","guanicoe","civettina","viverra","simensis", "euryzona", "leopardus", "gryphus", "rubicola", "wintoni", "iliensis", "javan", "acinonyx", "ochotona", "tayra", "fennec", "beluga", "itatsi", "pennantii", "luscinius", "kidogo", "rourei", "graysoni", "pagensis", "lilliae", "inscinius", "diazi", "gerpi", "lutreola", "walie", "gambieri", "saola", "waldeni", "indri", "jefferyi", "theropithecus", "pelzelni",
                "template001", "template002", "template003", "template004", "template005", "template006", "template007", "template008", "template009",
                "plutolabs","smc","cloudia","eunoia","saladly",
                "academy02","academy03","academy04","academy05",
                "company02","company03","company04","company05","company06","company07",
                "beauty01","beauty02","beauty03","beauty04","beauty05","beauty06",
                "culture01","culture02","culture03","culture05","culture06","culture07","culture08",
                "sports03","sports04",
                "cafe04","cafe05",
                "house02","house05",
                "portfolio16","portfolio06","portfolio22","portfolio23",
                "product02"
            ],
            // templates_org = ["aves","habroptila","vultur","pardinus","otocyon","fulica","phocoena","tremarctos","mysticetus","nigripes","pteromys","guanicoe","civettina","viverra","simensis", "euryzona", "leopardus", "gryphus", "rubicola", "wintoni", "iliensis", "javan", "acinonyx", "ochotona", "tayra", "fennec", "beluga", "itatsi", "pennantii", "luscinius", "kidogo", "rourei", "graysoni", "pagensis", "lilliae", "inscinius", "diazi", "gerpi", "lutreola", "walie", "gambieri", "saola", "waldeni", "indri", "jefferyi", "theropithecus", "pelzelni",
            //                  "template001", "template002", "template003", "template004", "template005", "template006", "template007", "template008", "template009",
            //                  "plutolabs","smc","cloudia","eunoia","saladly",
            //                  "academy02","academy03","company02","company03","company04","company05","company06","company07",
            //                  "beauty01","beauty02","beauty03","beauty04","beauty05","beauty06","sports03","sports04","cafe04","cafe05","academy04","academy05",
            //                  "culture01","culture02","culture03","culture05","culture06","culture07","culture08","product02","house02","house05","portfolio06","portfolio16"],
            templates = [],
            templates_admin = [];


        $.each(templates_org, function(i, v) {
            $.each(templates_lang, function(a, b) {
                templates_admin.push(v + '_' + b);
            });
        });

        templates = templates_admin.concat(templates_org);

        var is_templates = ($.inArray(sid.toLowerCase(), templates) > -1) ? true : false;

        return is_templates;
    }

    jQuery.fn.serializeObject = function() {
        var obj = null;
        try {
            if (this[0].tagName && this[0].tagName.toUpperCase() == "FORM") {
                var arr = this.serializeArray();
                if (arr) {
                    obj = {};
                    jQuery.each(arr, function() {
                        obj[this.name] = this.value;
                    });
                } //if ( arr ) {
            }
        } catch (e) {
            alert(e.message);
        } finally {}
        return obj;
    }

    function errorCss(css) {
        css = css.replace(/::/g, '');
        var cssStart = occurrences(css, '{', false),
            cssEnd = occurrences(css, '}', false),
            pStart = occurrences(css, ':', false),
            pEnd = occurrences(css, ';', false),
            min = occurrences(css, '(min-width', false),
            min2 = occurrences(css, '( min-width', false),
            max = occurrences(css, '(max-width', false),
            max2 = occurrences(css, '( max-width', false),
            hover = occurrences(css, ':hover', false),
            active = occurrences(css, ':active', false),
            focus = occurrences(css, ':focus', false),
            before = occurrences(css, ':before', false),
            after = occurrences(css, ':after', false),
            empty = occurrences(css, ':empty', false),
            not = occurrences(css, ':not', false),
            css_is = occurrences(css, ':is', false),
            checked = occurrences(css, ':checked', false),
            first = occurrences(css, ':first-child', false),
            last = occurrences(css, ':last-child', false),
            first_letter = occurrences(css, ':first-letter', false),
            first_line = occurrences(css, ':first-line', false),
            first_of_type = occurrences(css, ':first-of-type', false),
            nth = occurrences(css, ':nth', false),
            nth_even = occurrences(css, ':nth-child(even)', true),
            nth_odd = occurrences(css, ':nth-child(odd)', true),
            holder1 = occurrences(css, ':-webkit-input-placeholder', false),
            holder2 = occurrences(css, ':-moz-placeholder', false),
            holder3 = occurrences(css, ':-ms-input-placeholder', false),
            media_controls = occurrences(css, ':-webkit-media-controls', false),
            select_icon = occurrences(css, ':-ms-expand', false),
            scrollbar1 = occurrences(css, ':-webkit-scrollbar', false),
            scrollbar2 = occurrences(css, ':-webkit-scrollbar-track', false),
            scrollbar3 = occurrences(css, ':-webkit-scrollbar-thumbr', false),
            https = occurrences(css, 'https:', false),
            http = occurrences(css, 'http:', false);

        if (rt_admin == "admin") {
            console.log('{', cssStart);
            console.log('}', cssEnd);
            console.log(':', pStart);
            console.log(';', pEnd);
            console.log('media css', (min + min2 + max + max2));
            console.log('hover', hover);
            console.log('active', active);
            console.log('focus', focus);
            console.log('before', before);
            console.log('after', after);
            console.log('empty', empty);
            console.log('not', not);
            console.log('css_is', css_is);
            console.log('checked', checked);
            console.log('first-child', first);
            console.log('last-child', last);
            console.log('first-letter', first_letter);
            console.log('first-line', first_line);
            console.log('first-of-type', first_of_type);
            console.log('nth', nth);
            console.log('nth-even', nth_even);
            console.log('nth-odd', nth_odd);
            console.log('holder', (holder1 + holder2 + holder3));
            console.log('video-controls(::-webkit-media-controls)', media_controls);
            console.log('select-icon(::-ms-expand)', select_icon);
            console.log('scrollbar', scrollbar1);
            console.log('scrollbar-track', scrollbar2);
            console.log('scrollbar-thumb', scrollbar3);
            console.log('https:', https);
            console.log('http:', http);
        }
        if (cssStart != cssEnd) return true;
        if (pStart != (pEnd + min + min2 + max + max2 + hover + active + focus + before + after + empty + not + css_is + checked + first + last + first_letter + first_line + first_of_type + nth + holder1 + holder2 + holder3 + media_controls + select_icon + scrollbar1 + scrollbar2 + scrollbar3 + https + http)) return true;
        return false;
    }

    if (typeof(MD5_JS) == 'undefined') {
        var MD5_JS = true;
        var hexcase = 0;
        var b64pad = "";
        var chrsz = 8;

        function hex_md5(s) { return binl2hex(core_md5(str2binl(s), s.length * chrsz)); }

        function b64_md5(s) { return binl2b64(core_md5(str2binl(s), s.length * chrsz)); }

        function str_md5(s) { return binl2str(core_md5(str2binl(s), s.length * chrsz)); }

        function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }

        function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }

        function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }

        function core_md5(x, len) {
            x[len >> 5] |= 0x80 << ((len) % 32);
            x[(((len + 64) >>> 9) << 4) + 14] = len;
            var a = 1732584193;
            var b = -271733879;
            var c = -1732584194;
            var d = 271733878;
            for (var i = 0; i < x.length; i += 16) {
                var olda = a;
                var oldb = b;
                var oldc = c;
                var oldd = d;
                a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
                d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
                c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
                b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
                a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
                d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
                c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
                b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
                a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
                d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
                c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
                b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
                a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
                d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
                c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
                b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
                a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
                d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
                c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
                b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
                a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
                d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
                c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
                b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
                a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
                d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
                c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
                b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
                a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
                d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
                c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
                b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
                a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
                d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
                c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
                b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
                a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
                d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
                c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
                b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
                a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
                d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
                c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
                b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
                a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
                d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
                c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
                b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
                a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
                d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
                c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
                b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
                a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
                d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
                c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
                b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
                a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
                d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
                c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
                b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
                a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
                d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
                c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
                b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
                a = safe_add(a, olda);
                b = safe_add(b, oldb);
                c = safe_add(c, oldc);
                d = safe_add(d, oldd);
            }
            return Array(a, b, c, d);
        }

        function md5_cmn(q, a, b, x, s, t) { return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b); }

        function md5_ff(a, b, c, d, x, s, t) { return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); }

        function md5_gg(a, b, c, d, x, s, t) { return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); }

        function md5_hh(a, b, c, d, x, s, t) { return md5_cmn(b ^ c ^ d, a, b, x, s, t); }

        function md5_ii(a, b, c, d, x, s, t) { return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); }

        function SHA256(s) {
            var chrsz   = 8;
            var hexcase = 0;

            function safe_add (x, y) {
                var lsw = (x & 0xFFFF) + (y & 0xFFFF);
                var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
                return (msw << 16) | (lsw & 0xFFFF);
            }

            function S (X, n) { return ( X >>> n ) | (X << (32 - n)); }
            function R (X, n) { return ( X >>> n ); }
            function Ch(x, y, z) { return ((x & y) ^ ((~x) & z)); }
            function Maj(x, y, z) { return ((x & y) ^ (x & z) ^ (y & z)); }
            function Sigma0256(x) { return (S(x, 2) ^ S(x, 13) ^ S(x, 22)); }
            function Sigma1256(x) { return (S(x, 6) ^ S(x, 11) ^ S(x, 25)); }
            function Gamma0256(x) { return (S(x, 7) ^ S(x, 18) ^ R(x, 3)); }
            function Gamma1256(x) { return (S(x, 17) ^ S(x, 19) ^ R(x, 10)); }
            function core_sha256(m, l) {
                var K = new Array(0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 
                    0x923F82A4, 0xAB1C5ED5, 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 
                    0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, 0xE49B69C1, 0xEFBE4786, 
                    0xFC19DC6, 0x240CA1CC, 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, 
                    0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 0xC6E00BF3, 0xD5A79147, 
                    0x6CA6351, 0x14292967, 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, 
                    0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, 0xA2BFE8A1, 0xA81A664B, 
                    0xC24B8B70, 0xC76C51A3, 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, 
                    0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 0x391C0CB3, 0x4ED8AA4A, 
                    0x5B9CCA4F, 0x682E6FF3, 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 
                    0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2);
    
                var HASH = new Array(0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19);
    
                var W = new Array(64);
                var a, b, c, d, e, f, g, h, i, j;
                var T1, T2;
         
                m[l >> 5] |= 0x80 << (24 - l % 32);
                m[((l + 64 >> 9) << 4) + 15] = l;
         
                for ( var i = 0; i<m.length; i+=16 ) {
                    a = HASH[0];
                    b = HASH[1];
                    c = HASH[2];
                    d = HASH[3];
                    e = HASH[4];
                    f = HASH[5];
                    g = HASH[6];
                    h = HASH[7];
         
                    for ( var j = 0; j<64; j++) {
                        if (j < 16) W[j] = m[j + i];
                        else W[j] = safe_add(safe_add(safe_add(Gamma1256(W[j - 2]), W[j - 7]), Gamma0256(W[j - 15])), W[j - 16]);
         
                        T1 = safe_add(safe_add(safe_add(safe_add(h, Sigma1256(e)), Ch(e, f, g)), K[j]), W[j]);
                        T2 = safe_add(Sigma0256(a), Maj(a, b, c));
         
                        h = g;
                        g = f;
                        f = e;
                        e = safe_add(d, T1);
                        d = c;
                        c = b;
                        b = a;
                        a = safe_add(T1, T2);
                    }
         
                    HASH[0] = safe_add(a, HASH[0]);
                    HASH[1] = safe_add(b, HASH[1]);
                    HASH[2] = safe_add(c, HASH[2]);
                    HASH[3] = safe_add(d, HASH[3]);
                    HASH[4] = safe_add(e, HASH[4]);
                    HASH[5] = safe_add(f, HASH[5]);
                    HASH[6] = safe_add(g, HASH[6]);
                    HASH[7] = safe_add(h, HASH[7]);
                }
                return HASH;
            }
            function str2binb (str) {
                var bin = Array();
                var mask = (1 << chrsz) - 1;
                for(var i = 0; i < str.length * chrsz; i += chrsz) {
                    bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (24 - i%32);
                }
                return bin;
            }
         
            function Utf8Encode(string) {
                string = string.replace(/\r\n/g,"\n");
                var utftext = "";
         
                for (var n = 0; n < string.length; n++) {
         
                    var c = string.charCodeAt(n);
         
                    if (c < 128) {
                        utftext += String.fromCharCode(c);
                    }
                    else if((c > 127) && (c < 2048)) {
                        utftext += String.fromCharCode((c >> 6) | 192);
                        utftext += String.fromCharCode((c & 63) | 128);
                    }
                    else {
                        utftext += String.fromCharCode((c >> 12) | 224);
                        utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                        utftext += String.fromCharCode((c & 63) | 128);
                    }
         
                }
         
                return utftext;
            }
         
            function binb2hex (binarray) {
                var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
                var str = "";
                for(var i = 0; i < binarray.length * 4; i++) {
                    str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
                    hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8  )) & 0xF);
                }
                return str;
            }
            
            s = Utf8Encode(s);
            return binb2hex(core_sha256(str2binb(s), s.length * chrsz));
        }

        function core_hmac_md5(key, data) {
            var bkey = str2binl(key);
            if (bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
            var ipad = Array(16),
                opad = Array(16);
            for (var i = 0; i < 16; i++) {
                ipad[i] = bkey[i] ^ 0x36363636;
                opad[i] = bkey[i] ^ 0x5C5C5C5C;
            }
            var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
            return core_md5(opad.concat(hash), 512 + 128);
        }

        function safe_add(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); }

        function bit_rol(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); }

        function str2binl(str) { var bin = Array(); var mask = (1 << chrsz) - 1; for (var i = 0; i < str.length * chrsz; i += chrsz) bin[i >> 5] |= (str.charCodeAt(i / chrsz) & mask) << (i % 32); return bin; }

        function binl2str(bin) { var str = ""; var mask = (1 << chrsz) - 1; for (var i = 0; i < bin.length * 32; i += chrsz) str += String.fromCharCode((bin[i >> 5] >>> (i % 32)) & mask); return str; }

        function binl2hex(binarray) { var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; var str = ""; for (var i = 0; i < binarray.length * 4; i++) str += hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8 + 4)) & 0xF) + hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8)) & 0xF); return str; }

        function binl2b64(binarray) {
            var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
            var str = "";
            for (var i = 0; i < binarray.length * 4; i += 3) {
                var triplet = (((binarray[i >> 2] >> 8 * (i % 4)) & 0xFF) << 16) | (((binarray[i + 1 >> 2] >> 8 * ((i + 1) % 4)) & 0xFF) << 8) | ((binarray[i + 2 >> 2] >> 8 * ((i + 2) % 4)) & 0xFF);
                for (var j = 0; j < 4; j++) {
                    if (i * 8 + j * 6 > binarray.length * 32) str += b64pad;
                    else
                        str += tab.charAt((triplet >> 6 * (3 - j)) & 0x3F);
                }
            }
            return str;
        }
    }
    var Base64 = {
        _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
        encode: function(input) {
            var output = "";
            var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
            var i = 0;
            input = Base64._utf8_encode(input);
            while (i < input.length) {
                chr1 = input.charCodeAt(i++);
                chr2 = input.charCodeAt(i++);
                chr3 = input.charCodeAt(i++);
                enc1 = chr1 >> 2;
                enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
                enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
                enc4 = chr3 & 63;
                if (isNaN(chr2)) { enc3 = enc4 = 64 } else if (isNaN(chr3)) { enc4 = 64 }
                output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4)
            }
            return output
        },
        decode: function(input) {
            var output = "";
            var chr1, chr2, chr3;
            var enc1, enc2, enc3, enc4;
            var i = 0;
            input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
            while (i < input.length) {
                enc1 = this._keyStr.indexOf(input.charAt(i++));
                enc2 = this._keyStr.indexOf(input.charAt(i++));
                enc3 = this._keyStr.indexOf(input.charAt(i++));
                enc4 = this._keyStr.indexOf(input.charAt(i++));
                chr1 = (enc1 << 2) | (enc2 >> 4);
                chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
                chr3 = ((enc3 & 3) << 6) | enc4;
                output = output + String.fromCharCode(chr1);
                if (enc3 != 64) { output = output + String.fromCharCode(chr2) }
                if (enc4 != 64) { output = output + String.fromCharCode(chr3) }
            }
            output = Base64._utf8_decode(output);
            return output
        },
        _utf8_encode: function(string) {
            string = string.replace(/\r\n/g, "\n");
            var utftext = "";
            for (var n = 0; n < string.length; n++) {
                var c = string.charCodeAt(n);
                if (c < 128) { utftext += String.fromCharCode(c) } else if ((c > 127) && (c < 2048)) {
                    utftext += String.fromCharCode((c >> 6) | 192);
                    utftext += String.fromCharCode((c & 63) | 128)
                } else {
                    utftext += String.fromCharCode((c >> 12) | 224);
                    utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                    utftext += String.fromCharCode((c & 63) | 128)
                }
            }
            return utftext
        },
        _utf8_decode: function(utftext) {
            var string = "";
            var i = 0;
            var c = c1 = c2 = 0;
            while (i < utftext.length) {
                c = utftext.charCodeAt(i);
                if (c < 128) {
                    string += String.fromCharCode(c);
                    i++
                } else if ((c > 191) && (c < 224)) {
                    c2 = utftext.charCodeAt(i + 1);
                    string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                    i += 2
                } else {
                    c2 = utftext.charCodeAt(i + 1);
                    c3 = utftext.charCodeAt(i + 2);
                    string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                    i += 3
                }
            }
            return string
        }
    }


    /* new code 20240402 */
    var clmd5 = {
        hexcase: 0,
        b64pad: '',
        hex_md5: function(s) { return clmd5.rstr2hex(clmd5.rstr_md5(clmd5.str2rstr_utf8(s))); },
        b64_md5: function(s) { return clmd5.rstr2b64(clmd5.rstr_md5(clmd5.str2rstr_utf8(s))); },
        any_md5: function(s, e) { return clmd5.rstr2any(clmd5.rstr_md5(clmd5.str2rstr_utf8(s)), e); },
        hex_hmac_md5: function(k, d) { return clmd5.rstr2hex(clmd5.rstr_hmac_md5(clmd5.str2rstr_utf8(k), clmd5.str2rstr_utf8(d))); },
        b64_hmac_md5: function(k, d) { return clmd5.rstr2b64(clmd5.rstr_hmac_md5(clmd5.str2rstr_utf8(k), clmd5.str2rstr_utf8(d))); },
        any_hmac_md5: function(k, d, e) { return clmd5.rstr2any(clmd5.rstr_hmac_md5(clmd5.str2rstr_utf8(k), clmd5.str2rstr_utf8(d)), e); },
        rstr_md5: function(s) { return clmd5.binl2rstr(clmd5.binl_md5(clmd5.rstr2binl(s), s.length * 8)); },
        rstr_hmac_md5: function(key, data) {
            var bkey = clmd5.rstr2binl(key);
            if(bkey.length > 16) bkey = clmd5.binl_md5(bkey, key.length * 8);

            var ipad = Array(16), opad = Array(16);
            for(var i = 0; i < 16; i++)
            {
                ipad[i] = bkey[i] ^ 0x36363636;
                opad[i] = bkey[i] ^ 0x5C5C5C5C;
            }

            var hash = clmd5.binl_md5(ipad.concat(clmd5.rstr2binl(data)), 512 + data.length * 8);
            return clmd5.binl2rstr(clmd5.binl_md5(opad.concat(hash), 512 + 128));
        },
        rstr2hex: function(input) {
            try { clmd5.hexcase } catch(e) { clmd5.hexcase=0; }
            var hex_tab = clmd5.hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
            var output = "";
            var x;
            for(var i = 0; i < input.length; i++)
            {
              x = input.charCodeAt(i);
              output += hex_tab.charAt((x >>> 4) & 0x0F)
                     +  hex_tab.charAt( x        & 0x0F);
            }
            return output;
        },
        rstr2b64: function(input) {
            try { clmd5.b64pad } catch(e) { clmd5.b64pad=''; }
            var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
            var output = "";
            var len = input.length;
            for(var i = 0; i < len; i += 3)
            {
              var triplet = (input.charCodeAt(i) << 16)
                          | (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0)
                          | (i + 2 < len ? input.charCodeAt(i+2)      : 0);
              for(var j = 0; j < 4; j++)
              {
                if(i * 8 + j * 6 > input.length * 8) output += clmd5.b64pad;
                else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F);
              }
            }
            return output;
        },
        rstr2any: function(input, encoding) {
            var divisor = encoding.length;
            var i, j, q, x, quotient;
          
            /* Convert to an array of 16-bit big-endian values, forming the dividend */
            var dividend = Array(Math.ceil(input.length / 2));
            for(i = 0; i < dividend.length; i++)
            {
              dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
            }
          
            /*
             * Repeatedly perform a long division. The binary array forms the dividend,
             * the length of the encoding is the divisor. Once computed, the quotient
             * forms the dividend for the next step. All remainders are stored for later
             * use.
             */
            var full_length = Math.ceil(input.length * 8 /
                                              (Math.log(encoding.length) / Math.log(2)));
            var remainders = Array(full_length);
            for(j = 0; j < full_length; j++)
            {
              quotient = Array();
              x = 0;
              for(i = 0; i < dividend.length; i++)
              {
                x = (x << 16) + dividend[i];
                q = Math.floor(x / divisor);
                x -= q * divisor;
                if(quotient.length > 0 || q > 0)
                  quotient[quotient.length] = q;
              }
              remainders[j] = x;
              dividend = quotient;
            }
          
            /* Convert the remainders to the output string */
            var output = "";
            for(i = remainders.length - 1; i >= 0; i--)
              output += encoding.charAt(remainders[i]);
          
            return output;
        },
        str2rstr_utf8: function(input) {
            var output = "";
            var i = -1;
            var x, y;
          
            while(++i < input.length)
            {
              /* Decode utf-16 surrogate pairs */
              x = input.charCodeAt(i);
              y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
              if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF)
              {
                x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
                i++;
              }
          
              /* Encode output as utf-8 */
              if(x <= 0x7F)
                output += String.fromCharCode(x);
              else if(x <= 0x7FF)
                output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F),
                                              0x80 | ( x         & 0x3F));
              else if(x <= 0xFFFF)
                output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F),
                                              0x80 | ((x >>> 6 ) & 0x3F),
                                              0x80 | ( x         & 0x3F));
              else if(x <= 0x1FFFFF)
                output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07),
                                              0x80 | ((x >>> 12) & 0x3F),
                                              0x80 | ((x >>> 6 ) & 0x3F),
                                              0x80 | ( x         & 0x3F));
            }
            return output;
        },
        // str2rstr_utf16le: function(input) {
        //     var output = "";
        //     for(var i = 0; i < input.length; i++)
        //       output += String.fromCharCode( input.charCodeAt(i)        & 0xFF,
        //                                     (input.charCodeAt(i) >>> 8) & 0xFF);
        //     return output;
        // },
        // str2rstr_utf16be: function(input) {
        //     var output = "";
        //     for(var i = 0; i < input.length; i++)
        //       output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF,
        //                                      input.charCodeAt(i)        & 0xFF);
        //     return output;
        // },
        rstr2binl: function(input) {
            var output = Array(input.length >> 2);
            for(var i = 0; i < output.length; i++)
              output[i] = 0;
            for(var i = 0; i < input.length * 8; i += 8)
              output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (i%32);
            return output;
        },
        binl2rstr: function(input) {
            var output = "";
            for(var i = 0; i < input.length * 32; i += 8)
              output += String.fromCharCode((input[i>>5] >>> (i % 32)) & 0xFF);
            return output;
        },
        binl_md5: function(x, len) {
            /* append padding */
            x[len >> 5] |= 0x80 << ((len) % 32);
            x[(((len + 64) >>> 9) << 4) + 14] = len;
          
            var a =  1732584193;
            var b = -271733879;
            var c = -1732584194;
            var d =  271733878;
          
            for(var i = 0; i < x.length; i += 16)
            {
              var olda = a;
              var oldb = b;
              var oldc = c;
              var oldd = d;
          
              a = clmd5.md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
              d = clmd5.md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
              c = clmd5.md5_ff(c, d, a, b, x[i+ 2], 17,  606105819);
              b = clmd5.md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
              a = clmd5.md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
              d = clmd5.md5_ff(d, a, b, c, x[i+ 5], 12,  1200080426);
              c = clmd5.md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
              b = clmd5.md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
              a = clmd5.md5_ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
              d = clmd5.md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
              c = clmd5.md5_ff(c, d, a, b, x[i+10], 17, -42063);
              b = clmd5.md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
              a = clmd5.md5_ff(a, b, c, d, x[i+12], 7 ,  1804603682);
              d = clmd5.md5_ff(d, a, b, c, x[i+13], 12, -40341101);
              c = clmd5.md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
              b = clmd5.md5_ff(b, c, d, a, x[i+15], 22,  1236535329);
          
              a = clmd5.md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
              d = clmd5.md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
              c = clmd5.md5_gg(c, d, a, b, x[i+11], 14,  643717713);
              b = clmd5.md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
              a = clmd5.md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
              d = clmd5.md5_gg(d, a, b, c, x[i+10], 9 ,  38016083);
              c = clmd5.md5_gg(c, d, a, b, x[i+15], 14, -660478335);
              b = clmd5.md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
              a = clmd5.md5_gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
              d = clmd5.md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
              c = clmd5.md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
              b = clmd5.md5_gg(b, c, d, a, x[i+ 8], 20,  1163531501);
              a = clmd5.md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
              d = clmd5.md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
              c = clmd5.md5_gg(c, d, a, b, x[i+ 7], 14,  1735328473);
              b = clmd5.md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
          
              a = clmd5.md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
              d = clmd5.md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
              c = clmd5.md5_hh(c, d, a, b, x[i+11], 16,  1839030562);
              b = clmd5.md5_hh(b, c, d, a, x[i+14], 23, -35309556);
              a = clmd5.md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
              d = clmd5.md5_hh(d, a, b, c, x[i+ 4], 11,  1272893353);
              c = clmd5.md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
              b = clmd5.md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
              a = clmd5.md5_hh(a, b, c, d, x[i+13], 4 ,  681279174);
              d = clmd5.md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
              c = clmd5.md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
              b = clmd5.md5_hh(b, c, d, a, x[i+ 6], 23,  76029189);
              a = clmd5.md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
              d = clmd5.md5_hh(d, a, b, c, x[i+12], 11, -421815835);
              c = clmd5.md5_hh(c, d, a, b, x[i+15], 16,  530742520);
              b = clmd5.md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
          
              a = clmd5.md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
              d = clmd5.md5_ii(d, a, b, c, x[i+ 7], 10,  1126891415);
              c = clmd5.md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
              b = clmd5.md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
              a = clmd5.md5_ii(a, b, c, d, x[i+12], 6 ,  1700485571);
              d = clmd5.md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
              c = clmd5.md5_ii(c, d, a, b, x[i+10], 15, -1051523);
              b = clmd5.md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
              a = clmd5.md5_ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
              d = clmd5.md5_ii(d, a, b, c, x[i+15], 10, -30611744);
              c = clmd5.md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
              b = clmd5.md5_ii(b, c, d, a, x[i+13], 21,  1309151649);
              a = clmd5.md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
              d = clmd5.md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
              c = clmd5.md5_ii(c, d, a, b, x[i+ 2], 15,  718787259);
              b = clmd5.md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
          
              a = clmd5.safe_add(a, olda);
              b = clmd5.safe_add(b, oldb);
              c = clmd5.safe_add(c, oldc);
              d = clmd5.safe_add(d, oldd);
            }
            return Array(a, b, c, d);
        },
        md5_cmn: function(q, a, b, x, s, t) { return clmd5.safe_add(clmd5.bit_rol(clmd5.safe_add(clmd5.safe_add(a, q), clmd5.safe_add(x, t)), s),b); },
        md5_ff: function(a, b, c, d, x, s, t) { return clmd5.md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); },
        md5_gg: function(a, b, c, d, x, s, t) { return clmd5.md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); },
        md5_hh: function(a, b, c, d, x, s, t) { return clmd5.md5_cmn(b ^ c ^ d, a, b, x, s, t); },
        md5_ii: function(a, b, c, d, x, s, t) { return clmd5.md5_cmn(c ^ (b | (~d)), a, b, x, s, t); },
        safe_add: function(x, y) {
            var lsw = (x & 0xFFFF) + (y & 0xFFFF);
            var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
            return (msw << 16) | (lsw & 0xFFFF);
        },
        bit_rol: function(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); }
    }

    $('.newcheckbox').live('click', function() {
        var checkCollection = $(this).parents('.collection-item').length;
        if (checkCollection < 1) {
            if ($(this).hasClass('disabled')) {
                return false;
            }
        }
    });


    var setPanelTranslate = function(obj) {
        $.each(obj.find('[data-title]'), function(i, v) {
            var el_title = $(this).attr('data-title'),
                lang_check = /[ㄱ-ㅎㅏ-ㅣ가-힣]/,
                el_title_lang = (lang_check.test(el_title)) ? 'ko' : 'en',
                arr = $.lang[el_title_lang];
            if ($(this).parent().hasClass('gallery-item')) return true;
            key = getKeyByValue(arr, el_title);

            if (key && el_title_lang != LANG) $(this).attr('data-title', $.lang[LANG][key]);
            if (typeof $.lang['en'][key] != 'undefined') $(this).attr('data-subtitle', $.lang['en'][key].toLowerCase().replace(/\s/g, '-'));
        });
    }

    var cutStrInBytes = function(str, limit) {
        var size = 0;
        for (var i = 0; i < str.length; i++) {
            size += (str.charCodeAt(i) > 128) ? 2 : 1;
            if (size > limit) return str.substring(0, i) + '...';
        }
        return str;
    }

    var refreshGalleryField = function(elObj, elsettings) {
        if (typeof elsettings == 'undefined' ||
            $.isEmptyObject(elsettings) ||
            typeof elsettings.field_disable == 'undefined' ||
            $.isEmptyObject(elsettings.field_disable)
        ) {
            return false;
        }

        var gVALIDTYPE = (PAGE_MODE == 'c') ? VALIDTYPE : property.VALIDTYPE;

        var el_mode = elObj.attr('data-mode'),
            el_seq = elObj.attr('data-id'),
            checkGalleryField = (elObj.find('h5.figure').eq(0).hasClass('title')) ? true : false;
        if (!checkGalleryField) return false;

        var gfield_all = ['brand','title','caption','price','review_cnt','review_score','comment','number','basket','like','basket'],
            gfield_oldver = (typeof elsettings.field_oldver != 'undefined' && !$.isEmptyObject(elsettings.field_oldver)) ? elsettings.field_oldver : [],
            gfield_disable = (typeof elsettings.field_disable != 'undefined' && !$.isEmptyObject(elsettings.field_disable)) ? elsettings.field_disable : [],
            gfield_listSet = (typeof el_mode != 'undefined') ? ['title', 'caption'] : [];
        if (typeof el_mode != 'undefined' && el_mode == 'shopping') {
            gfield_listSet = ['title', 'caption', 'price', 'review_cnt', 'review_score', 'basket'];
            if (typeof LUX != 'undefined' ? LUX : property.LUX) gfield_listSet.push('brand');
            if (gfield_disable.indexOf('basket') < 0 && gfield_oldver.indexOf('basket') < 0 && elObj.find('.figure.basket:not([data-oldver])').length == 0) gfield_disable.push('basket');
            if (gVALIDTYPE != 'SM' && gfield_disable.indexOf('basket') < 0)  gfield_disable.push('basket');
            if (typeof el_seq != 'undefined' && el_seq == 'all_products') gfield_disable = [];
        } else if (typeof el_mode != 'undefined' && el_mode == 'project') {
            gfield_listSet = ['title', 'caption', 'comment'];
        }

        if (elObj.find('.figure.number').length > 0) gfield_listSet.push('number');
        if (elObj.find('.figure.like').length > 0) elObj.find('.figure.like').addClass('hide');

        $.each(gfield_all, function(g_i, g_v) {
            var onoff = ($.inArray(g_v, gfield_disable) > -1) ? false : true;
            if (onoff && $.inArray(g_v, gfield_listSet) == -1) onoff = false;

            var checkReviewField = (g_v.match(/^review_/gi) !== null) ? true : false;
            if (checkReviewField) {
                elObj.find('.figure.review').attr('data-' + g_v, onoff);
            } else {
                if (onoff) {
                    elObj.find('.figure.' + g_v).each(function(i, v) {
                        if (  (g_v == 'comment' && Number($(v).find('figure-comment-cnt').text()) == 0) ||
                              (g_v == 'basket' && $(this).hasClass('cannotby'))
                        ) {
                            return true;
                        }
                        $(this).removeAttr('style');
                        $(this).removeClass('hide');
                    });
                } else {
                    elObj.find('.figure.' + g_v).each(function() { 
                        $(this).addClass('hide'); 
                    });
                }
            }
        });

        elObj.find('.grid figcaption').each(function() {
            if($(this).find('.figure:not(.hide, .review[data-review_cnt="false"][data-review_score="false"])').length > 0 && $(this).height() > 0) {
                $(this).removeClass('allhide');
            } else {
                $(this).addClass('allhide');
            }
        });
    }

    var refreshGalleryHeight = function(el) {
        if (el == 'el-menu' || el == 'el-footer') return false;
        var g_block = (typeof el != 'undefined' && el) ? '.' + el : '',
            g_block_selector = (typeof el != 'undefined' && el == 'el_display') ? '#element-display' : '.element[data-type="gallery"]' + g_block;

        $(g_block_selector).each(function() {
            if ($(this).find('.empty-txt').length > 0 || $(this).find('.grid').length == 0) return;

            var gsort = $(this).find('.goption').attr('data-gsort'),
                gh = $(this).find('.goption').attr('data-gh');
            if (typeof gh == 'undefined' || gh == 'auto') { return; }
            if (typeof gsort != 'undefined' && gsort == 'm') {
                $(this).find('.grid .g-img').removeClass('style');
                return;
            }

            var gel = $(this).find('.grid').eq(0),
                // gw = parseFloat(gel.css('width').replace(/[^0-9]/g,'')),
                gw = parseFloat(gel[0].getBoundingClientRect().width),
                gpl = parseFloat(gel.css('padding-left').replace(/[^0-9]/g, '')),
                gpr = parseFloat(gel.css('padding-right').replace(/[^0-9]/g, '')),
                g_img_height = (gw - (gpl + gpr)) * parseFloat(gh);

            $(this).find('.grid .g-img').css('height', g_img_height + 'px');
        });
    }

    var refreshGallerySwiperHeight = function(el) {
        if (typeof el == 'undefined' || !el || $(el).length == 0 || $(el).length > 1) return false;
        if ($(el).find('.empty-txt').length > 0 || $(el).find('.grid').length == 0) return false;

        var swiper_elname = $(el).attr('data-name'),
            swp_h = getComputedStyle(document.querySelector('.' + swiper_elname)).getPropertyValue('--swiper-height');
        if (typeof swp_h != 'undefined' && swp_h) {
            var gel = $(el).find('.grid').eq(0),
                gw = parseFloat(gel[0].getBoundingClientRect().width),
                gpl = parseFloat(gel.css('padding-left').replace(/[^0-9]/g, '')),
                gpr = parseFloat(gel.css('padding-right').replace(/[^0-9]/g, ''));

            if ($(el).is('.reorderBlock')) {
                gw = parseFloat(gw * 5);
                gpl = parseFloat(gpl * 5);
                gpl = parseFloat(gpl * 5);
            }
            var swp_wrap_h = (gw - (gpl + gpr)) * parseFloat(swp_h);
            $(el).find('.swiper-wrapper').css('height', parseFloat(swp_wrap_h) + 'px');
        }
    }


    var getGalleryCategoryBlockNav = function(elid, elsettings) {
        var g_mode = $('.element[data-id="' + elid + '"]').attr('data-mode');
        var gallery_category_home = (typeof elsettings.category_home == 'undefined') ? 'All' : elsettings.category_home,
            gallery_settings_category = (typeof elsettings.category == 'undefined') ? '' : elsettings.category.replace(/\|/g, '').replace(/\,/g, ', '),
            gallery_settings_category_color = (typeof elsettings.category_color_type != 'undefined' && elsettings.category_color_type) ? elsettings.category_color_type : '',
            category_nav_list = '',
            g_category = (gallery_settings_category) ? gallery_settings_category.split(',') : ['category1', 'category2', 'category3'];
        var category_display = (typeof elsettings.category_display == 'undefined') ? 'OFF' : elsettings.category_display;
        var product_orderby = (typeof elsettings.product_orderby == 'undefined') ? 'OFF' : elsettings.product_orderby;
        var str = '<div class="gallery-category-wrap goption-container">',
            ssid = (typeof property != 'undefined') ? property.SID : SID;

        if(category_display == 'ON') {
            if (!gallery_settings_category) {
                elsettings = {
                    category: '|category1|,|category2|,|category3|',
                    category_home: 'All'
                };

                $.post('/template/settings', { sid: ssid, settings: JSON.stringify(elsettings), el: elid }, function(data) {
                    checkError(data);
                }, 'json');
            }

            var active_arr = [],
                cookie_gallery_category = $.cookie('gallery-category-' + elid);

            $.each(g_category, function(i, v) {
                var active = (v.trim() == cookie_gallery_category) ? 'active' : '';
                active_arr.push(active);
                if (v) category_nav_list = category_nav_list + '\
                    <li class="' + active + '"><a href="javascript:;" data-idx="' + (i + 1) + '">' + v.trim() + '</a></li>\
                ';
            });

            var active_empty = ($.inArray('active', active_arr) == -1) ? 'active' : '',
                active_home = (typeof elsettings.category_home_hide != 'undefined' && (elsettings.category_home_hide == 'true' || elsettings.category_home_hide === true)) ? ' hide' : '';
            str += '\
                    <ul class="gallery-category-nav goption-row" data-category-color="' + gallery_settings_category_color + '">\
                        <li class="' + active_empty + active_home + '"><a href="javascript:;" data-idx="0">' + gallery_category_home + '</a></li>\
                        ' + category_nav_list + '\
                    </ul>\
                ';
        }
        
        if(product_orderby == 'ON' && g_mode == 'shopping') {
            var cookie_gallery_orderby = $.cookie('gallery-orderby-' + elid);
            if(!cookie_gallery_orderby) cookie_gallery_orderby = 'recent';
            var g_orderby = {
                'recent': $.lang[LANG]['gallery.shopping.orderby.recent'],
                // 'sales': '판매 인기순',
                'lowprice': $.lang[LANG]['gallery.shopping.orderby.lowprice'],
                'highprice': $.lang[LANG]['gallery.shopping.orderby.highprice'],
                'discount': $.lang[LANG]['gallery.shopping.orderby.discount'],
                'review_cnt': $.lang[LANG]['gallery.shopping.orderby.review_cnt']
            };
            var orderby_nav_list = '';
            var active_orderby = (typeof cookie_gallery_orderby != 'undefined' && cookie_gallery_orderby)? g_orderby[cookie_gallery_orderby] : '신상품순';
            // var gallery_settings_sort_color = (typeof elsettings.product_sort_color_type != 'undefined') ? elsettings.product_sort_color_type : (typeof elsettings['product_sort_color_type'] != 'undefined' && elsettings['product_sort_color_type']) ? elsettings['product_sort_color_type'] : '';

            var i = 0;
            $.each(g_orderby, function(k, v) {
                var active = (k == cookie_gallery_orderby) ? 'active' : '';
                orderby_nav_list += '\
                    <li class="' + active + '"><a href="javascript:;" data-idx="' + i + '" data-orderby="' + k + '">' + v + '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 10" width="13" height="10"><path d="m5 9.71-5-5 1.41-1.42L5 6.88 11.59.29 13 1.71z"/></svg></a></li>\
                ';
                i++;
            });
            str += '\
                    <div class="gallery-sort-nav goption-row" data-sort-lang="' + LANG + '">\
                        <div class="toggle-dropdown display-flex space-between align-items-center">\
                            <span class="active-sort">' + active_orderby + '</span><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="m8 11.35-6-6 .71-.7L8 9.94l5.29-5.29.71.7z"/></svg>\
                        </div>\
                        <ul>\
                        ' + orderby_nav_list + '\
                        </ul>\
                    </div>\
                ';
        }

        str += '</div>';

        return str;
    }

    var loadGalleryCategoryBlock = function(gc_el, gc_id, gc_elsettings) {
        var $gc_el = gc_el;
        if ($gc_el.length == 0) {
            console.log('undefined Gallery Block..');
            return false;
        }

        var gc_deferred = $.Deferred();
        if (typeof isElviewPage != 'undefined' && isElviewPage === true) {
            gc_elsettings = {};
        } else if (typeof gc_elsettings == 'undefined' && typeof gc_id != 'undefined' && gc_id) {
            $.getJSON('/template/element/type/get/seq/' + gc_id, function(data) {
                checkError(data);
                gc_elsettings = (typeof data[0] != 'undefined' && typeof data[0].elsettings != 'undefined' && data[0].elsettings == '') ? $.parseJSON(data[0].elsettings) : {};
                gc_deferred.resolve(gc_elsettings);
            });
        } else gc_deferred.resolve(gc_elsettings);


        gc_deferred.promise().then(function(settings) {
            if (typeof settings == 'undefined') settings = {};

            var margin_val = $gc_el.find('[data-loop="true"]').css('margin-left'),
                padding_val = $gc_el.find('.grid').first().css('padding-left'),
                gc = (typeof settings.category_display != 'undefined' && settings.category_display == 'ON') ? true : false,
                gs = (typeof settings.product_orderby != 'undefined' && settings.product_orderby == 'ON') ? true : false,
                checkLUX = (typeof settings.lux_category_no != 'undefined' && settings.lux_category_no) ? true : false;

            if (checkLUX && $gc_el.is('[data-mode="shopping"]')) gc = false;
            if (gc || gs) {
                var checkMsny = ($gc_el.is('[data-msny="true"]')) ? true : false,
                    checkPremium = ($gc_el.is('[data-type2="premium"]')) ? true : false,
                    checkGalleryCate = ((checkMsny && $gc_el.children('.gallery-category-wrap').length > 0) ||
                        (!checkMsny && $gc_el.find('.container .gallery-category-wrap').length > 0)
                    ) ? true : false,
                    gallery_category_html = getGalleryCategoryBlockNav(gc_id, settings);

                if (checkGalleryCate) $gc_el.find('.gallery-category-wrap').replaceWith(gallery_category_html);
                else {
                    $gc_el.find('.gallery-category-wrap').remove();
                    if (checkMsny) {
                        if ($gc_el.find('.goption').length > 0) $gc_el.find('.goption').after(gallery_category_html);
                        else $gc_el.prepend(gallery_category_html);
                    } else if (checkPremium) {
                        var gcate_position = (typeof getGalleryCateNavPosition == 'function') ? getGalleryCateNavPosition($gc_el) : '';
                        if (gcate_position) $gc_el.find(gcate_position).before(gallery_category_html);
                    } else {
                        $gc_el.find('[data-loop="true"]').before(gallery_category_html);
                    }
                }

                if ($gc_el.find('[data-loop="true"]').find('.emptyGalleryItem').length > 0 && $gc_el.find('.gallery-category-nav .active').index() == 0) {
                    $gc_el.find('.gallery-category-nav').addClass('empty');
                } else $gc_el.find('.gallery-category-nav').removeClass('empty');

            } else {
                $gc_el.find('.gallery-category-wrap').remove();
            }

            var checkGalleryPadding = ($gc_el.find('.goption[data-gpd]').length > 0) ? true : false;
            if (checkGalleryPadding) {} else {
                // before Ver
                if ($('body').width() <= 768) {
                    if (!$gc_el.find('.container').hasClass('full-width')) padding_val = '15px';
                    if ($gc_el.find('input[data-js="fixedscroll"][data-js-code="4"]').length > 0) padding_val = '0px';
                }
                if($gc_el.find('.gallery-category-wrap').width() < $gc_el.width()) {
                    padding_val = '0px';
                }

                $gc_el.find('.gallery-category-wrap').css({ 'margin-left': margin_val, 'margin-right': margin_val });
                $gc_el.find('.gallery-category-nav').css({ 'padding-left': padding_val, 'padding-right': padding_val });
                $gc_el.find('.gallery-sort-nav').css({ 'padding-left': padding_val, 'padding-right': padding_val });

                var gc_width_control = ($gc_el.find('.container').hasClass('full-width')) ? true : false;
                if (typeof $gc_el.attr('data-msny') != 'undefined' && $gc_el.attr('data-msny') == 'true' || gc_width_control) {
                    var width = (gc_width_control && $gc_el.find('.container').css('margin') == '0px') ? $gc_el.find('.container').outerWidth() - 40 : $gc_el.find('.container').outerWidth();
                    $gc_el.find('.gallery-category-wrap').css({ 'width': width, 'margin': '0 auto' });
                }
            }

            if ($gc_el.find('[data-loop="true"]').css('overflow') == 'hidden') $gc_el.find('[data-loop="true"]').css('overflow', 'visible');
            if (checkPremium && $gc_el.is('[data-feature*=fixedscroll]')) {
                setTimeout(function() {
                    gjs01SetFixedscroll($gc_el);
                }, 300);
            }
        });
    }

    var clSVG = function(type, w, h, wrap, add_class) {
        if (typeof add_class == 'undefined') add_class = '';

        var icon = '';
        switch (type) {
            case 'select_caret':
                icon = '<svg viewBox="0 0 16 16" width="' + w + '" height="' + h + '"><path d="M8 12.5c-0.13 0-0.26-0.05-0.35-0.15l-7.5-7.5c-0.2-0.2-0.2-0.51 0-0.71s0.51-0.2 0.71 0L8 11.29l7.15-7.15c0.2-0.2 0.51-0.2 0.71 0s0.2 0.51 0 0.71l-7.5 7.5C8.26 12.45 8.13 12.5 8 12.5z"></path></svg>';
                break;
            case 'caret':
                icon = '<svg viewBox="0 0 8 4" width="' + w + '" height="' + h + '"><polygon points="0 0 4 4 8 0 "></polygon></svg>';
                break;

            case 'plus':
                icon = '<svg viewBox="0 0 14 14" width="' + w + '" height="' + h + '"><rect x="6" width="2" height="14"/><rect x="6" transform="matrix(6.123234e-17 -1 1 6.123234e-17 0 14)" width="2" height="14"/></svg>';
                break;

            case 'move_handle':
                icon = '<svg viewBox="0 0 20 20" width="' + w + '" height="' + h + '"><circle cx="7.5" cy="4" r="1.5"/><circle cx="12.5" cy="4" r="1.5"/><circle cx="7.5" cy="10" r="1.5"/><circle cx="12.5" cy="10" r="1.5"/><circle cx="7.5" cy="16" r="1.5"/><circle cx="12.5" cy="16" r="1.5"/></svg>';
                break;

            case 'folder':
                icon = '<svg viewBox="0 0 16 12" width="' + w + '" height="' + h + '"><path d="M4.38 1c.13 0 .26.05.35.15l1.41 1.41c.29.28.67.44 1.07.44H12c.55 0 1 .45 1 1v6c0 .55-.45 1-1 1H2c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1h2.38m0-1H2C.9 0 0 .9 0 2v8c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2H7.21c-.14 0-.26-.05-.36-.15L5.44.44C5.16.16 4.78 0 4.38 0z"/></svg>';
                break;
            case 'folder_open':
                icon = '<svg viewBox="0 0 16 12" width="' + w + '" height="' + h + '"><path d="M14.8 6a.203.203 0 0 1 .19.28l-1.76 4.12c-.17.36-.53.6-.93.6H1.82a.203.203 0 0 1-.19-.28L3.4 6.61c.16-.37.52-.61.92-.61H14.8m0-1H4.32c-.8 0-1.52.48-1.84 1.21L.72 10.33C.38 11.12.96 12 1.82 12H12.3c.8 0 1.52-.48 1.84-1.21l1.76-4.12c.34-.79-.24-1.67-1.1-1.67z"/><path d="M12 11H2c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1h2.38c.13 0 .26.05.35.15l1.41 1.41c.29.28.67.44 1.07.44H12c.55 0 1 .45 1 1v1h1V4c0-1.1-.9-2-2-2H7.21c-.14 0-.26-.05-.36-.15L5.44.44C5.16.16 4.78 0 4.38 0H2C.9 0 0 .9 0 2v8c0 1.1.9 2 2 2h10c.74 0 1.38-.4 1.72-1H12z"/></svg>';
                break;

            case 'info':
                icon = '<svg viewBox="0 0 13 13" width="' + w + '" height="' + h + '"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>';
                break;

            case 'info2':
                icon = '<svg viewBox="0 0 12 12" width="' + w + '" height="' + h + '"><path d="M6 0a6 6 0 10.01 12.01A6 6 0 006 0zm.6 9.2H5.4V8h1.2v1.2zm0-2H5.4l-.2-4.4h1.6l-.2 4.4z"/></svg>';
                break;

            case 'guide_banner':
                icon = '<svg viewBox="0 0 30 30" width="' + w + '" height="' + h + '"><path d="M20 6.34c.91 0 1.66.74 1.66 1.66v13c0 .91-.74 1.66-1.66 1.66H10c-.91 0-1.66-.74-1.66-1.66V8c0-.91.74-1.66 1.66-1.66h10M20 5H10C8.35 5 7 6.35 7 8v13c0 1.65 1.35 3 3 3h10c1.65 0 3-1.35 3-3V8c0-1.65-1.35-3-3-3z"/><path d="M19 10.69h-3c-.38 0-.69-.31-.69-.69s.31-.69.69-.69h3c.38 0 .69.31.69.69s-.31.69-.69.69z"/><path d="M19 13.69h-3c-.38 0-.69-.31-.69-.69s.31-.69.69-.69h3c.38 0 .69.31.69.69s-.31.69-.69.69z"/><path d="M12 26.69c-.38 0-.69-.31-.69-.69V6c0-.38.31-.69.69-.69s.69.31.69.69v20c0 .38-.31.69-.69.69z"/></svg>';
                break;

            case 'guide_banner2':
                icon = '<svg viewBox="0 0 26 26" width="' + w + '" height="' + h + '"><path d="M13 2C6.92 2 2 6.92 2 13s4.92 11 11 11 11-4.92 11-11S19.08 2 13 2zm0 20.31c-5.13 0-9.31-4.18-9.31-9.31 0-5.13 4.18-9.31 9.31-9.31s9.31 4.18 9.31 9.31c0 5.13-4.18 9.31-9.31 9.31z"/><path d="M13.28 7.09c-1.78 0-3.53.83-3.67 3.03 0 .11-.02.2 0 .34h1.73c0-.13.02-.25.03-.39.14-1.04.88-1.28 1.83-1.28 1.07 0 1.72.63 1.72 1.61-.02.81-.5 1.48-1.28 2.27-1.14 1.12-1.46 1.8-1.49 2.86h1.67c.02-.58.09-1.07 1.16-2.11.84-.81 1.75-1.82 1.75-3.18 0-1.72-1.38-3.15-3.45-3.15zM12.15 17.23h1.69v1.69h-1.69z"/></svg>';
                break;

            case 'guide_arrow':
                icon = '<svg viewBox="0 0 164 105" width="' + w + '" height="' + h + '">\
                          <path d="M4.93 97.87c.1-.14.17-.26.28-.42.03-.22-.08-.01-.28.42zM4.93 97.87c-.99 1.42-2.21 3.85-2.93 5.42.78-.22 2.28-4.04 2.93-5.42zM6.26 97.66c-.56.96-.72.62-1.14 1.81l1.14-1.81zM5.95 96.96l-.73.91.16.2zM91.28 35.83c-.21-.12-.47-.26-.94-.52.56.31.69.39.94.52zM30.74 57.7c.44-.33 1.08-.82 1.78-1.35-.47.19-.85.03-1.78 1.35zM86.92 51.02l.07-.25c-.42.24-.29.27-.07.25zM89.96 38.62l.37-.02-.17-.14c-.09 0-.16.06-.2.16zM81.53 51.44c.11.19.33.41.45.5.08-.15-.02-.3-.45-.5zM91.28 35.83l.12.07v-.01c-.06-.03-.07-.03-.12-.06zM7.56 92.19c.24-.17.48-.43.72-.73-.18.05-.38.12-.72.73zM71.29 32.75c-.28.04-.55.04-.85.12.27-.06.57-.09.85-.12zM25.1 69.35c-.06.05-.11.08-.15.11.04-.01.08-.04.15-.11zM25.33 69.09c-.1.13-.17.2-.22.26.05-.05.13-.13.22-.26zM72.27 43.82v-.05c0 .01-.01.02-.02.03l.02.02zM92.11 52.91l-.11.06-.12.09zM7.73 91.01c.46-.33.31-.69.63-1.24-.32.55-1.4 1.71-.63 1.24zM9.82 88.3c.26-.39.49-.71.72-.95-.36.36-.56.66-.72.95zM10.54 87.35c.08-.08.17-.17.27-.26-.09.07-.18.16-.27.26zM8.64 90.49c.75-1.08.88-1.62 1.18-2.18-.38.56-.78 1.3-1.18 2.18zM16.5 77.65s.71-1.32 1.35-1.82c-.97.74-1.25.57-2.45 2.21.32-.13 2.69-3.25 1.1-.39zM22.62 69.96c-.49.28-.96.42-1.67 1.3.45-.13-.04.48-.5 1.13.66-.78 1.55-1.2 2.17-2.43zM43.69 44.83c.28-.27 1.31-1.21.65-.8l-1.48 1.23c.12.11.61-.29.83-.43zM51.02 40.33c-.7.34.19.27-1.09 1.09l1.32-.56-.23-.53zM50.8 44.29l.04-.06-.43.25zM54.83 37.21l1.25.09c.23-.07 0-.52-1.25-.09zM63.2 33.97l-2.82.68.95-.09zM68.54 32.7l-.23.17 2.22-.25zM117.96 12.77l2.91.13c-2.28-.14-.65-.37-2.91-.13zM139.77 25.97c-.36.01-.72.31-.94.5.49.42.78-.28.94-.5zM140.17 26.81l.38-.07c-.17.07-.34-.19-.38.07zM139.95 26.16l.13.19.15-.13zM146.26 20.93c.12.06.31.15.51.26-.15-.19-.32-.54-.51-.26zM161.68 20.12s-.05.01-.11 0c.1.04.24.09.43.16l-.32-.16zM153.64 18.27l.19.07-.02-.02c-.11-.07-.17-.05-.17-.05zM156.31 18.37l.03.01-.02-.01zM155.18 17.88c.04 0 .04-.01.07-.01-.03 0-.11-.02-.07.01zM97.38 42.64c.02.29.07.69.17 1.26-.02-.44-.08-.86-.17-1.26zM100.55 19.29h-.25.25z"/>\
                          <path d="M161.11 19.03c.03-.11-.47.15-.78-.26 1.33.24-.42-.54.97-.33l-.85-.5h.6c-1.54-.48.1-.5-.76-1.1-.11.03-.1.09-.21.06-.01-.17-.28-.59.29-.27-.25-.3-.85-1.37-1.06-.83.29-.07.37.38.39.56-.52 0-.67-.43-1.27-.46.04-.02.08-.08.13-.13l-.34-.01c.07-.59-.71-1-.48-1.6-.14.03-.31-.02-.44-.21l.46-.24-.53-.6-.4.65c-.59-.46-.44-1.52-.54-1.82-.69.49-.28-.77-1.05-.51l.04.38c-.32-.58-.76-.3-.96-.94.55.18.43.29 1.44.37-.76-.31-.53-1.26-1.35-1.43-.11.17-.09.38-.35.4.22-.39-.45-.46-.01-.73-.27-.04-.64.26-.78.22l-.04-.94-.06.08c-1.67-.06-.99-2.16-2.19-2.68l-.18.2.07-.49c-.02.35-.31.16-.49.31l-.12-.96c-.18.15-.53.56-.32.62-.4-.02-.21-.62-.37-.83l-.1.23-.04-.32-.24.24c-.19-.41-.8-.54-.54-1.03l-.34.41-.02-.62-.07.44c-.44-.28-.68-1.12-.76-1.19l-.11.17c-.13.01-.08-.12-.1-.23l-.16.26c-.48-.59-1.1-.26-1.49-1.08-.22-.11.02.16-.09.28-.26.08-.31-.29-.26-.43-.28.38.07.53-.38.61.02-.3-.21.4-.39.1l.33-.52c-.21-.06-.35.31-.53.06-.06-.42.77-.19.44-.64-.23-.16-1.38.59-1.54-.02-.55-.1-.48.84-.82.28l.02.56c-.19.05-.35.31-.46.03.1-.23.19-.56.1-.68.11.74-.85.13-.86.94l-.13-.16s-.03.08-.07.1l-.22-.16c.03.21.28.53-.16.71l-.36-.19c-.16.31-.35.31-.52.52l.38 1.26c.11-.17.08-.38.26-.49.34.09-.07.43.33.44l.09-.28c-.05.09-.05.14-.12.12-.19.05-.08-.12.03-.24.31-.17.36.2.26.42.3.23.48-.38.61-.39-.26.54.46.43.44.78l.15-.37c.51-.11.44.32.47.53l.16-.26c.24.32 1.09-.26.56.71l.11-.17c.18.05.52.07.4.4.09-.09.22-.18.29-.16-.23.35.11.25.34.37-.04-.19.37-.53.34-.74.65-.12-.18.66.05.88.33-.06.09-.33.2-.5.14.55 1.57-.16 1.04.8l-.39.09c-.03.3.05.37.1.28-.07-.02-.01-.1.04-.19.8.02.08 1.2.65 1.46.11-.17.1-.28.22-.4.34.05-.55.91.05.93l.11-.22c.2.01.04.32-.02.35.65-.63.61.69 1.67.08-.2.5-.06 1.21.27 1.15.58-.18.26-.58.7-.86.15.15-.13.57.21.68-.22.22-.54.32-.76.48.1-.03.2-.02.27-.06l.33.56c-.35.4-.52.05-.65.11.43.28 1.41.17 1.47.76l.11-.17c.08.74.95-.42.65.51.27.08.35-.46.64-.21.07.08-.12.17-.18.2.18.47.51-.2.44.45l.35-.45c.06.64-.3 1.7.18 1.86.05-.06.04-.09.06-.14h-.01l-.03-.32.06-.03.02.24c.05-.17.03-.33.15-.54-.2.95.94 1.17.9 1.75-.18.08-.33.23-.48.38-1.1-.46-2.18-.98-3.29-1.36.23.27 1.2.65.77.75-1.9-.3-1.43-.77-3.25-.9l.71.43c-.12-.13-.35-.21.04-.16.65-.01.88.25.84.42-.69.15-2.4-.44-2.88-.79-2.28-.46-.59.49-1.11.48-1.06-.78-3.78-.71-5.14-1.16l.84.5c-1.79.17-3.27-.43-4.28-.67l.35.35c-2.4-.37-3.69.52-5.42-.71l.24.22c-1-.02-2.51.11-3.44-.27-.03.12-.21.27-.61.28-.51-.46-1.56-.2-3.02-.18.96.15.63.66 1.64.84-2.26.46-2.02-.69-3.92-.73-1.14.26 1.01.31 1.27.53-2.92-.39-5.95 1.16-7.8.15l1.24-.36c-1.16-.21-1.79-.19-1.65-.1.37-.04.5.06.63.15-3.46.66-5.51-.54-9.04.05.29.17.79.16.83.34-1.59.41-1.7-.85-4.28-.07l.55.14c-.85.28-1.55.06-1.44-.02.11.86-5.61.95-7.02 2.78-1.39-.17-5.06.84-5.97 1.64-1.25 1.18 1.56-.07 1.21.65-1.12.56-1.99.31-3.54 1.42-.31-.43 2.86-2.73-.48-1.23l-.31.49c.31-.22.71-.56 1.21-.76 1.05-.25-.39.61-.53.84-1.17.56-2.28 1.22-3.38 1.92-.54-.27 1.48-1.5 1.62-1.73-2.64 1.74-5.03 4.69-7.18 6.59l.33-.07c-2.77 2.49-.61 2.2-2.97 4.07-.67 1.39.76-.17-.37 1.81-.27.58-.29.15-.3.01-.14.26-.16.35-.25.53-1.05-.02-2.15-.03-3.35.14.52-.04.92-.01.61.21-.5.16-1.28.16-1.7.07l.15.08c-1.72-.05-3.43.05-5.07.48.48.17 3.18-.64 2.05.06-.62.61-2.09.62-2.97.86.04-.26 1.6-.96-.07-.57-.17.17-1.63.88-.86.82-1.73.26-4.2.86-5.71 1.28-.4.31.34.06.58-.02l.09-.12c1.01-.29.33.38 2.17-.54.39.54-2.6 1.37-4.16 2.27l2.76-.77c-1.89 1.58-4.45 2.6-6.88 3.9-2.36 1.41-4.9 2.62-6.78 4.01.93-1.06 2.08-1.43 1.58-1.86-2.65 1.36-2.13 1.4-4.52 3.11l.21-.13c-.97 1.2-2.96 2.06-3.37 3.09.72-.16 1.46-1.6 1.92-1.11-.94.78-1.96 1.48-2.81 2.36 1.04-.57 2.84-2.33 3.95-3.17.76-.67-1.63 1.22-1.54.58 2.68-2.17 3.56-2.33 5.23-2.89 1.08-.25-.87 1.31-1.34 1.72-2.03.88-4.91 2.46-7.03 5.14l-.98 1.66c-1.52.83-1.65-.31-3.75 1.9l.91-.38c-.37.56-.65.9-.86 1.14 1.09-.76 2.34-1.49 3.37-2.1-.72 1.69-3.76 3.17-5.52 5.01.16-.03.77-.67 1.09-.73-2.41 2.87-5.66 5.28-7.52 7.54-.5 1.17 1.68-1.75 1.7-.97-1.1 1.07-1.83 2.69-2.45 2.73.94-.12-2.14 2.78.17.87-3.09 4.53-7.02 9.14-10.32 13.64.31-.12.45-.03.44.24.99-1.59 2.7-3.78 3.65-4.39-.39 1.21-1.99 2.18-2.01 2.58.49-.44 1.17-1.48 1.46-1.31-.57 1.54-1.51 2-2.18 2.9l.2-.6c-2.26 2.73-2.01 1.03-3.83 4.32-.36 1.37.29.16.73.4-.65.64-1.6 3.37-2.51 3.9l1.09-1.99c-.91 1.3-1.66 2.61-2.35 3.48.15-.05.29-.07.5-.34-.84 1-1.58 2.44-2.17 2.85l.3.57c.14-.78 1.19-2.77 1.65-2.95.29.41-1.07 2.25-1.5 3.15 2.22-3.79 3.04-3.38 4.55-6.77l-.45.46c.82-2.19 2.66-3.86 3.69-5.59-.2.54-.1.74.12.57 2.04-3.98 4.71-7.47 7.52-11.7l1.32-.92-.27-.32c1.07-1.69.95-.8 1.34-1.02-.04.01-.08.01-.14.02 2.15-1.97.7-1.48 1.8-2.66-.82.33-2.06 2.34-2.07 1.43 2.17-1.96 4.71-5.67 5.79-5.3 3.15-4.31 8.22-8.57 11.55-11.46.35-.51-.38.14-.29-.11 1.71-.68 4.29-4.02 4.63-3.65.57-.65.62-1.17.72-1.42 1.04-.49 2.26-1.08 3.47-1.82l-.95.46.06-.12 1.34-.65-.03.06c2.92-2.01 6.61-3.75 9.65-4.66-1.61.46-.14-.55-.52-.58 1.78-.17 5.35-.95 8.18-2.02-.05-.16.15-.36-.23-.38.59-.11 1.23.04 1.83.04l-.27-.17c1.12-.17 2.26-.23 3.37-.26-.27.97-.7 1.91-.33 2.41-.03-.5.26-1.55.46-2.42.26-.01.53-.02.79-.02-1.21 2.5-2.17 5.46-1.65 7.93.08-.04.12-.17.16-.31l-.07-.1c0-.52.04-1.05.1-1.58l.07.11c-.07.52-.09 1.03-.09 1.54.16-.57.13-1.69.41-2.21-.86 3.69 1.08 8.82 3.48 11.5-1.09-.54.72 1.91-1.28.36-.02-.85-1.01-1.52-1.57-2.71-.1 1.2 1.37 3.2 3.3 4.3 1.9 1.15 3.83 1.31 4.05 1.9l.67-.33c.64.19 2.29.41 1.16.61 1.6-.13 2.95-.6 4.22-1.15-1.49.32-4.57.01-5.66.13-1.08-.63 1.75-.1.77-.76 2.68.66 1.63-.27 4.12-.8-.92 1.06 2.77-.2 2.78.03.75-.49 2.54-1.33 3.29-1.66 1.33-.93 3.68-3.77 4.89-6.3-.57.94-1.69 2.05-1.95 1.72.91-.86 1.48-2.21 1.12-2.58-2.73 3.33.4 1.94-2.52 4.71-1.08.29-1.88.95-3.56 1.9.54-.75.15-.64.21-1.14 2.55-.5 4.68-3.88 5.77-6.72.35-1.28 1.48-.25.82-3.63.26.54.46 1.11.6 1.71-.11-1.45.55-.1-.01-2.48l.01 1.2c-.56-1.63-.89-2.17-1.2-3.12.17.48.19 1.04.26 1.53-.42-.82-1.53-1.99-1.3-2.24-.26-.06-.4-.04-.47.03-.06-.16-.29-.55-1.09-1.14.44.37.74.69.65.81-2.86-2.38-1-.13-2.84-1.32.23.3-.36.08-1.09-.14.48-.89-3.59-2.44-4.63-3.03l.01.02c-.93-.34-1.88-.59-2.83-.85.58.14-.09.31-.93.3l.14.01c-.92.05.96 1.05-1.71.55l-1.4-.36c.25.04 0 .17-.14.23l-.16-.03c.27-.43.5-.73.56-.44.45-.99.23-1.41.56-2.01.95-.84 1.9-1.67 2.97-2.35l-.15.01c4.01-5.38 10.36-6.27 16.43-8.31l-.19-.23 1.46.01c-.8-.04.73-.47.78-.71 1.47-.06 2.92-.15 4.39-.13.07-.24-.27-.76-1.32-.49 1.62-.5 3.4-.19 4.85-.27l-.52-.19 1.48.07-.05-.33c2.43-.07 5.46-.53 6.37-.01l-.3-.53 2.61.38-1.49-.33c2.93-.21 7.37.38 7.98.41l-.25-.21c.48-.08.85.06 1.35.15l-.37-.31c4.4.36 5.68-.25 10.55.68 1.35.1-.73-.19-.73-.36.76-.15 2.45.3 2.8.51-.31-.53-2.41-.68-.78-.83 1.08.4-.7-.55 1.25-.15l.68.71c1.11.08.3-.45 2.01-.08 1.91.62-2.51.23.62.9 1.57.25 3.6-.74 6.56.35 2.63.38-.93-1.2 2.27-.19l.33.51c.05.02-.09-.38-.32-.51.06.02.09.03.16.05L149 17.34c.65 0 .35-.41 1.9.15.32.28.91.64 1.52.94.03.12 0 .33.13.45-.27-.17-.53-.24-.97-.55-.05.12.1.18.15.2v-.07c.19.08.24.56.42.25.3.72-.38.33-.63.52l.6.36c-.45 1.24-1.8.46-2.56.72.14-.3.4-.15.18-.71-.56-.11-.46-.01-.97.04l.05.02c-.14.37-.67-.07-.64.5.22.27.23-.42.47.21l-.6.17c.32.31.6-.17.85-.16.15-.09-.35.02-.43-.41.56-.17.83.19 1.3.7.31.39-.08.53-.18.57-.57-.54-1.19-.66-1.61-.16l-.11.59c-.43-.33-.65-1.23-1.08-.93l.28.28c-.05.18-.1.25-.15.27.29.18.62.39.92.58.01.82-.9-.05-1.36-.03.06.08.21.05.32.22-.51.4-1.48-.19-1.99-.08-.05.4.47.03.58.54-.31-.07-.39.45-.65.06.38.56-.52.29.19.65-.7.65-1.87.54-2.87.71.14.15.22.29.26.43.27-.17.76-.24 1.13.1-.02.39-.64-.17-.6.04.17.09.34-.02.51.28-.05.45-.43.07-.62.11v-.2c-.73-.1-.87-.84-1.32-.36.02.46.18.28.45.71-.24-.1-.32.62-.74.27l.29-.25c-.29.03-.5.18-.75.14.08.08.15.16.22.16-.27-.01-.46.17-.75-.03l.27.47c-.04-.26.25-.51.47-.3.24.41-.23.38-.35.5.69-.29 1.15.4 1.44-.22l-.17-.08c.09-.55.79-.17 1.06-.35-.02.14.06.32.14.38.39-.74 1.19-.77 1.81-1.38l.46.37-.16-.37c.29-.33.32.48.54.33-.09.04-.1-.03-.16-.11.62.22.08-.45.37-.44-.29-.34-.53.07-.66-.5.63.22 1.19-.32 1.64.55.65-.7 1.88-.53 2.59-.7.03-.2-.1-.1-.11-.24.46.42.79-.7.96-.22.09-.18.02-.54.02-.68.26.17.51.21.75.19l-.21-.07v-.07l.3.11v.03c.61-.04 1.22-.37 1.89-.01-.33-.19-.17-.5-.24-.67.39.62 1.63.26 2.39 0-.11-.14-.13-.28-.31-.37l.71.16-.21-.15c.68-.34 2.61.13 2.89-.31-.51.02-.69-.12-1.02-.31.66-.13 1.24-.25 2.38-.24-.12-.03-.23-.06-.32-.1.09-.09.63-.01 1 .02l-.62-.28c.69.04.81-.2 1.87-.09-.59-.35.24-.62-.44-1.16zM143.4 3.01l.02.16c-.05.14-.17.21-.22.29-.09-.13-.06-.42.2-.45zm.93 1.88c-.16.09-.16.03-.15-.05l-.23-.03c-.27.21-.25.56-.33.74-.02-.16.14-.47-.13-.44-.05.09-.12.12-.04.19l-.21-.11c.15-.52.43-.45.71-.39a.66.66 0 0 1 .22-.12c.06-.01.03.08.01.15.07 0 .14 0 .2-.04l-.05.1zm1.94 2.07c.17-.26.13-.01.32-.11l.12.44c-.49.37-.24-.27-.44-.33zm.8-2.52c.12-.07.27.03.29.18-.33.06-.27-.02-.29-.18zm.24-.19c-.46.02.07-.44-.02-.62.39-.04-.08.39.02.62zm1.01 4.79c.24-.24-.06-.48-.06-.53.29-.37.25-.13.57-.24-.13.01-.28.43-.07.49l-.44.28zm.3.34c.21.11.37.32.55.22-.16.21-.83.21-.55-.22zm3.41.12c-.31-.1-.31.32-.5.39.05-.13.17-.29.04-.33l.14.04c.31-.16.03-.3.21-.5.2.02.24.44.11.4zm.58.25c.04-.31-.45.05-.14-.47.5-.2.21.25.14.47zM20.28 74.39l-.81.38.9-1.2-.09.82zm9.68-13.29-.6.63.7-1.04-.1.41zm11.72-11.23c-.88 1.21-4.15 2.58-2.56 2.89-.56.31-2.34 1.55-1.98.86 1.27-1.12 3.44-3.51 4.34-4.45 0 .12.1.17.27.16-.56.35-1.28.99-1.53 1.37.33-.03 1.08-.68 1.46-.83zm15.53-9.39-.68.15c1.49-.96.77-.39.68-.15l.81-.18c-.72.33-.84.29-.81.18zm3.08-2.16c-.09.38-2.2 1.35-2.83 1.48.86-.47 3.14-1.67 2.83-1.48zm.38-1.49c-.34.02-.66.17-.96.29.55-.26.82-.31.96-.29.54-.06.98-.04.9.18-1.28.22-.56-.16-.9-.18zm1.73-.71c-1.02.16-2.11.17-3.07.51 1.49-1.03 3.68-1.06 4.02-.85l-2.02.36 1.07-.02zm2.05-.61-.71-.13.21-.06-.11-.04 3.32-.83-3.21.87.5.19zm8.55-.66c.02.14-.03.29-.03.43-.89-.03-1.19-.44-1.05-.67-1.4-.1-1.09.24-1.8.39l.4-.49c1.77.02 2.17.22 3.24.5-.03.06-.06.13-.1.2-.18.02-.38.07-.53.07.04-.28.01-.46-.13-.43zm.51.84c.25-.09.44-.21.62-.33-.04.07-.07.15-.1.22-.17.04-.35.07-.52.11zm.93 4.74-.34.34v-.34c-.14.47-.13.94-.21 1.42-.46-1.92.55-3.21.89-4.06-.29.75-1.16 2.98-.34 2.64zm3.08 9.79c.21.35.31.53.54.71-.01-.29-.27-1.06.14-.69.04.49 1.01 1.32.86 1.59-.71-.88-1.91-.98-1.54-1.61zm1.85 5.01c-.24-.16-.46-.39-.67-.58.45.2.93.34 1.4.46l-.73.12zm-.69-1.79c-.01.86 2.9 1.46 3.53 1.45-1.59.3-4.79-1.26-3.53-1.45zm2.29-1.45c.23.1.5.14.74.22-.39-.03-.76.12-.74-.22zm2.23 2.18c.72-.08.92-.22.91.12.4.08.93-.27 1.32-.26-1.35.72-1.42.13-2.23.14zm.73-17.7c-.13-.07-.21-.14-.21-.2.71.03 1.48.42 2.14.67l.19-.36c1.25.49 2.97.88 4.11 1.88.88-.15 2.62 2.25 3.03 3.38.1.55 0-1.29.51.17-.62.43.26 1.95-.72 1.84.02.34.07.77-.04 1.22l-.54.06c.18 1.46-1.23 1.34-2.36 2.84.14 0 .32-.12.29 0-.51.4-1.71 1.25-.97.36-.73.78-3.92 2.36-2.31 1.98-.23-.16 1.14-.74 1.71-1.06.18.38-1.25 1.17-1.4 1.73-.11.01-.29.03-.46.05l-.09.33c-1.97.59-3.97 1.31-4.83.59-.04.14-.35.18-.91.02l.12-.49c-.51-.16-.99-.36-1.42-.64.08.32.17.69.32 1.01-1.88-.79-2.09-2.57-2.66-4.09-1.06-.06-.82-3.44-1.6-5.08l-.04 1.58c-.19-3.3-.68-3.81.25-6.79-.27 2.57-.49 2.61.41 6.22-.62-2.98.16-5.13.99-7.53.26 0 .55 0 .78-.01-.32-.04-.55-.08-.74-.12.05-.13.09-.27.13-.41 2.05.08 4.05.25 6.32.85zm-3.2-8.21c.87-.66.84-1.34 1.87-1.54-.45 1.1-1.32 1.19-1.87 1.54zm2.13-2.44c1.29-1.24-1.02.13-.21-.73-.25.2-.46.43-.68.66.89-1.32 1.1-.4 1.86-1.17l-.52.5c-.23.61 1-.5 1.27-.37-.57.61-2.21 1.61-1.72 1.11zm8.27-7.56c-.27-.2 2.18-1.64 2.96-1.41-1.27.57-2.71 1.08-2.96 1.41zm7.01-1.63c.46-.2-.77-.37-1.8.09l.43-.66c.11.27 2.3-.27 2.55-.29.49.36-.41.37-1.18.86zm15.12-2.65-2.41-.08c.42-.66 2.14-.09 3.26-.26.41.27-.49.12-.85.34zm6.14 1.96c1.1-.26 1.23-.16 1.97-.05-.24.13-1.22.15-1.97.05zm1.74.24c1.84-.32 1.5.38 2.6.49-1.46.24-1.23-.37-2.6-.49zm11.89-2.07c-.05.07-.17.14-.46.2-.24.03-.45-.08-.67-.16-.31.02-.57.05-.7.1l-.13-.11c.33-.14.59-.08.83.01.4-.01.76-.02 1.13-.04.29-.31-1.26-.7-1.66-.92.74.17 1.36.56 2.37.45-.12-.11.01-.17-.62-.22l1.38.07c1.52.68.01.59-1.47.62zm9.66 2.29-.72-.23c-.36-.2-.09-.29-.21-.41.87.19 1.95.62.93.64zm1.19 7.58.23-.09.08.42-.31-.33zm2.41-1.27.13-.24.02.21-.15.03zm2.37 0c-.15-.12-.62-.33-.59-.59.29-.03.74-.35.86-.67.02.09.06.19.11.27-.13-.05-.27.06-.29.2.11.17.25.08.36.18-.06.53-1.07-.62-.45.61zm7.09-9.59c.04.14.06.21.15.26.12-.17.15-.57.35-.46-.08.26.19.65-.09.84.03-.53-.9-.14-.41-.64zm.02 2.18c.09.12.19.13-.16.22-.09.09.16.13.07.22-.48-.12.07-.26.09-.44zm-.29 1.15c.47.07.6.02 1.1.04-.29.08-.39.17-.41.26-.23-.11-.47-.18-.7-.29l.01-.01zm.83 1.16c-.32-.34-.07-.39.14-.46.21.17.42.34.21.47-.4.06-1.59-.24-1.6-.05l-.7-.3c.49.21-.04.07-.38.02-.34-.2-.47-.36-.06-.4.17.08.33.16.25.22.12 0 .25-.02.42-.04l1.72.54zm-2.08-.16c-.09-.05-.13-.08-.2-.12l.29.05c.14.07.08.09-.09.07zm.67-2.75c-.5.39.15.55.07.7-.31-.12-.78-.43-.07-.7zm-.5.88c-.52.51.45.04.54.38-.2.02-.26.08-.37.13-.25-.11-.5-.2-.75-.31.15-.02.29-.01.58-.2zm-.19-.15-.36.1.17-.2.19.1zm-.68-3.7c.08.13-.17.92.37.33l-.17.25-.07-.02.03.32c-.54.03-.14-.67-.16-.88zm-1.09 6.71c.14.07.28.15.42.2.07.05.14.09.17.2.16.37-.27.05-.36.05-.07-.19-.09-.35-.23-.45zm-.28 3.48c.22-.29.13-.05.16.12l-.16-.12zm.09-.39c.15-.09.54-.28.49-.23.05.3-.35.36-.49.23zm.29-1.44c.11.07.23.2.27.38-.28-.09-.18-.28-.27-.38zm-.02-.48.25.24-.63-.39c.21-.35.54 0 .77.32l-.39-.17zm.59.17-.25-.28h.03l-.05-.06.57.03-.53.03.23.28zm.01-1.32c.01-.08.17-.06.35.17.03.1-.14.04-.27-.06l.09.08c-.31-.1-.58-.22-.82-.34.11.16.26.22.38.31-.18-.09-.33-.16-.43-.23-.01 0 0-.02-.01-.03l.01.02c-.21-.12-.3-.21-.27-.25l.05-.02-.02-.01c.28-.1 1.65.16 1.85-.02.36.19.86.43.43.35l-.46-.13c.06.02.19.12.26.17l-.42-.14c.59.7-.87-.25-.72.13zm1.48 1.76-.25-.39c.17.04.3.1.44.15-.38-.11-.1.14-.19.24zm.23-.23c.3.12.6.27 1.16.5-.25.31-.94-.22-1.16-.5zm1.41.92c.04-.25-.58-.77.4-.33l-.4.33zm-2.33-3.09.02.01-.18-.05c-.13-.09-.23-.17-.49-.31l1.18.43c-.14-.07-.16-.14-.07-.16l1.59.53c-.43-.22-1.15-.53-1.69-.8l.63.12c.16.08.38.23-.21.06.25.08.45.14.62.19-.09-.02-.06.01-.09.02.03 0 .08.01.22.05-.16.14.97.37.91.45l-.04.01c.27.07.48.18.48.24-1.49-.52-2.1-.49-2.88-.79zm3.3-3.9.17.25c-.17-.09-.44-.08-.17-.25z"/><path d="m152.62 14.01-.01-.08c-.01.03-.03.07-.05.11l.06-.03zM148.68 11.04l.25-.13c-.05-.01-.1-.05-.15-.08-.02.07-.14.09-.1.21zM148.72 10.79c0 .03.04.02.06.03.02-.07.04-.15.1-.2-.06.03-.12.04-.16.17zM140.46 24.38c-.09.06-.52-.08-.16.2.2.13.07-.14.16-.2zM143.28 23.48c-.36-.26-.52-.56-.87-.48.14.15.85.07.48.54-.01 0 .15-.24.39-.06zM143.99 23.26c.19-.01.52.35.63.06-.18-.17-.37-.42-.57-.39.18.24.05.27-.06.33zM148.99 19.35c.05-.05.25-.2.09-.25l-.31.11c.07.16.17.13.22.14zM150.38 19.73l.31.18-.16-.55c-.16-.05.1.32-.15.37zM151.14 22.52v-.04l-.08.01zM152.75 18.3l.2-.03-.27-.09zM152.16 13.29c-.2-.01-.38-.53-.74-.13.63-.31.18.52.74.13zM145.28 7.04l-.25-.43c.17.35-.16.31.25.43z"/>\
                        </svg>';
                break;

            case 'question':
                icon = '<svg viewBox="0 0 13 13" width="' + w + '" height="' + h + '"><path d="M6.5 0a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13zM7 10H6V9h1v1zm.67-3.25c-.63.62-.67.91-.68 1.25H6c.02-.63.21-1.03.88-1.69.46-.47.75-.86.76-1.34 0-.58-.39-.95-1.02-.95-.56 0-1 .14-1.08.76-.01.07-.02.15-.02.22H4.5c-.01-.08 0-.14 0-.2.08-1.3 1.11-1.79 2.17-1.79 1.22 0 2.04.84 2.04 1.87-.01.8-.54 1.39-1.04 1.87z"/></svg>';
                break;

            case 'question2':
                icon = '<svg viewBox="0 0 13 13" width="' + w + '" height="' + h + '"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="9" width="1" height="1"/><path d="M6.66 3.01C5.61 3.01 4.58 3.5 4.5 4.8c0 0.06-0.01 0.12 0 0.2h1.02c0-0.07 0.01-0.15 0.02-0.23 0.08-0.62 0.52-0.76 1.08-0.76 0.63 0 1.02 0.37 1.02 0.95 -0.01 0.48-0.3 0.87-0.76 1.34C6.21 6.97 6.02 7.37 6 8h0.99C7 7.66 7.04 7.37 7.67 6.75 8.17 6.27 8.7 5.68 8.7 4.87 8.7 3.85 7.89 3.01 6.66 3.01z"/></svg>';
                break;

            case 'checkbox_active':
                icon = '<svg viewBox="0 0 20 20" width="' + w + '" height="' + h + '" class="cl-svg-checkbox hand"><path d="M10 0C4.48 0 0 4.48 0 10c0 5.52 4.48 10 10 10s10-4.48 10-10C20 4.48 15.52 0 10 0zM15.03 7.78l-5.5 5.5C9.38 13.43 9.19 13.5 9 13.5s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L9 11.69l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S15.32 7.49 15.03 7.78z"/></svg>';
                break;
            case 'checkbox_inactive':
                icon = '<svg viewBox="0 0 20 20" width="' + w + '" height="' + h + '" class="cl-svg-checkbox"><path d="M10 0C4.48 0 0 4.48 0 10c0 5.52 4.48 10 10 10s10-4.48 10-10C20 4.48 15.52 0 10 0zM14.5 10.75h-9c-0.41 0-0.75-0.34-0.75-0.75S5.09 9.25 5.5 9.25h9c0.41 0 0.75 0.34 0.75 0.75S14.91 10.75 14.5 10.75z"/></svg>';
                break;

            case 'checkbox2_active':
                icon = '<svg viewBox="0 0 16 16" width="' + w + '" height="' + h + '" class="cl-svg-checkbox hand"><path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3c0-1.66-1.34-3-3-3zm.03 6.03-5.5 5.5c-.15.15-.34.22-.53.22s-.38-.07-.53-.22l-3.5-3.5a.754.754 0 0 1 0-1.06c.29-.29.77-.29 1.06 0L7 9.94l4.97-4.97c.29-.29.77-.29 1.06 0 .29.29.29.77 0 1.06z"/></svg>';
                break;
            case 'checkbox2_default':
                icon = '<svg viewBox="0 0 16 16" width="' + w + '" height="' + h + '" class="cl-svg-checkbox hand"><path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3c0-1.66-1.34-3-3-3zm2 13c0 1.1-.9 2-2 2H3c-1.1 0-2-.9-2-2V3c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2v10z"/></svg>';
                break;

            case 'checkbox':
                icon = '\
                        <svg viewBox="0 0 16 16" width="' + w + '" height="' + h + '">\
                            <path class="st6" d="M3 0h10c1.66 0 3 1.34 3 3v10c0 1.66-1.34 3-3 3H3c-1.66 0-3-1.34-3-3V3C0 1.34 1.34 0 3 0z"/>\
                            <path class="st19" d="M13 1c1.1 0 2 0.9 2 2v10c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2H13M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0L13 0z"/>\
                        </svg>\
                        <svg class="active" viewBox="0 0 16 16" width="' + w + '" height="' + h + '">\
                            <rect x="2" y="2" class="st19" width="12" height="12"/>\
                            <path d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/>\
                        </svg>\
                    ';
                break;

            case 'radio_set':
                icon = '\
                            <svg viewBox="0 0 18 18" width="18" height="18">\
                                <path fill="#dbdcdf" d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"/>\
                            </svg>\
                            <svg class="active" viewBox="0 0 18 18" width="18" height="18">\
                                <path fill="#4789e7" d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"/>\
                                <circle fill="#4789e7" cx="9" cy="9" r="6"/>\
                            </svg>\
                    ';
                break;

            case 'pencil':
                icon = '<svg viewBox="0 0 12 12" width="' + w + '" height="' + h + '"><path d="M11.56 0.57l-0.13-0.13C11.14 0.15 10.76 0 10.37 0 9.99 0 9.6 0.15 9.31 0.44L0.75 9 0 12l3-0.75 8.56-8.56C12.15 2.1 12.15 1.15 11.56 0.57zM2.49 10.35l-1.11 0.28 0.28-1.11 6.58-6.58 0.84 0.84L2.49 10.35zM10.85 1.98L9.77 3.06 8.94 2.23l1.08-1.08C10.15 1.02 10.29 1 10.37 1s0.23 0.02 0.35 0.15l0.13 0.13C11.05 1.47 11.05 1.79 10.85 1.98z"></path></svg>';
                break;

            case 'clone':
                icon = '<svg viewBox="0 0 12 12" width="' + w + '" height="' + h + '"><path d="M9.5 0h-5C3.67 0 3 0.67 3 1.5V2H2.5C1.67 2 1 2.67 1 3.5v7C1 11.33 1.67 12 2.5 12h5C8.33 12 9 11.33 9 10.5V10h0.5c0.83 0 1.5-0.67 1.5-1.5v-7C11 0.67 10.33 0 9.5 0zM8 10.5C8 10.78 7.78 11 7.5 11h-5C2.22 11 2 10.78 2 10.5v-7C2 3.22 2.22 3 2.5 3H3v5.5C3 9.33 3.67 10 4.5 10H8V10.5zM10 8.5C10 8.78 9.78 9 9.5 9h-5C4.22 9 4 8.78 4 8.5v-7C4 1.22 4.22 1 4.5 1h5C9.78 1 10 1.22 10 1.5V8.5z"/></svg>';
                break;

            case 'delete':
                icon = '<svg viewBox="0 0 12 12" width="' + w + '" height="' + h + '"><path d="M11 2H9V0H3v2H1 0v1h1v7c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2H11zM4 1H8v1H4V1zM10 10c0 0.6-0.4 1-1 1H3c-0.5 0-1-0.4-1-1V3h1H9h1V10z"></path><rect x="4" y="4" width="1" height="6"></rect><rect x="7" y="4" width="1" height="6"></rect></svg>';
                break;

            case 'paperclip':
                icon = '<svg viewBox="0 0 16 16" width="' + w + '" height="' + h + '"><path d="M13.98 1.04c-2.12-1.66-5.2-1.28-6.86 0.84L0.97 9.75c-1.32 1.68-1.02 4.12 0.66 5.43 1.68 1.32 4.12 1.02 5.43-0.66l6.16-7.87c0.97-1.24 0.75-3.04-0.49-4.01 -1.24-0.97-3.04-0.75-4.01 0.49l-4.78 6.1 0.85 0.66 4.78-6.1c0.6-0.77 1.73-0.91 2.5-0.3 0.77 0.6 0.91 1.73 0.3 2.5l-6.16 7.87c-0.95 1.21-2.71 1.43-3.92 0.48 -1.21-0.95-1.43-2.71-0.48-3.92l6.16-7.87c1.29-1.65 3.69-1.95 5.35-0.65 1.65 1.29 1.95 3.69 0.65 5.35l-4.78 6.1L10.04 14l4.78-6.1C16.48 5.77 16.1 2.7 13.98 1.04z"></path></svg>';
                break;

            case 'check':
                icon = '<svg viewBox="0 0 24 24" width="' + w + '" height="' + h + '"><path d="M19.29 6.29 10 15.59l-5.29-5.3-1.42 1.42 6.71 6.7 10.71-10.7z"/></svg>';
                break;

            case 'search':
                    icon = '<svg viewBox="0 0 16 16" width="'+w+'" height="'+h+'" ><path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"></path></svg>';
                break;

            case 'times':
                icon = '<svg viewBox="0 0 12 12" width="' + w + '" height="' + h + '"><polygon points="12 0.71 11.29 0 6 5.29 0.71 0 0 0.71 5.29 6 0 11.29 0.71 12 6 6.71 11.29 12 12 11.29 6.71 6 "/></svg>';
                break;

            case 'close':
                icon = '<svg viewBox="0 0 12 12" width="' + w + '" height="' + h + '"><path d="M6.71 6l5.15-5.15c0.2-0.2 0.2-0.51 0-0.71s-0.51-0.2-0.71 0L6 5.29 0.85 0.15c-0.2-0.2-0.51-0.2-0.71 0s-0.2 0.51 0 0.71L5.29 6l-5.15 5.15c-0.2 0.2-0.2 0.51 0 0.71C0.24 11.95 0.37 12 0.5 12s0.26-0.05 0.35-0.15L6 6.71l5.15 5.15c0.1 0.1 0.23 0.15 0.35 0.15s0.26-0.05 0.35-0.15c0.2-0.2 0.2-0.51 0-0.71L6.71 6z"/></svg>';
                break;

            case 'close_m':
                    icon = '<svg viewBox="0 0 16 16" width="'+w+'" height="'+h+'"><path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"/></svg>';
                break;

            case 'close_m_thin':
                    icon = '<svg viewBox="0 0 16 16" width="'+w+'" height="'+h+'" aria-label="close"><path d="M4.55082 5.25841L4.19727 4.90486L4.90437 4.19775L5.25793 4.55131L7.99994 7.29332L10.7419 4.55131L11.0955 4.19775L11.8026 4.90486L11.4491 5.25841L8.70704 8.00042L11.4484 10.7418L11.802 11.0953L11.0948 11.8024L10.7413 11.4489L7.99994 8.70753L5.25858 11.4489L4.90502 11.8024L4.19792 11.0953L4.55147 10.7418L7.29283 8.00042L4.55082 5.25841Z"></path></svg>';
                break;

            case 'close_l':
                icon = '<svg viewBox="0 0 22 22" width="' + w + '" height="' + h + '"><path d="M-.002 20.942 20.935.004l1.06 1.061L1.058 22.003z"/><path d="m-.003 1.058 1.06-1.06 20.939 20.937-1.061 1.06z"/></svg>';
                break;


            case 'videoPlay_btn':
                icon = '<svg viewBox="0 0 58 58" width="' + w + '" height="' + h + '" class="playbtn"><circle cx="29" cy="29" r="29"/><path class="st23" d="M29 0C12.98 0 0 12.98 0 29c0 16.02 12.98 29 29 29s29-12.98 29-29C58 12.98 45.02 0 29 0zM41.25 29.43l-17.5 10.13C23.42 39.76 23 39.52 23 39.13V18.87c0-0.39 0.42-0.63 0.75-0.43l17.5 10.13C41.59 28.76 41.59 29.24 41.25 29.43z"/></svg>';
                break;

            case 'visible-off':
                icon = '<svg viewBox="0 0 14 12" width="' + w + '" height="' + h + '"><path d="M12.29 0l-1.88 1.88C9.39 1.32 8.23 1 7 1 3.83 1 1.12 3.07 0 6c0.56 1.46 1.53 2.68 2.73 3.56L1 11.29 1.71 12 13 0.71 12.29 0zM1.09 6C2.15 3.64 4.4 2 7 2c0.95 0 1.86 0.23 2.67 0.62L8.73 3.56C8.24 3.21 7.65 3 7 3 5.34 3 4 4.34 4 6c0 0.65 0.21 1.24 0.56 1.73L3.44 8.85C2.44 8.15 1.62 7.17 1.09 6zM5 6c0-1.1 0.9-2 2-2 0.37 0 0.71 0.11 1.01 0.28L5.28 7.01C5.11 6.71 5 6.37 5 6z"/><path d="M12.05 3.06l-0.71 0.71C11.99 4.4 12.53 5.15 12.91 6c-1.05 2.36-3.3 4-5.91 4 -0.57 0-1.12-0.09-1.65-0.24l-0.8 0.8C5.32 10.84 6.14 11 7 11c3.17 0 5.88-2.07 7-5C13.57 4.87 12.89 3.87 12.05 3.06z"/></svg>';
                break;

            case 'link':
                icon = '<svg viewBox="0 0 12 12" width="' + w + '" height="' + h + '"><path d="M11.3 0.81L11.19 0.7C10.72 0.23 10.11 0 9.49 0 8.88 0 8.27 0.23 7.8 0.7L6.24 2.26l0.71 0.71L8.5 1.41C8.77 1.15 9.12 1 9.49 1c0.37 0 0.73 0.15 0.99 0.41l0.11 0.11c0.55 0.55 0.55 1.43 0 1.98L7.48 6.6C7.22 6.87 6.87 7.01 6.49 7.01c-0.37 0-0.73-0.15-0.99-0.41L5.45 6.54 4.74 7.25 4.8 7.31c0.47 0.47 1.08 0.7 1.7 0.7 0.61 0 1.23-0.23 1.7-0.7L11.3 4.2C12.23 3.27 12.23 1.75 11.3 0.81z"/><path d="M3.5 10.59C3.23 10.85 2.88 11 2.51 11c-0.37 0-0.73-0.15-0.99-0.41l-0.11-0.11c-0.55-0.55-0.55-1.43 0-1.98L4.52 5.4c0.26-0.26 0.62-0.41 0.99-0.41 0.37 0 0.73 0.15 0.99 0.41l0.06 0.06 0.71-0.71L7.2 4.69c-0.47-0.47-1.08-0.7-1.7-0.7 -0.61 0-1.23 0.23-1.7 0.7L0.7 7.8c-0.94 0.94-0.94 2.46 0 3.39l0.11 0.11c0.47 0.47 1.08 0.7 1.7 0.7 0.61 0 1.23-0.23 1.7-0.7l1.55-1.55L5.05 9.04 3.5 10.59z"/></svg>';
                break;

            case 'gallery-link':
                icon = '<svg viewBox="0 0 15 15" width="' + w + '" height="' + h + '"><path d="M6 9.85c-0.22 0-0.44-0.08-0.6-0.25 -0.33-0.33-0.33-0.87 0-1.2l3-3c0.33-0.33 0.87-0.33 1.2 0 0.33 0.33 0.33 0.87 0 1.2l-3 3C6.44 9.77 6.22 9.85 6 9.85z"/><path d="M3.85 15c-1.03 0-2-0.4-2.72-1.13C0.4 13.15 0 12.18 0 11.15s0.4-2 1.13-2.72l2-2C3.46 6.1 4 6.1 4.33 6.43c0.33 0.33 0.33 0.87 0 1.2l-2 2c-0.41 0.41-0.63 0.95-0.63 1.52s0.22 1.11 0.63 1.52c0.81 0.81 2.23 0.81 3.04 0l2-2c0.33-0.33 0.87-0.33 1.2 0 0.33 0.33 0.33 0.87 0 1.2l-2 2C5.85 14.6 4.88 15 3.85 15z"/><path d="M11.2 8.85c-0.22 0-0.44-0.08-0.6-0.25 -0.33-0.33-0.33-0.87 0-1.2l2.07-2.07c0.41-0.41 0.63-0.95 0.63-1.52s-0.22-1.11-0.63-1.52c-0.81-0.81-2.23-0.81-3.04 0L7.56 4.36c-0.33 0.33-0.87 0.33-1.2 0 -0.33-0.33-0.33-0.87 0-1.2l2.07-2.07c1.45-1.46 3.99-1.46 5.44 0C14.6 1.82 15 2.78 15 3.81s-0.4 2-1.13 2.72L11.8 8.61C11.64 8.77 11.42 8.85 11.2 8.85z"/></svg>';
                break;

            case 'lock':
                icon = '<svg viewBox="0 0 12 12" width="' + w + '" height="' + h + '"><path d="M10 5.09V3.5C10 1.57 8.43 0 6.5 0h-1C3.57 0 2 1.57 2 3.5v1.59C1.42 5.3 1 5.85 1 6.5v4C1 11.33 1.67 12 2.5 12h7c0.83 0 1.5-0.67 1.5-1.5v-4C11 5.85 10.58 5.3 10 5.09zM3 3.5C3 2.12 4.12 1 5.5 1h1C7.88 1 9 2.12 9 3.5V5H3V3.5zM10 10.5c0 0.28-0.22 0.5-0.5 0.5h-7C2.22 11 2 10.78 2 10.5v-4C2 6.22 2.22 6 2.5 6h7C9.78 6 10 6.22 10 6.5V10.5z"/></svg>';
                break;

            case 'item':
                icon = '<svg viewBox="0 0 16 16" width="' + w + '" height="' + h + '"><circle cx="5.5" cy="2.5" r="1.5"></circle><circle cx="10.5" cy="2.5" r="1.5"></circle><circle cx="10.5" cy="7.5" r="1.5"></circle><circle cx="5.5" cy="7.5" r="1.5"></circle><circle cx="5.5" cy="12.5" r="1.5"></circle><circle cx="10.5" cy="12.5" r="1.5"></circle></svg>';
                break;

            case 'file-link':
                icon = '<svg viewBox="0 0 12 12" width="' + w + '" height="' + h + '"><path d="M11.3 0.81L11.19 0.7C10.72 0.23 10.11 0 9.49 0 8.88 0 8.27 0.23 7.8 0.7L6.24 2.26l0.71 0.71L8.5 1.41C8.77 1.15 9.12 1 9.49 1c0.37 0 0.73 0.15 0.99 0.41l0.11 0.11c0.55 0.55 0.55 1.43 0 1.98L7.48 6.6C7.22 6.87 6.87 7.01 6.49 7.01c-0.37 0-0.73-0.15-0.99-0.41L5.45 6.54 4.74 7.25 4.8 7.31c0.47 0.47 1.08 0.7 1.7 0.7 0.61 0 1.23-0.23 1.7-0.7L11.3 4.2C12.23 3.27 12.23 1.75 11.3 0.81z"></path><path d="M3.5 10.59C3.23 10.85 2.88 11 2.51 11c-0.37 0-0.73-0.15-0.99-0.41l-0.11-0.11c-0.55-0.55-0.55-1.43 0-1.98L4.52 5.4c0.26-0.26 0.62-0.41 0.99-0.41 0.37 0 0.73 0.15 0.99 0.41l0.06 0.06 0.71-0.71L7.2 4.69c-0.47-0.47-1.08-0.7-1.7-0.7 -0.61 0-1.23 0.23-1.7 0.7L0.7 7.8c-0.94 0.94-0.94 2.46 0 3.39l0.11 0.11c0.47 0.47 1.08 0.7 1.7 0.7 0.61 0 1.23-0.23 1.7-0.7l1.55-1.55L5.05 9.04 3.5 10.59z"></path></svg>';
                break;

            case 'file-image':
                icon = '<svg viewBox="0 0 20 20" width="' + w + '" height="' + h + '"><path d="M0 0v20h20V0H0zM19 1v11.3l-3-3 -4 4 -6-6 -5 5V1H19zM1 19v-5.3l5-5 6 6 4-4 3 3V19H1z"/><circle cx="14.5" cy="5.5" r="1.5"/></svg>';
                break;

            case 'elviewer-pc':
                icon = '<svg viewBox="0 0 42 42" width="' + w + '" height="' + h + '"><g><path class="st9" d="m18.43 24.5-5.77 10c-1.15 2 .29 4.5 2.6 4.5H26.8c2.31 0 3.75-2.5 2.6-4.5l-5.77-10c-1.16-2-4.04-2-5.2 0z" fill="#ffffff"/><path d="M21.03 25c.17 0 .61.05.87.5l5.77 10c.26.45.09.85 0 1s-.35.5-.87.5H15.26c-.52 0-.78-.35-.87-.5s-.26-.55 0-1l5.77-10c.26-.45.7-.5.87-.5m0-2c-1.01 0-2.02.5-2.6 1.5l-5.77 10c-1.15 2 .29 4.5 2.6 4.5H26.8c2.31 0 3.75-2.5 2.6-4.5l-5.77-10c-.58-1-1.59-1.5-2.6-1.5z" /><path class="st9" d="M36 33H6c-2.21 0-4-1.79-4-4V7c0-2.21 1.79-4 4-4h30c2.21 0 4 1.79 4 4v22c0 2.21-1.79 4-4 4z" fill="#ffffff"/><path d="M36 3H6C3.79 3 2 4.79 2 7v22c0 2.21 1.79 4 4 4h30c2.21 0 4-1.79 4-4V7c0-2.21-1.79-4-4-4zM4 23V7c0-1.1.9-2 2-2h30c1.1 0 2 .9 2 2v16H4zm2 8c-1.1 0-2-.9-2-2v-4h34v4c0 1.1-.9 2-2 2H6z" /><circle class="st9" cx="21" cy="28" r=".25"/><path d="M21 27c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z" /></g></svg>';
                break;
            case 'elviewer-mobile':
                icon = '<svg viewBox="0 0 42 42" width="' + w + '" height="' + h + '"><g><path d="M28 40H14c-2.76 0-5-2.24-5-5V7c0-2.76 2.24-5 5-5h14c2.76 0 5 2.24 5 5v28c0 2.76-2.24 5-5 5z" style="fill:#fff"/><path d="M28 4c1.65 0 3 1.35 3 3v28c0 1.65-1.35 3-3 3H14c-1.65 0-3-1.35-3-3V7c0-1.65 1.35-3 3-3h14m0-2H14c-2.76 0-5 2.24-5 5v28c0 2.76 2.24 5 5 5h14c2.76 0 5-2.24 5-5V7c0-2.76-2.24-5-5-5z" /><path d="M21 32c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z" /></g></svg>';
                break;
            case 'elviewer-pc-t':
                icon = '<svg viewBox="0 0 42 42" width="' + w + '" height="' + h + '"><path d="M36 5c1.1 0 2 .9 2 2v22c0 1.1-.9 2-2 2H6c-1.1 0-2-.9-2-2V7c0-1.1.9-2 2-2h30m0-2H6C3.79 3 2 4.79 2 7v22c0 2.21 1.79 4 4 4h30c2.21 0 4-1.79 4-4V7c0-2.21-1.79-4-4-4z"/><path d="M40 23H2v2h38v-2z"/><circle cx="21" cy="28" r=".25" fill="#white"/><path d="M21 27c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"/><path d="M27.38 31h-2.31l1.15 2 1.44 2.5c.26.45.09.85 0 1s-.33.5-.86.5H15.26c-.52 0-.78-.35-.87-.5a.976.976 0 0 1 0-1l1.44-2.5 1.15-2h-2.31l-1.15 2-.87 1.5c-1.15 2 .29 4.5 2.6 4.5H26.8c2.31 0 3.75-2.5 2.6-4.5l-.86-1.5-1.16-2z"/></svg>';
                break;
            case 'elviewer-mobile-t':
                icon = '<svg viewBox="0 0 42 42" width="' + w + '" height="' + h + '"><path d="M28 4c1.65 0 3 1.35 3 3v28c0 1.65-1.35 3-3 3H14c-1.65 0-3-1.35-3-3V7c0-1.65 1.35-3 3-3h14m0-2H14c-2.76 0-5 2.24-5 5v28c0 2.76 2.24 5 5 5h14c2.76 0 5-2.24 5-5V7c0-2.76-2.24-5-5-5z"/><path d="M21 32c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"/></svg>';
                break;

            case 'elview-info':
                icon = '<svg viewBox="0 0 13 13" width="' + w + '" height="' + h + '"><g id="alert01"><path d="M6.5 0a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13zm0 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><path d="M6 5h1v5H6z"/><path d="M6 3h1v1H6z"/></g></svg>';
                break;

            case 'elview-left':
                icon = '<svg viewBox="0 0 44 44" width="' + w + '" height="' + h + '"><path d="M30 43c-.29 0-.58-.13-.78-.38l-16-20c-.29-.37-.29-.88 0-1.25l16-20c.35-.43.97-.5 1.41-.16.43.35.5.97.16 1.41L15.28 22l15.5 19.37c.34.43.27 1.06-.16 1.41-.18.15-.4.22-.62.22z"/></svg>';
                break;
            case 'elview-right':
                icon = '<svg viewBox="0 0 44 44" width="' + w + '" height="' + h + '"><path d="M14 43c.29 0 .58-.13.78-.38l16-20c.29-.37.29-.88 0-1.25l-16-20c-.35-.43-.97-.5-1.41-.16-.43.35-.5.97-.16 1.41L28.72 22l-15.5 19.37c-.34.43-.27 1.06.16 1.41.18.15.4.22.62.22z"/></svg>';
                break;
            case 'elview-leftright-p':
                icon = '<svg viewBox="0 0 36 26" width="' + w + '" height="' + h + '"><path d="M0 3v20l13-10z"/><path d="M34.25 6.56v12.88L25.88 13l8.37-6.44M36 3 23 13l13 10V3z"/><path fill="none" stroke="#8e9095" stroke-width="2" stroke-miterlimit="10" stroke-dasharray="3.5,2.3" d="M18.08 0v26"/></svg>';
                break;
            case 'elview-leftright-m':
                icon = '<svg viewBox="0 0 26 36" width="' + w + '" height="' + h + '"><path d="M23 0H3l10 13z"/><path d="m13 25.88 6.44 8.37H6.56L13 25.88M13 23 3 36h20L13 23z"/><path fill="none" stroke="#8e9095" stroke-width="2" stroke-miterlimit="10" stroke-dasharray="3.5,2.3" d="M26 18.08H0"/></svg>';
                break;

            case 'block-premium':
                icon = '<svg viewBox="0 0 13 10" width="' + w + '" height="' + h + '"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 0 .05 4.04 6.49 10l6.56-5.98L11 0z"/></svg>';
                break;

            case 'block-menu':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><g><path d="M34 8.5v21H4v-21h30m0-2H4c-1.1 0-2 .9-2 2v21c0 1.1.9 2 2 2h30c1.1 0 2-.9 2-2v-21c0-1.1-.9-2-2-2z"/><path d="M36 14.34H2v2h34v-2z"/></g></svg>';
                break;
            case 'block-sidebar':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><g><path d="M34 8v22H4V8h30m0-2H4c-1.1 0-2 .9-2 2v22c0 1.1.9 2 2 2h30c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2z"/><path d="M12 6h-2v26h2V6z"/></g></svg>';
                break;
            case 'block-moption':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><path d="M31.91 20h-26c-.55 0-1-.45-1-1s.45-1 1-1h26c.55 0 1 .45 1 1s-.45 1-1 1z"/><path d="M31.91 29h-26c-.55 0-1-.45-1-1s.45-1 1-1h26c.55 0 1 .45 1 1s-.45 1-1 1z"/><path d="M31.91 11h-26c-.55 0-1-.45-1-1s.45-1 1-1h26c.55 0 1 .45 1 1s-.45 1-1 1z"/></svg>';
                break;
            case 'block-footer':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><g><path d="M28 23.01H10c-.55 0-1-.45-1-1s.45-1 1-1h18c.55 0 1 .45 1 1 0 .56-.45 1-1 1zM28 18.01H10c-.55 0-1-.45-1-1s.45-1 1-1h18c.55 0 1 .45 1 1 0 .56-.45 1-1 1z"/><path d="M34 8.99v18H4v-18H2v18c0 1.12.9 2.03 2 2.03h30c1.1 0 2-.91 2-2.03v-18h-2z"/></g>';
                break;
            case 'block-project':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><g><path d="M4 27.01v-14h30v14h2v-14c0-1.12-.9-2.03-2-2.03H4c-1.1 0-2 .91-2 2.03v14h2z"/><path d="M28 18.99H10c-.55 0-1-.45-1-1s.45-1 1-1h18c.55 0 1 .45 1 1s-.45 1-1 1z"/></g></svg>';
                break;
            case 'block-gallerycategory':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><g><path d="M4 27.01v-14h30v14h2v-14c0-1.12-.9-2.03-2-2.03H4c-1.1 0-2 .91-2 2.03v14h2z"/><path d="M28 18.99H10c-.55 0-1-.45-1-1s.45-1 1-1h18c.55 0 1 .45 1 1s-.45 1-1 1z"/></g></svg>';
                break;
            case 'block-showcase':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><g><path d="M28.3 10.93H9.7c-1.1 0-2 .9-2 2v12.15c0 1.1.9 2 2 2h18.6c1.1 0 2-.9 2-2V12.93c0-1.11-.89-2-2-2zm0 14.14H9.7V12.93h18.6v12.14zM5.23 16.36l-.05-.05c-.2-.2-.51-.2-.71 0l-2.34 2.34c-.2.2-.2.51 0 .71l.05.05 2.28 2.28c.2.2.51.2.71 0l.05-.05c.2-.2.2-.51 0-.71L3.3 19l1.93-1.93c.19-.2.19-.51 0-.71zM35.87 18.65l-2.34-2.34c-.2-.2-.51-.2-.71 0l-.05.05c-.2.2-.2.51 0 .71L34.7 19l-1.93 1.93c-.2.2-.2.51 0 .71l.05.05c.2.2.51.2.71 0l2.28-2.28.05-.05c.2-.2.2-.52.01-.71z"/></g></svg>\
                    ';
                break;
            case 'block-header':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><g><path d="M26.07 16H11.93c-.51 0-.93.42-.93.93v.14c0 .51.42.93.93.93h14.14c.51 0 .93-.42.93-.93v-.14c0-.51-.42-.93-.93-.93zM26.07 20H11.93c-.51 0-.93.42-.93.93v.14c0 .51.42.93.93.93h14.14c.51 0 .93-.42.93-.93v-.14c0-.51-.42-.93-.93-.93z"/><path d="M30 11H8c-1.1 0-2 .9-2 2v13c0 .55.45 1 1 1s1-.45 1-1V14c0-.55.45-1 1-1h20c.55 0 1 .45 1 1v12c0 .55.45 1 1 1s1-.45 1-1V13c0-1.1-.9-2-2-2z"/></g></svg>';
                break;
            case 'block-contents':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><g><path d="M16 12H5c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V14c0-1.1-.9-2-2-2zm0 12H5V14h11v10zM21 14h13c.55 0 1-.45 1-1s-.45-1-1-1H21c-.55 0-1 .45-1 1s.45 1 1 1zM34 16H21c-.55 0-1 .45-1 1s.45 1 1 1h13c.55 0 1-.45 1-1s-.45-1-1-1zM34 20H21c-.55 0-1 .45-1 1s.45 1 1 1h13c.55 0 1-.45 1-1s-.45-1-1-1zM28 24h-7c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1z"/></g></svg>';
                break;
            case 'block-gallery':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><g><path d="M12.86 11.29H8c-.55 0-1 .45-1 1v4.86c0 .55.45 1 1 1h4.86c.55 0 1-.45 1-1v-4.86c0-.56-.45-1-1-1zM21.43 11.29h-4.86c-.55 0-1 .45-1 1v4.86c0 .55.45 1 1 1h4.86c.55 0 1-.45 1-1v-4.86c0-.56-.45-1-1-1zM30 11.29h-4.86c-.55 0-1 .45-1 1v4.86c0 .55.45 1 1 1H30c.55 0 1-.45 1-1v-4.86c0-.56-.45-1-1-1zM12.86 19.86H8c-.55 0-1 .45-1 1v4.86c0 .55.45 1 1 1h4.86c.55 0 1-.45 1-1v-4.86c0-.56-.45-1-1-1zM21.43 19.86h-4.86c-.55 0-1 .45-1 1v4.86c0 .55.45 1 1 1h4.86c.55 0 1-.45 1-1v-4.86c0-.56-.45-1-1-1zM30 19.86h-4.86c-.55 0-1 .45-1 1v4.86c0 .55.45 1 1 1H30c.55 0 1-.45 1-1v-4.86c0-.56-.45-1-1-1z"/></g></svg>';
                break;
            case 'block-text':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><g><path d="M8 14h22c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zM30 16H8c-.55 0-1 .45-1 1s.45 1 1 1h22c.55 0 1-.45 1-1s-.45-1-1-1zM30 20H8c-.55 0-1 .45-1 1s.45 1 1 1h22c.55 0 1-.45 1-1s-.45-1-1-1zM22 24H8c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"/></g></svg>';
                break;
            case 'block-image':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><g><path d="M29 10.5H9c-1.1 0-2 .9-2 2v13c0 1.1.9 2 2 2h20c1.1 0 2-.9 2-2v-13c0-1.1-.9-2-2-2zm0 15h-.59l-4.6-5.68a.989.989 0 0 0-.78-.37c-.29 0-.58.12-.78.37l-3.06 3.78-4.4-5.71a.995.995 0 0 0-1.58 0L9 23.35V12.5h20v13z"/><circle cx="20" cy="15.5" r="2"/></g></svg>';
                break;
            case 'block-video':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><path d="M31.61 13.14c-.5-1.99-1.43-2.75-3.14-3.03-.98-.14-5.71-.33-9.47-.33-3.76 0-8.49.19-9.47.33-1.71.27-2.64 1.04-3.14 3.03-.16.66-.39 4.32-.39 5.71v.31c0 1.39.23 5.04.4 5.71.49 1.98 1.43 2.75 3.14 3.02.98.15 5.72.33 9.48.33H19c3.76 0 8.49-.19 9.48-.33 1.71-.27 2.64-1.04 3.14-3.02.15-.67.38-4.32.38-5.72v-.31c0-1.38-.23-5.04-.39-5.7zm-15.73 9.19v-6.66l6.23 3.25-6.23 3.41z"></svg>';
                break;
            case 'block-dividers':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><g><path d="M7.5 11.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5zM9.59 11.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5zM11.68 11.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5zM13.77 11.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5zM15.86 11.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5zM17.95 11.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5zM20.05 11.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.23.5-.5.5zM22.14 11.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.23.5-.5.5zM24.23 11.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.23.5-.5.5zM26.32 11.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.23.5-.5.5zM28.41 11.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5zM30.5 11.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5z"/><g><path d="M9.5 16.5h-2c-.28 0-.5-.22-.5-.5s.22-.5.5-.5h2c.28 0 .5.22.5.5s-.22.5-.5.5zM14.75 16.5h-2c-.28 0-.5-.22-.5-.5s.22-.5.5-.5h2c.28 0 .5.22.5.5s-.22.5-.5.5zM20 16.5h-2c-.28 0-.5-.22-.5-.5s.22-.5.5-.5h2c.28 0 .5.22.5.5s-.22.5-.5.5zM25.25 16.5h-2c-.28 0-.5-.22-.5-.5s.22-.5.5-.5h2c.28 0 .5.22.5.5s-.22.5-.5.5zM30.5 16.5h-2c-.28 0-.5-.22-.5-.5s.22-.5.5-.5h2c.28 0 .5.22.5.5s-.22.5-.5.5z"/></g><path d="M30.5 21.5h-23c-.28 0-.5-.22-.5-.5s.22-.5.5-.5h23c.28 0 .5.22.5.5s-.22.5-.5.5zM30 27.5H8c-.55 0-1-.45-1-1s.45-1 1-1h22c.55 0 1 .45 1 1s-.45 1-1 1z"/></g></svg>';
                break;
            case 'block-contact':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><path d="M28.09 9.42c-.35.02-.69.07-1.03.14-2.32.42-4.17 2.2-4.69 4.5-.34 1.56 0 3.2.94 4.5l3.83 5.29c.47.62 1.35.74 1.96.27.02-.01.03-.03.05-.04.08-.07.16-.15.22-.23l3.83-5.29c.69-.96 1.05-2.11 1.05-3.29a6 6 0 0 0-6.15-5.85h-.01m.16 8c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m-1 8.83v1.17h-17v-8.91l7.87 6.44c.37.3.9.3 1.27 0l3.81-3.12-1.17-1.62-3.27 2.68-6.67-5.46h8.48c-.19-.65-.29-1.32-.3-2H10.26c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h17c1.1 0 2-.9 2-2v-1.16c-.65.22-1.35.22-2 0"/></svg>';
                break;
            case 'block-forum':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><path d="M34 15h-8v-3c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h2v4l4-4h5v1c0 .55.45 1 1 1h11l4 4v-4h2c.55 0 1-.45 1-1v-7c0-.55-.45-1-1-1zm-18 1v4h-5l-2.5 2.5V20H6c-.55 0-1-.45-1-1v-6c0-.55.45-1 1-1h17c.55 0 1 .45 1 1v2h-7c-.55 0-1 .45-1 1zm4.5 5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"></svg>';
                break;
            case 'block-latest':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><g><path d="M10.5 11.5C6.36 11.5 3 14.86 3 19s3.36 7.5 7.5 7.5S18 23.14 18 19s-3.36-7.5-7.5-7.5zm0 13C7.47 24.5 5 22.03 5 19s2.47-5.5 5.5-5.5S16 15.97 16 19s-2.47 5.5-5.5 5.5z"/><path d="M11 15.5c-.55 0-1 .45-1 1v2H8c-.55 0-1 .45-1 1s.45 1 1 1h3c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1zM21 15.5h13c.55 0 1-.45 1-1s-.45-1-1-1H21c-.55 0-1 .45-1 1s.45 1 1 1zM34 17.5H21c-.55 0-1 .45-1 1s.45 1 1 1h13c.55 0 1-.45 1-1s-.45-1-1-1zM28 21.5h-7c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1z"/></g></svg>';
                break;
            case 'block-review':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 38 38" width="38" height="38"><g><path d="m17.52 15.44-2.77-.4-1.24-2.51c-.21-.42-.81-.42-1.01 0l-1.24 2.51-2.77.4c-.46.07-.65.64-.31.96l2 1.95-.48 2.77c-.08.46.41.81.82.6l2.48-1.3 2.48 1.3c.41.22.9-.13.82-.6l-.47-2.76 2-1.95c.33-.33.15-.9-.31-.97zM29 16h-8c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1zM21 14h5c.55 0 1-.45 1-1s-.45-1-1-1h-5c-.55 0-1 .45-1 1s.45 1 1 1zM29 20h-8c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1z"/><path d="M31 7H7c-1.66 0-3 1.34-3 3v14c0 1.66 1.34 3 3 3h3v4l4-4h17c1.66 0 3-1.34 3-3V10c0-1.66-1.34-3-3-3zm1 17c0 .55-.45 1-1 1H13.17L12 26.17V25H7c-.55 0-1-.45-1-1V10c0-.55.45-1 1-1h24c.55 0 1 .45 1 1v14z"/></g></svg>';
                break;
            case 'block-sns':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><path d="M30.5 19c0-4.97-5.15-9-11.5-9S7.5 14.03 7.5 19s5.15 9 11.5 9c2.46 0 4.73-.61 6.6-1.63L30.5 28l-1.52-4.55c.96-1.31 1.52-2.83 1.52-4.45zm-15.28.25c-.07-.07-.12-.14-.18-.22-.33-.42-.54-.95-.54-1.53A2.5 2.5 0 0 1 17 15c.82 0 1.54.4 2 1.01A2.5 2.5 0 0 1 21 15a2.5 2.5 0 0 1 2.5 2.5c0 .58-.21 1.11-.54 1.53-.06.07-.11.15-.18.22l-.03.03L19 23l-3.75-3.72-.03-.03z"></svg>';
                break;
            case 'block-form':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><g><path d="M10 11H8c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zM30 11H14c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h16c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zM10 17H8c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zM30 17H14c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h16c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zM10 23H8c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zM30 23H14c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h16c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1z"/></g></svg>';
                break;
            case 'block-others':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><g><path d="M12 16H8c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1zM21 16h-4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1zM30 16h-4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1z"/></g></svg>';
                break;
            case 'block-sync':
                icon = '<svg viewBox="0 0 38 38" width="'+w+'" height="'+h+'"><path d="M21.43 15.14h-4.86c-.55 0-1-.45-1-1V9.29c0-.55.45-1 1-1h4.86c.55 0 1 .45 1 1v4.86c0 .55-.45.99-1 .99z"/><path d="M12.86 28.71H8c-.55 0-1-.45-1-1v-4.86c0-.55.45-1 1-1h4.86c.55 0 1 .45 1 1v4.86c0 .56-.45 1-1 1z"/><path d="M21.43 28.71h-4.86c-.55 0-1-.45-1-1v-4.86c0-.55.45-1 1-1h4.86c.55 0 1 .45 1 1v4.86c0 .56-.45 1-1 1z"/><path d="M30 28.71h-4.86c-.55 0-1-.45-1-1v-4.86c0-.55.45-1 1-1H30c.55 0 1 .45 1 1v4.86c0 .56-.45 1-1 1z"/><path d="M28.03 24h-1.06v-3.5c0-.81-.61-1.47-1.36-1.47H12.39c-.75 0-1.36.66-1.36 1.47V24H9.97v-3.5c0-1.39 1.08-2.53 2.42-2.53h13.22c1.33 0 2.42 1.13 2.42 2.53V24z"/><path d="M18.46 15h1.09v9h-1.09z"/></svg>';
                break;

            case 'storagebox':
                icon = '<svg viewBox="0 0 38 38" width="' + w + '" height="' + h + '"><path d="M30.2 16.5H29V15c0-1.66-1.34-3-3-3h-7.19a.75.75 0 0 1-.53-.22l-2.12-2.12c-.42-.42-1-.66-1.59-.66H11c-1.66 0-3 1.34-3 3v12c0 1.25.76 2.32 1.85 2.77.25.14.55.23.88.23h15.72c1.2 0 2.28-.72 2.76-1.82l2.65-6.17c.5-1.19-.37-2.51-1.66-2.51zm-19.2-6h3.57c.2 0 .39.08.53.22l2.12 2.12c.43.42.99.66 1.59.66H26c.83 0 1.5.67 1.5 1.5v1.5H14.48c-1.2 0-2.28.72-2.76 1.82L9.5 23.5V12c0-.83.67-1.5 1.5-1.5zm19.47 7.92-2.65 6.17c-.24.55-.78.91-1.38.91H11c-.17 0-.33-.04-.48-.1-.01-.01-.03-.02-.04-.04a.29.29 0 0 1-.03-.28l2.65-6.17c.24-.55.78-.91 1.38-.91H30.2c.13 0 .21.07.25.13.04.07.08.17.02.29z"/></svg>';
                break;

            case 'used':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 38 38" width="38" height="38"><path d="m29.61 22.03 1.22-2.6c.11-.23.16-.47.17-.7.02-.91-.64-1.74-1.64-1.74H28v-2a2 2 0 0 0-2-2h-7.33c-.43 0-.85-.14-1.2-.4l-2.93-2.2c-.35-.26-.77-.4-1.2-.4H9a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14c0 3.31 2.69 6 6 6s6-2.69 6-6c0-3.1-2.36-5.65-5.39-5.96zM9 23.78V12.99a1 1 0 0 1 1-.99h3.33l2.93 2.2c.69.52 1.54.8 2.4.8H25c.55 0 .99.45.99 1v1h-12.7c-.66 0-1.26.38-1.54.97L9 23.78zM23.35 26H10.16l3.31-7h15.41l-1.56 3.24A6.01 6.01 0 0 0 23.35 26zm9.36.8-3.82 3.82c-.2.2-.45.29-.71.29s-.51-.1-.71-.29l-2.18-2.18a.996.996 0 1 1 1.41-1.41l1.47 1.47 3.11-3.11c.39-.39 1.02-.39 1.41 0s.41 1.02.02 1.41z"/></svg>';
                break;

            case 'ch-sortable':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="' + w + '" height="' + h + '"><circle cx="5.5" cy="2.5" r="1.5"/><circle cx="10.5" cy="2.5" r="1.5"/><circle cx="10.5" cy="7.5" r="1.5"/><circle cx="5.5" cy="7.5" r="1.5"/><circle cx="5.5" cy="12.5" r="1.5"/><circle cx="10.5" cy="12.5" r="1.5"/></svg>';
                break;

            case 'input_x':
                icon = '<svg viewBox="0 0 12 12" width="' + w + '" height="' + h + '"><polygon points="12 0.71 11.29 0 6 5.29 0.71 0 0 0.71 5.29 6 0 11.29 0.71 12 6 6.71 11.29 12 12 11.29 6.71 6 "/></svg>';
                break;

            case 'select_arrow':
                icon = '<svg class="arrow" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="' + w + '" height="' + h + '"><path d="M12 17.24c-.12 0-.24-.05-.34-.14L2.14 7.57a.465.465 0 0 1 0-.67c.19-.19.49-.19.67 0L12 16.09l9.19-9.19c.19-.19.49-.19.67 0 .19.19.19.49 0 .67l-9.52 9.52c-.1.1-.22.15-.34.15z" /></svg>';
                break;

            case 'radio_active':
                icon = '<svg class="active" viewBox="0 0 18 18" width="' + w + '" height="' + h + '"><path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"/><circle cx="9" cy="9" r="6"/></svg>';
                break;

            case 'radio_default':
                icon = '<svg viewBox="0 0 18 18" width="' + w + '" height="' + h + '"><path d="M9 0C4.03 0 0 4.03 0 9c0 4.97 4.03 9 9 9s9-4.03 9-9C18 4.03 13.97 0 9 0zM9 17c-4.41 0-8-3.59-8-8 0-4.41 3.59-8 8-8s8 3.59 8 8C17 13.41 13.41 17 9 17z"/></svg>';
                break;
                
            case 'faq3_set' :
                    icon = '\
                            <svg class="plus" viewBox="0 0 16 16" width="16" height="16">\
                              <g><path d="M7.5 13.5v-5h-5v-1h5v-5h1v5h5v1h-5v5z"/><path d="M8 3v5h5-5v5V3m1-1H7v5H2v2h5v5h2V9h5V7H9V2z"/></g>\
                            </svg>\
                            <svg class="minus" viewBox="0 0 16 16" width="16" height="16">\
                              <g><path d="M2.5 7.5h11v1h-11z"/><path d="M14 7H2v2h12V7z"/></g>\
                            </svg>\
                    ';
                break;

            case 'design_change':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="' + w + '" height="' + h + '"><path d="m10.13 4.5-.67.66L8.4 6.22l1.06 1.06L13 3.75 9.46.21 8.4 1.28l1.06 1.06.67.66H5C2.79 3 1 4.79 1 7v5h1.5V7A2.5 2.5 0 0 1 5 4.5h5.13z"/><path d="M17.5 8v5a2.5 2.5 0 0 1-2.5 2.5H9.87l.66-.66 1.06-1.06-1.06-1.06L7 16.25l3.54 3.54 1.06-1.06-1.06-1.06-.67-.67H15c2.21 0 4-1.79 4-4V8h-1.5z"/></svg>';
                break;

            case 'design_change2':
                icon = '<svg viewBox="0 0 20 20" width="' + w + '" height="' + h + '"><path d="M10.13 4.5L9.46 5.16 8.4 6.22l1.06 1.06L13 3.75 9.46 0.21 8.4 1.28l1.06 1.06L10.13 3H5C2.79 3 1 4.79 1 7v5h1.5v-1.5V10 7c0-1.38 1.12-2.5 2.5-2.5h2.5H10.13z"/><path d="M17.5 8v1.5V10v3c0 1.38-1.12 2.5-2.5 2.5h-2.5H9.87l0.66-0.66 1.06-1.06 -1.06-1.06L7 16.25l3.54 3.54 1.06-1.06 -1.06-1.06L9.87 17H15c2.21 0 4-1.79 4-4V8H17.5z"/></svg>';
                break;

            case 'fixbtn_search04':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="m22.53 21.47-4.26-4.26A6.757 6.757 0 0 0 19.75 13c0-3.72-3.03-6.75-6.75-6.75S6.25 9.28 6.25 13s3.03 6.75 6.75 6.75c1.59 0 3.05-.56 4.21-1.48l4.26 4.26c.15.15.34.22.53.22s.38-.07.53-.22c.29-.29.29-.77 0-1.06zM13 18.25c-2.9 0-5.25-2.36-5.25-5.25S10.1 7.75 13 7.75s5.25 2.36 5.25 5.25-2.35 5.25-5.25 5.25z"/></svg>';
                break;

            case 'fixbtn_um_login_04':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="M18 5.25h-6C9.93 5.25 8.25 6.93 8.25 9v1c0 .41.34.75.75.75s.75-.34.75-.75V9c0-1.24 1.01-2.25 2.25-2.25h6c1.24 0 2.25 1.01 2.25 2.25v10c0 1.24-1.01 2.25-2.25 2.25h-6c-1.24 0-2.25-1.01-2.25-2.25v-1c0-.41-.34-.75-.75-.75s-.75.34-.75.75v1c0 2.07 1.68 3.75 3.75 3.75h6c2.07 0 3.75-1.68 3.75-3.75V9c0-2.07-1.68-3.75-3.75-3.75z"/><path d="M13.47 16.47c-.29.29-.29.77 0 1.06.15.15.34.22.53.22s.38-.07.53-.22l3-3c.29-.29.29-.77 0-1.06l-3-3c-.29-.29-.77-.29-1.06 0s-.29.77 0 1.06l1.72 1.72H5c-.41 0-.75.34-.75.75s.34.75.75.75h10.19l-1.72 1.72z"/></svg>';
                break;

            case 'fixbtn_um_mypage_04':
            case 'fixbtn_um04':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="M16.77 13.84A4.743 4.743 0 0 0 18.75 10c0-2.62-2.13-4.75-4.75-4.75S9.25 7.38 9.25 10c0 1.58.78 2.98 1.98 3.84C8.32 15.1 6.25 18.28 6.25 22c0 .41.34.75.75.75s.75-.34.75-.75c0-4 2.8-7.25 6.25-7.25S20.25 18 20.25 22c0 .41.34.75.75.75s.75-.34.75-.75c0-3.72-2.07-6.9-4.98-8.16zM10.75 10c0-1.79 1.46-3.25 3.25-3.25s3.25 1.46 3.25 3.25-1.46 3.25-3.25 3.25-3.25-1.46-3.25-3.25z"/></svg>';
                break;

            case 'fixbtn_cart04':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="M21 9.25h-2.33c-.36-2.26-2.31-4-4.67-4s-4.31 1.74-4.67 4H7c-.41 0-.75.34-.75.75v9c0 2.07 1.68 3.75 3.75 3.75h8c2.07 0 3.75-1.68 3.75-3.75v-9c0-.41-.34-.75-.75-.75zm-7-2.5c1.53 0 2.81 1.07 3.15 2.5h-6.31c.35-1.43 1.63-2.5 3.16-2.5zM20.25 19c0 1.24-1.01 2.25-2.25 2.25h-8c-1.24 0-2.25-1.01-2.25-2.25v-8.25h1.5V12c0 .41.34.75.75.75s.75-.34.75-.75v-1.25h6.5V12c0 .41.34.75.75.75s.75-.34.75-.75v-1.25h1.5V19z"/></svg>';
                break;

            case 'fixbtn_search05':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="m22.64 21.36-4.24-4.24c1-1.27 1.6-2.88 1.6-4.62C20 8.36 16.64 5 12.5 5S5 8.36 5 12.5 8.36 20 12.5 20c1.75 0 3.35-.6 4.62-1.6l4.24 4.24c.18.18.41.26.64.26s.46-.09.64-.26c.35-.35.35-.93 0-1.28zM12.5 18.2c-3.14 0-5.7-2.56-5.7-5.7s2.56-5.7 5.7-5.7 5.7 2.56 5.7 5.7-2.56 5.7-5.7 5.7z"/></svg>';
                break;

            case 'fixbtn_um_login05':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="M21 5.1H9c-.5 0-.9.4-.9.9v4c0 .5.4.9.9.9s.9-.4.9-.9V6.9h10.2v14.2H9.9V18c0-.5-.4-.9-.9-.9s-.9.4-.9.9v4c0 .5.4.9.9.9h12c.5 0 .9-.4.9-.9V6c0-.5-.4-.9-.9-.9z"/><path d="M13.36 16.36a.9.9 0 0 0 0 1.27c.18.18.41.26.64.26s.46-.09.64-.26l3-3a.9.9 0 0 0 0-1.27l-3-3c-.35-.35-.92-.35-1.27 0s-.35.92 0 1.27l1.46 1.46H5c-.5 0-.9.4-.9.9s.4.9.9.9h9.83l-1.47 1.47z"/></svg>';
                break;

            case 'fixbtn_um_mypage05':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="M14 5a9 9 0 1 0 .001 18.001A9 9 0 0 0 14 5zM9.81 19.84c.88-.56 2.32-1.04 4.19-1.04 1.88 0 3.32.48 4.2 1.04A7.166 7.166 0 0 1 14 21.2c-1.57 0-3.01-.51-4.19-1.36zm9.74-1.26C18.27 17.62 16.27 17 14 17s-4.28.62-5.55 1.58A7.17 7.17 0 0 1 6.8 14c0-3.97 3.23-7.2 7.2-7.2s7.2 3.23 7.2 7.2c0 1.74-.62 3.33-1.65 4.58z"/><path d="M14 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 6.2c-1.21 0-2.2-.99-2.2-2.2s.99-2.2 2.2-2.2 2.2.99 2.2 2.2-.99 2.2-2.2 2.2z"/></svg>';
                break;

            case 'fixbtn_cart05':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="M22.77 8.53A.91.91 0 0 0 22 8.1H9.56L8.8 6.6a.884.884 0 0 0-.8-.5H6c-.5 0-.9.4-.9.9s.4.9.9.9h1.44l3.52 7.03-1.71 2.57c-.18.28-.2.63-.04.92.15.3.46.48.79.48h11c.5 0 .9-.4.9-.9s-.4-.9-.9-.9h-9.32l.8-1.2H19c.34 0 .65-.19.8-.5l3-6c.14-.28.13-.61-.03-.87zm-4.33 5.57h-5.89l-2.1-4.2h10.09l-2.1 4.2z"/><circle cx="10.5" cy="21.5" r="1.5"/><circle cx="20.5" cy="21.5" r="1.5"/></svg>';
                break;

            case 'fixbtn_search06':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="M14 0C6.27 0 0 6.27 0 14s6.27 14 14 14 14-6.27 14-14S21.73 0 14 0zm6.46 20.46c-.13.13-.29.19-.46.19s-.33-.06-.46-.19l-3.38-3.38c-.93.73-2.09 1.17-3.36 1.17-3 0-5.45-2.45-5.45-5.45S9.8 7.35 12.8 7.35s5.45 2.45 5.45 5.45c0 1.27-.44 2.43-1.17 3.36l3.38 3.38c.25.25.25.67 0 .92z"/><circle cx="12.8" cy="12.8" r="4.15"/></svg>';
                break;

            case 'fixbtn_um_login06':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="28" height="28"><path d="M14 0C6.27 0 0 6.27 0 14s6.27 14 14 14 14-6.27 14-14S21.73 0 14 0zM6.35 14c0-.36.29-.65.65-.65h7.81l-1.23-1.23c-.25-.25-.25-.67 0-.92s.67-.25.92 0l2.34 2.34c.25.25.25.67 0 .92L14.5 16.8c-.13.13-.29.19-.46.19s-.33-.06-.46-.19a.658.658 0 0 1 0-.92l1.23-1.23H7c-.36 0-.65-.29-.65-.65zm13.8 3.91c0 1.65-1.34 2.99-2.99 2.99h-4.69c-1.65 0-2.99-1.34-2.99-2.99v-.78c0-.36.29-.65.65-.65s.65.29.65.65v.78c0 .93.76 1.69 1.69 1.69h4.69c.93 0 1.69-.76 1.69-1.69V10.1c0-.93-.76-1.69-1.69-1.69h-4.69c-.93 0-1.69.76-1.69 1.69v.78c0 .36-.29.65-.65.65s-.65-.29-.65-.65v-.78c0-1.65 1.34-2.99 2.99-2.99h4.69c1.65 0 2.99 1.34 2.99 2.99v7.81z"/></svg>';
                break;

            case 'fixbtn_um_mypage06':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="M16.56 10.79c0-1.41-1.15-2.56-2.56-2.56s-2.56 1.15-2.56 2.56 1.15 2.56 2.56 2.56 2.56-1.15 2.56-2.56z"/><path d="M14 0C6.27 0 0 6.27 0 14s6.27 14 14 14 14-6.27 14-14S21.73 0 14 0zm5.62 21.08c-.36 0-.65-.29-.65-.65 0-3.19-2.23-5.78-4.97-5.78s-4.97 2.59-4.97 5.78c0 .36-.29.65-.65.65s-.65-.29-.65-.65c0-2.98 1.64-5.53 3.96-6.57-.93-.71-1.54-1.81-1.54-3.07 0-2.13 1.73-3.87 3.86-3.87s3.86 1.73 3.86 3.87c0 1.26-.61 2.36-1.54 3.07 2.31 1.04 3.96 3.59 3.96 6.57-.01.36-.31.65-.67.65z"/></svg>';
                break;

            case 'fixbtn_cart06':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="M17.79 12.43c0 .36-.29.65-.65.65s-.65-.29-.65-.65v-.92h-4.98v.92c0 .36-.29.65-.65.65s-.65-.29-.65-.65v-.92H9.15v5.78c0 1.3 1.05 2.35 2.35 2.35h5c1.3 0 2.35-1.05 2.35-2.35v-5.78h-1.06v.92z"/><path d="M14 8.36c-1.15 0-2.11.78-2.4 1.84h4.79A2.48 2.48 0 0 0 14 8.36z"/><path d="M14 0C6.27 0 0 6.27 0 14s6.27 14 14 14 14-6.27 14-14S21.73 0 14 0zm6.15 17.29c0 2.01-1.64 3.65-3.65 3.65h-5c-2.01 0-3.65-1.64-3.65-3.65v-6.43c0-.36.29-.65.65-.65h1.77c.31-1.78 1.86-3.14 3.73-3.14s3.42 1.36 3.73 3.14h1.77c.36 0 .65.29.65.65v6.43z"/></svg>';
                break;

            case 'fixbtn_search07':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="m21 20-3.65-3.65c.84-1.06 1.35-2.4 1.35-3.86 0-3.42-2.78-6.2-6.2-6.2s-6.2 2.78-6.2 6.2 2.78 6.2 6.2 6.2c1.46 0 2.8-.51 3.86-1.35L20 21c.14.14.32.21.5.21s.36-.08.5-.21c.27-.28.27-.72 0-1zM7.7 12.5a4.801 4.801 0 0 1 9.6 0 4.801 4.801 0 0 1-9.6 0z"/></svg>';
                break;

            case 'fixbtn_um_login07':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="M20 6.3H10c-.39 0-.7.31-.7.7v4c0 .39.31.7.7.7s.7-.31.7-.7V7.7h8.6v12.6h-8.6V17c0-.39-.31-.7-.7-.7s-.7.31-.7.7v4c0 .39.31.7.7.7h10c.39 0 .7-.31.7-.7V7c0-.39-.31-.7-.7-.7z"/><path d="M13.5 16.5a.706.706 0 0 0 .5 1.2c.18 0 .36-.07.5-.21l3-3c.27-.27.27-.72 0-.99l-3-3c-.27-.27-.72-.27-.99 0s-.27.72 0 .99l1.81 1.8H8c-.39 0-.7.31-.7.7s.31.7.7.7h7.31L13.5 16.5z"/></svg>';
                break;

            case 'fixbtn_um_mypage07':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="M14.5 13.5c-3.5 0-7 2.5-7 5.5 0 1.5 2.86 2.5 7 2.5s7-1 7-2.5c0-3-3.5-5.5-7-5.5zm0 6.6c-3.6 0-5.31-.78-5.6-1.16.05-2.05 2.8-4.04 5.6-4.04s5.54 1.99 5.6 4.04c-.29.38-2 1.16-5.6 1.16z"/><path d="M14.5 13c1.93 0 3.5-1.57 3.5-3.5S16.43 6 14.5 6 11 7.57 11 9.5s1.57 3.5 3.5 3.5zm0-5.6a2.1 2.1 0 1 1 0 4.2 2.1 2.1 0 0 1 0-4.2z"/></svg>';
                break;

            case 'fixbtn_cart07':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="M19.99 9.89a.691.691 0 0 0-.69-.59h-1.62c-.11-1.67-1.48-3-3.18-3s-3.07 1.33-3.18 3H9.7c-.35 0-.64.25-.69.59l-1.7 11a.706.706 0 0 0 .69.81h13c.2 0 .4-.09.53-.24.13-.16.19-.36.16-.56l-1.7-11.01zM14.5 7.7c.92 0 1.68.7 1.78 1.6h-3.56c.1-.9.86-1.6 1.78-1.6zM8.82 20.3l1.48-9.6h1V12c0 .39.31.7.7.7s.7-.31.7-.7v-1.3h3.6V12c0 .39.31.7.7.7s.7-.31.7-.7v-1.3h1l1.48 9.6H8.82z"/></svg>';
                break;

            case 'fixbtn_search08':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="m20.85 20.15-4.13-4.13c.8-.95 1.28-2.18 1.28-3.52C18 9.47 15.53 7 12.5 7S7 9.47 7 12.5 9.47 18 12.5 18c1.34 0 2.56-.48 3.52-1.28l4.13 4.13a.485.485 0 0 0 .7 0c.2-.19.2-.51 0-.7zM8 12.5C8 10.02 10.02 8 12.5 8s4.5 2.02 4.5 4.5-2.02 4.5-4.5 4.5S8 14.98 8 12.5z"/></svg>';
                break;

            case 'fixbtn_um_login08':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="M20.5 7h-10c-.28 0-.5.22-.5.5v3c0 .28.22.5.5.5s.5-.22.5-.5V8h9v12h-9v-3.48c0-.28-.22-.5-.5-.5s-.5.22-.5.5v3.98c0 .28.22.5.5.5h10c.28 0 .5-.22.5-.5v-13c0-.28-.22-.5-.5-.5z"/><path d="M14.15 15.65c-.2.2-.2.51 0 .71a.485.485 0 0 0 .7 0l2.5-2.5c.2-.2.2-.51 0-.71l-2.5-2.5c-.2-.2-.51-.2-.71 0s-.2.51 0 .71L15.79 13H7.5c-.28 0-.5.22-.5.5s.22.5.5.5h8.29l-1.64 1.65z"/></svg>';
                break;

            case 'fixbtn_um_mypage08':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="M14 16c2.48 0 4.5-2.02 4.5-4.5S16.48 7 14 7s-4.5 2.02-4.5 4.5S11.52 16 14 16zm0-8c1.93 0 3.5 1.57 3.5 3.5S15.93 15 14 15s-3.5-1.57-3.5-3.5S12.07 8 14 8z"/><path d="M20.64 20.19C19.01 18.16 16.59 17 14 17s-5.01 1.16-6.64 3.19c-.17.21-.14.53.08.7.21.17.53.14.7-.08C9.58 19.03 11.71 18 14 18s4.42 1.03 5.85 2.81c.1.12.24.19.39.19.11 0 .22-.04.31-.11.22-.17.26-.49.09-.7z"/></svg>';
                break;

            case 'fixbtn_cart08':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="M21.62 12.01c-.27-.06-.54.1-.61.36L19.11 20H9.89l-1.91-7.62a.498.498 0 0 0-.61-.36c-.27.07-.43.34-.36.61l2 8c.06.21.26.37.49.37h10c.23 0 .43-.16.49-.38l2-8c.06-.27-.1-.54-.37-.61z"/><path d="M10.62 10.42c.25.11.55-.01.65-.27C11.82 8.84 13.09 8 14.5 8s2.68.84 3.23 2.15c.08.19.27.31.46.31.06 0 .13-.01.19-.04.25-.11.37-.4.27-.65C17.95 8.08 16.32 7 14.5 7s-3.45 1.08-4.15 2.76a.5.5 0 0 0 .27.66z"/></svg>';
                break;

            case 'fixbtn_cart09':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="M21.38 9.18A.465.465 0 0 0 21 9H9.31l-.32-1.6A.503.503 0 0 0 8.5 7h-2c-.28 0-.5.22-.5.5s.22.5.5.5h1.59l1.92 9.6c.05.23.25.4.49.4h9c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-8.59l-.2-1H20c.24 0 .45-.18.49-.42l1-6a.455.455 0 0 0-.11-.4zM19.58 15h-9.07l-1-5h10.9l-.83 5z"/><circle cx="11.5" cy="20" r="1"/><circle cx="18.5" cy="20" r="1"/></svg>';
                break;

            case 'fixbtn_search10':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="' + w + '" height="' + h + '"><path d="m21.35 20.65-3.77-3.77C18.46 15.83 19 14.48 19 13c0-3.31-2.69-6-6-6s-6 2.69-6 6 2.69 6 6 6c1.48 0 2.83-.54 3.87-1.42l3.77 3.77a.485.485 0 0 0 .7 0c.21-.19.21-.51.01-.7zM8 13c0-2.76 2.24-5 5-5s5 2.24 5 5-2.24 5-5 5-5-2.24-5-5z"/></svg>';
                break;

            case 'fixbtn_arrow01':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="' + w + '" height="' + h + '"><path d="M11.85 6.15c-.2-.2-.51-.2-.71 0L8 9.29 4.85 6.15c-.2-.2-.51-.2-.71 0s-.2.51 0 .71l3.5 3.5a.485.485 0 0 0 .7 0l3.5-3.5c.21-.2.21-.52.01-.71z"/></svg>';
                break;

            case 'fixbtn_lang05':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="' + w + '" height="' + h + '"><path d="M9 0a9 9 0 1 0 .001 18.001A9 9 0 0 0 9 0zm0 17c-.84 0-1.95-1.48-2.55-4h5.11c-.61 2.52-1.72 4-2.56 4zm-2.75-5C6.09 11.1 6 10.1 6 9s.09-2.1.25-3h5.51c.15.9.24 1.9.24 3s-.09 2.1-.25 3h-5.5zM9 1c.84 0 1.95 1.48 2.55 4h-5.1C7.05 2.48 8.16 1 9 1zm3.77 5h3.64c.38.93.59 1.94.59 3s-.21 2.07-.59 3h-3.64c.15-.94.23-1.95.23-3s-.08-2.06-.23-3zm3.15-1h-3.34c-.34-1.55-.88-2.84-1.53-3.73 2.07.55 3.81 1.91 4.87 3.73zM6.96 1.27C6.3 2.16 5.76 3.45 5.42 5H2.08a8.028 8.028 0 0 1 4.88-3.73zM1.59 6h3.64C5.08 6.94 5 7.95 5 9s.08 2.06.23 3H1.59C1.21 11.07 1 10.06 1 9s.21-2.07.59-3zm.49 7h3.34c.34 1.55.88 2.84 1.53 3.73A8.035 8.035 0 0 1 2.08 13zm8.96 3.73c.66-.88 1.19-2.18 1.53-3.73h3.34a7.98 7.98 0 0 1-4.87 3.73z"/></svg>';
                break;

            case 'fixbtn_arrow_right':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="' + w + '" height="' + h + '"><path d="M6.5 12a.47.47 0 0 1-.35-.15c-.2-.2-.2-.51 0-.71L9.29 8 6.15 4.85c-.2-.2-.2-.51 0-.71s.51-.2.71 0l3.5 3.5c.2.2.2.51 0 .71l-3.5 3.5c-.1.1-.23.15-.36.15z"/></svg>';
                break;

            case 'fixbtn_edit_pencil':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" width="' + w + '" height="' + h + '" xml:space="preserve"><path d="M22.88 7.12C22.13 6.37 21.14 6 20.15 6s-1.97.37-2.72 1.12l-.66.66-1.06 1.06-8.34 8.34c-.24.24-.37.56-.37.9v4.17c0 .42.22.74.76.74l4.18.01c.33 0 .64-.13.87-.36l8.35-8.35 1.06-1.06.66-.66a3.881 3.881 0 0 0 0-5.45zM11.8 21.45l-3.25-.01V18.2l8.26-8.26 3.25 3.25-8.26 8.26zm9.98-9.98-.66.66-3.25-3.25.66-.66c.43-.43 1.01-.67 1.63-.67s1.2.24 1.63.67c.89.9.89 2.36-.01 3.25z"/></svg>';
                break;

            case 'block-config':
                icon = '<svg viewBox="0 0 19 19" width="' + w + '" height="' + h + '"><path d="M17.16 8.16l1.41-1.51c-0.2-0.65-0.48-1.28-0.84-1.9 -0.35-0.61-0.77-1.17-1.23-1.67l-2.02 0.46c-0.7-0.58-1.48-1.03-2.32-1.34l-0.61-1.97C10.9 0.08 10.21 0 9.5 0 8.79 0 8.1 0.08 7.44 0.22L6.83 2.2h0C5.98 2.51 5.19 2.97 4.51 3.54L2.5 3.08c-0.46 0.5-0.87 1.06-1.23 1.67S0.64 6 0.44 6.65l1.4 1.52c-0.16 0.89-0.15 1.8 0 2.68l-1.41 1.51c0.2 0.65 0.48 1.28 0.84 1.9s0.77 1.17 1.23 1.67l2.02-0.46c0.7 0.58 1.48 1.03 2.32 1.34l0.61 1.97v0C8.1 18.92 8.79 19 9.5 19c0.71 0 1.4-0.08 2.06-0.22l0.61-1.97c0.85-0.31 1.63-0.77 2.32-1.34l2.01 0.46c0.46-0.5 0.87-1.06 1.23-1.67 0.35-0.61 0.63-1.25 0.84-1.9l-1.4-1.52C17.31 9.94 17.31 9.04 17.16 8.16zM9.5 15.5c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6S12.81 15.5 9.5 15.5z"/></svg>';
                break;

            case 'arrow_next':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="' + w + '" height="' + h + '"><path d="M6.5 12a.47.47 0 0 1-.35-.15c-.2-.2-.2-.51 0-.71L9.29 8 6.15 4.85c-.2-.2-.2-.51 0-.71s.51-.2.71 0l3.5 3.5c.2.2.2.51 0 .71l-3.5 3.5c-.1.1-.23.15-.36.15z"/></svg>';
                break;

            case 'clslick_arrow1':
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="'+w+'" height="'+h+'"><g><g><path d="m16.567 28.021 12.728-12.728.707.707-12.728 12.728z" class="st80"/><path d="M29.29 16 17.27 28.02z" class="st81"/></g><g><path d="m30 16.002-.707.707L16.565 3.98l.707-.707z" class="st80"/><path d="M29.29 16 17.27 3.98z" class="st81"/></g><g><path d="M29 16.498H2v-1h27z" class="st80"/><path d="M28.5 15.998h-26z" class="st81"/></g></g></svg>';
                break;

            case 'sync_arrow1':
                    icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44" width="'+w+'" height="'+h+'" xml:space="preserve"><path d="M22 3.2c10.37 0 18.8 8.43 18.8 18.8S32.37 40.8 22 40.8 3.2 32.37 3.2 22 11.63 3.2 22 3.2M22 2C10.95 2 2 10.95 2 22s8.95 20 20 20 20-8.95 20-20S33.05 2 22 2z"/><path d="m18.888 14.93 7.07 7.07-.848.85-7.07-7.072z"/><path d="m18.039 28.222 7.071-7.071.849.848-7.071 7.071z"/></svg>';
                break;

            case 'sync_arrow2':
                    icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="'+w+'" height="'+h+'" xml:space="preserve"><path d="M6.5 14a.47.47 0 0 1-.35-.15c-.2-.2-.2-.51 0-.71L11.29 8 6.15 2.85c-.2-.2-.2-.51 0-.71s.51-.2.71 0l5.5 5.5c.2.2.2.51 0 .71l-5.5 5.5c-.1.1-.23.15-.36.15z"/></svg>';
                break;

            case 'sync_arrow3': 
                    icon = '<svg viewBox="0 0 44 44" width="'+w+'" height="'+h+'"><path d="M30 43c-.29 0-.58-.13-.78-.38l-16-20c-.29-.37-.29-.88 0-1.25l16-20c.35-.43.97-.5 1.41-.16.43.35.5.97.16 1.41L15.28 22l15.5 19.37c.34.43.27 1.06-.16 1.41-.18.15-.4.22-.62.22z"></path></svg>';
                break;

            case 'sync_arrow4_left': 
                    icon = '<svg viewBox="0 0 24 24" width="'+w+'" height="'+w+'"><path d="m8.44 12 8.72-8.72c.29-.29.29-.77 0-1.06s-.77-.29-1.06 0l-9.26 9.25c-.29.29-.29.77 0 1.06l9.25 9.25c.15.15.34.22.53.22s.38-.07.53-.22c.29-.29.29-.77 0-1.06L8.43 12Z"/></svg>';
                break;
            case 'sync_arrow4_right': 
                    icon = '<svg viewBox="0 0 24 24" width="'+w+'" height="'+w+'"><path d="M17.16 11.47 7.91 2.22c-.29-.29-.77-.29-1.06 0s-.29.77 0 1.06L15.57 12l-8.72 8.72c-.29.29-.29.77 0 1.06.15.15.34.22.53.22s.38-.07.53-.22l9.25-9.25c.29-.29.29-.77 0-1.06Z"/></svg>';
                break;

            case 'sync_arrow5_left': 
                    icon = '<svg viewBox="0 0 18 18" width="'+w+'" height="'+w+'"><path d="m6.94 9 5.72-5.72c.29-.29.29-.77 0-1.06s-.77-.29-1.06 0L5.35 8.47a.75.75 0 0 0 0 1.06l6.25 6.25c.15.15.34.22.53.22s.38-.07.53-.22c.29-.29.29-.77 0-1.06L6.94 9Z"/></svg>';
                break;
            case 'sync_arrow5_right': 
                    icon = '<svg viewBox="0 0 18 18" width="'+w+'" height="'+w+'"><path d="M12.66 8.47 6.41 2.22c-.29-.29-.77-.29-1.06 0s-.29.77 0 1.06L11.07 9l-5.72 5.72c-.29.29-.29.77 0 1.06.15.15.34.22.53.22s.38-.07.53-.22l6.25-6.25a.75.75 0 0 0 0-1.06Z"/></svg>';
                break;

            case 'sync_arrow6_left': 
                    icon = '<svg viewBox="0 0 62 62" width="'+w+'" height="'+w+'"><path d="M17.46 31 45.6 2.85c.2-.2.2-.51 0-.71s-.51-.2-.71 0l-28.5 28.5c-.09.09-.15.22-.15.35s.05.26.15.35l28.5 28.5a.485.485 0 0 0 .7 0c.2-.2.2-.51 0-.71L17.44 30.98Z"/></svg>';
                break;
            case 'sync_arrow6_right': 
                    icon = '<svg viewBox="0 0 62 62" width="'+w+'" height="'+w+'"><path d="M45.6 30.65 17.1 2.15c-.2-.2-.51-.2-.71 0s-.2.51 0 .71l28.15 28.15-28.15 28.15c-.2.2-.2.51 0 .71a.485.485 0 0 0 .7 0l28.5-28.5c.09-.09.15-.22.15-.35s-.05-.26-.15-.35Z"/></svg>';
                break;

            case 'forum_arrow1_1': 
                    icon = '<svg viewBox="0 0 12 12" width="'+w+'" height="'+h+'"><path d="m4.85 2.15-.7.7L7.79 6.5l-3.64 3.65.7.7L9.21 6.5z"/></svg>';
                break;

            case 'forum_arrow1_2': 
                    icon = '<svg viewBox="0 0 12 12" width="'+w+'" height="'+h+'"><g><path d="m2.35 1.65-.7.7L5.29 6 1.65 9.65l.7.7L6.71 6z"/><path d="m6.35 1.65-.7.7L9.29 6 5.65 9.65l.7.7L10.71 6z" /></g></svg>';
                break;

            case 'forum_arrow2_1': 
                    icon = '<svg viewBox="0 0 12 12" width="'+w+'" height="'+h+'"><path d="M4 2v8l4-4z"/></svg>';
                break;

            case 'forum_arrow2_2': 
                    icon = '<svg viewBox="0 0 12 12" width="'+w+'" height="'+h+'"><g><path d="m1.5 10 4-4-4-4zM6.5 2v8l4-4z"/></g></svg>';
                break;
            
            case 'block-menu_v2': 
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 38 38" width="'+w+'" height="'+h+'"><path d="M33 6H5C3.34 6 2 7.34 2 9v20c0 1.66 1.34 3 3 3h28c1.66 0 3-1.34 3-3V9c0-1.66-1.34-3-3-3Zm1 23c0 .55-.45 1-1 1H5c-.55 0-1-.45-1-1V17h30v12Z" /></svg>';
                break;

            case 'block-sidebar_v2': 
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 38 38" width="'+w+'" height="'+h+'"><path d="M33 6H5C3.34 6 2 7.34 2 9v20c0 1.66 1.34 3 3 3h28c1.66 0 3-1.34 3-3V9c0-1.66-1.34-3-3-3Zm1 23c0 .55-.45 1-1 1H12V8h21c.55 0 1 .45 1 1v20Z"/></svg>';
                break;
            
            case 'block-moption_v2': 
                icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 38 38" width="'+w+'" height="'+h+'"><path d="M33 6H5C3.34 6 2 7.34 2 9v20c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V15h15c1.66 0 3-1.34 3-3V9c0-1.66-1.34-3-3-3Zm1 6c0 .55-.45 1-1 1H18V8h15c.55 0 1 .45 1 1v3Z"/></svg>';
                break;

            default:
                break;
        }

        if (wrap) {
            return '<span class="' + add_class + ' cl-icon">' + icon + '</span>';
        } else {
            return icon;
        }
    }

    var getEventObject = function(type, price, quantity, step, explan, lang, href) {
        var prod_position = {
                "LK": 0,
                "BS": 0,
                "BN": 1,
                "SM": 2
            },
            prod_type = {
                "LK": $.lang[LANG]['pay.plan.LK.name'],
                "BS": $.lang[LANG]['pay.plan.BS.name'],
                "BN": $.lang[LANG]['pay.plan.BN.name'],
                "SM": $.lang[LANG]['pay.plan.SM.name']
            },
            prod_brand = (lang == 'ko') ? '크리에이터링크' : 'creatorlink',
            prod_currency = (lang == 'ko') ? 'KRW' : 'USD',
            prod_action = '',
            prod_step = 1;

        if (explan.length == 0) {
            prod_action = '신규결제';
        } else if (explan == type) {
            prod_action = '요금제 연장';
        } else if ((explan.length && type.length) && (explan != type)) {
            prod_action = '요금제 변경';
        }

        var charge = price + (price * 0.1);
        return {
            'name': prod_type[type],
            'price': charge,
            'brand': prod_brand,
            'category': prod_action,
            'variant': quantity,
            'position': prod_position[type],
            'explan': explan,
            'plan': type,
            'step': step,
            'currency': prod_currency,
            'href': href
        }
    }


    /* 동영상블럭 갤러리타입 **************************************/
    var getGalleryVideoType = function(val) {
        var videoTypeArray = ['youtube', 'vimeo', 'soundcloud', 'youtu.be'],
            videoType = '';

        $.each(videoTypeArray, function(i, v) {
            if (val.indexOf(v) > -1) {
                videoType = v;
            }
        });

        return videoType;
    }

    var getGalleryVideoData = function(videoUrl) {
        var videoId = '',
            videoThumb = '',
            videoType = '',
            check_video = false;

        videoType = getGalleryVideoType(videoUrl);

        switch (videoType) {
            case 'youtube':
            case 'youtu.be':
                var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/,
                    match = videoUrl.match(regExp);

                if (match && match[2].length === 11) {
                    var videoId = match[2],
                        videoThumb = '//img.youtube.com/vi/' + videoId + '/0.jpg',
                        aType = "text/html",
                        src = '//www.youtube.com/embed/' + videoId;

                    check_video = true;
                    src = src.replace('watch?v=', 'v/');
                }

                break;

            case 'vimeo':
                var regExp = /\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/,
                    match = videoUrl.match(regExp);

                if (match && match[3].length > 0) {
                    var videoId = match[3],
                        aType = "text/html",
                        src = '//player.vimeo.com/video/' + videoId;

                    var vidx = ($('#el-blockConfig .bg-video-wrap .input-group.active').length > 0) ? $('#el-blockConfig .bg-video-wrap .input-group.active').attr('id').replace(/[^0-9]/gi, '') : 0,
                        vgrid = $('.'+selectEL).find('.grid').eq(vidx),
                        w = (vidx && vgrid.length > 0) ? vgrid.width() + 100 : 1024,
                        h = (vidx && vgrid.length > 0) ? vgrid.height() + 100 : 1024,
                        size = (w > h) ? '&height='+h : '&width='+w;
                    $.getJSON('https://vimeo.com/api/oembed.json?url=https://player.vimeo.com/video/' + videoId + size, function(data) {
                        if (typeof data.thumbnail_url != 'undefined' && data.thumbnail_url) {
                            videoThumb = data.thumbnail_url;
                        }
                    });

                    check_video = true;
                }


                break;

            case 'soundcloud':
                var videoId = '',
                    aType = "";

                videoUrl = (videoUrl.indexOf('https') > -1) ? videoUrl : 'https://' + videoUrl;

                $.getJSON('https://soundcloud.com/oembed?format=json&url=' + videoUrl, function(data) {
                    if (typeof data.html == 'undefined') { return; }
                    $video = $(data.html);
                    src = $video.prop('src');
                    videoThumb = data.thumbnail_url;
                    check_video = true;
                }).fail(function(response) {
                    console.log(response);
                    return;
                });

                break;
            default:

                break;
        }

        var videoData = {
            check_video: check_video,
            videoType: videoType,
            videoId: videoId,
            videoUrl: videoUrl,
            aType: aType,
            poster: videoThumb,
            iframe_src: src
        }

        return videoData;
    }

    // $('.video-content > svg').live('click', function() {
    //     if($(this).parents('.el_viewblock').length>0) return false;

    //     $.loadingOn($(this).parents('.video-content')); 

    //     var vd_src = $(this).parents('.video-content').attr('data-url'),
    //         vd_height = $(this).parents('.video-content').css('height').replace('px',''),
    //         vd_data = getGalleryVideoData(vd_src),
    //         vd_mode = $(this).parents('.element').attr('data-mode'),
    //         vd_id = $(this).parents('.element').attr('data-id'),
    //         vd_mute = (vd_src.indexOf('vimeo')>-1) ? '&muted=1' : '&mute=1',
    //         vd_content_new = '<iframe class="video-iframe hide" height="'+vd_height+'" src="'+vd_data.iframe_src+'?wmode=transparent&amp;autoplay=1'+vd_mute+'" allow="autoplay""></iframe>';

    //     if(vd_mode!='zoom') {
    //         //if(isThumnailv_type) {
    //             $(this).parents('.video-content').append(vd_content_new);
    //             $(this).parents('.video-content').find('.ly-img').remove();
    //             $(this).remove();

    //             setTimeout(function(){
    //                 $('.video-iframe').removeClass('hide');
    //                 $('.dsgn-body').fitVids();
    //                 $.loadingOFF();

    //             },300);
    //         //}
    //     }   
    // });

    function setSnsJoinConvertScript(snstype) {
        console.log('setSnsJoinConvertScript');
        snstype = (typeof snstype != 'undefined') ? snstype : 'naver';
        var scriptStr = '\
            <script type="text/javascript" src="https://wcs.naver.net/wcslog.js"></script>\
            <script type="text/javascript" class="snsjoin_convert">\
            if(typeof(wcs) != "undefined") {\
                if(!wcs_add) var wcs_add={};\
                wcs_add["wa"]="s_48e853d9cc7e";\
                var _nasa={};\
                _nasa["cnv"] = wcs.cnv("2","1");\
                wcs_do(_nasa);\
                console.log("naver 전환");\
            }\
            </script>\
            <script type="text/javascript" charset="UTF-8" src="//t1.daumcdn.net/kas/static/kp.js"></script>\
            <script type="text/javascript" class="snsjoin_convert">\
                kakaoPixel("6608645775572775786").pageView();\
                kakaoPixel("6608645775572775786").completeRegistration();\
                console.log("kakao 전환");\
            </script>\
            <script type="text/javascript" class="snsjoin_convert">\
            !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?\
                n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;\
                n.push=n;n.loaded=!0;n.version="2.0";n.queue=[];t=b.createElement(e);t.async=!0;\
                t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,\
                document,"script","https://connect.facebook.net/en_US/fbevents.js");\
                fbq("init", "256796588050321");\
                fbq("track", "PageView");\
                fbq("trac", "CompleteRegistration");\
                console.log("facebook 전환");\
            </script>\
        ';

        switch (snstype) {
            case 'naver':
                scriptStr += '\
                    <script class="snsjoin_convert" async src="https://www.googletagmanager.com/gtag/js?id=G-JT83EQYG01"></script>\
                    <script class="snsjoin_convert">\
                    window.dataLayer = window.dataLayer || [];\
                        function gtag(){dataLayer.push(arguments);}\
                        gtag("js", new Date());\
                        gtag("config", "G-JT83EQYG01");\
                        gtag("event", "네이버_소셜_회원가입_완료", {\
                        "Social_Button" : "네이버 아이콘",\
                    });\
                    </script>\
                ';
                break;

            case 'kakao':
                scriptStr += '\
                <script class="snsjoin_convert" async src="https://www.googletagmanager.com/gtag/js?id=G-JT83EQYG01"></script>\
                <script class="snsjoin_convert">\
                    window.dataLayer = window.dataLayer || [];\
                    function gtag(){dataLayer.push(arguments);}\
                    gtag("js", new Date());\
                    gtag("config", "G-JT83EQYG01");\
                    gtag("event", "카카오_소셜_회원가입_완료", {\
                    "Social_Button" : "카카오 아이콘",\
                    });\
                </script>\
                ';
                break;
                
            case 'fb':
                scriptStr += '\
                <script class="snsjoin_convert" async src="https://www.googletagmanager.com/gtag/js?id=G-JT83EQYG01"></script>\
                <script class="snsjoin_convert">\
                console.log(\'sss\');\
                window.dataLayer = window.dataLayer || [];\
                    function gtag(){dataLayer.push(arguments);}\
                    gtag("js", new Date());\
                    gtag("config", "G-JT83EQYG01");\
                    gtag("event", "페이스북_소셜_회원가입_완료", {\
                    "Social_Button" : "페이스북 아이콘",\
                });\
                ';
            break;

            default:
                break;
        }
        $('.snsjoin_convert').remove();
        $('body').append(scriptStr);
    }

    function kakaoLogin() {
        if(window.Kakao) {
            const kakao = window.Kakao;
            if(!kakao.isInitialized()) {
                kakao.init('85677ffc26b1bca1130b866859031c06');
            }

            Kakao.Auth.authorize({
                redirectUri: document.location.protocol + '//' + getServiceHost() + '/oauth_kakao',
                scope: 'account_email,profile',
            });
        }
    }

    /*
    function kakaoLogin(ip) {
        Kakao.Auth.login({
            success: function(response) {
                //사용자 정보 가져오기
                Kakao.API.request({
                    url: '/v2/user/me', //계정 정보를 가져오는 request url
                    success: function(data) {
                        var user = data.kakao_account, //카카오 계정 정보
                            accessToken = Kakao.Auth.getAccessToken();

                        Kakao.Auth.setAccessToken(accessToken);

                        var checkObj = { userinfo: data, id: user.email, snsType: 'kakao', ip: ip };
                        if (typeof $.cookie('land_join') != 'undefined' && $.cookie('land_join')) {
                            checkObj['land_join'] = $.cookie('land_join');
                            $.removeCookie('land_join', { path: '/' });
                        }
                        $.post('/template/snsloginCheck', checkObj, function(data) {
                            if (data.login) {
                                if (data.join) setSnsJoinConvertScript(); //sns 회원가입 전환 스크립트 

                                if (typeof data.url != 'undefined' && data.url) location.href = data.url;
                                else location.replace('/');
                                self.close();
                            } else {
                                alert(data.msg);
                                opener.location.reload();
                                self.close();
                            }
                        }, 'json');
                    },
                    fail: function(error) {
                        console.log('카카오톡과 연결이 완료되지 않았습니다.');
                    },
                })
            },
            fail: function(error) {
                console.log('카카오톡과 연결 실패하였습니다.');
            },
        })
    }
    */

    function snsLogout() {
        var sid = (typeof SID != 'undefined' && SID) ? SID : '';

        if(window.Kakao) {
            Kakao.init('85677ffc26b1bca1130b866859031c06');
            Kakao.isInitialized();
    
            if (Kakao.Auth.getAccessToken()) {
                Kakao.Auth.logout()
                    .then(function(response) {
                        // console.log(Kakao.Auth.getAccessToken());
                    })
                    .catch(function(error) {
                        // console.log('Not logged in.');
                    });
            }
        }

        window.fbAsyncInit = function() {
            FB.init({
                version : 'v19.0',
                appId : '590704662264509',		// [ creatorlink ] Facebook App
                // appId : '398865637129551',	// [ creatorlinkdev ] Facebook Test App
                status	: true,		//check login status
                cookie	: true,
                xfbml	: true
            });

            FB.getLoginStatus(function(response) {
                if (response.status == 'connected') {
                    FB.logout(function(response) {
                        FB.Auth.setAuthResponse(null, 'unknown');
                        console.log('logged out~');
                    });
                }
            });
        };

        (function(d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) { return; }
            js = d.createElement(s);
            js.id = id;
            js.async = true;
            js.src = 'https://connect.facebook.net/en_KR/all.js';
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));

        if (typeof sid != 'undefined' && sid) {
            if ($.cookie('domainSet-next-' + sid) !== undefined) $.removeCookie('domainSet-next-' + sid, { path: '/' });
        }

        location.href = '/member/login/out';
    }

    function disableScrolling() {
        var x = window.scrollX;
        var y = window.scrollY;
        window.onscroll = function() { window.scrollTo(x, y); };
    }

    function enableScrolling() {
        window.onscroll = function() {};
    }

    var hexToRgba = function(hex) {
        if (hex.lastIndexOf('#') > -1) {
            hex = hex.replace(/#/, '0x');
        } else {
            hex = '0x' + hex;
        }
        var r = hex >> 16;
        var g = (hex & 0x00FF00) >> 8;
        var b = hex & 0x0000FF;
        return rgb = { r: r, g: g, b: b };
    }

    var rgbaToOpacity = function(rgba) {
        if (typeof rgba == 'undefined') rgba = 'rgba(255,255,255,1)';
        //rgba = rgba.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+(\.\d{1,2}))[\s+]?/i);
        var r = [],
            rgba = rgba.replace(/^(rgb|rgba)\(/, '').replace(/\)$/, '').replace(/\s/g, '').split(',');

        r.r = rgba[0], r.g = rgba[1], r.b = rgba[2], r.a = rgba[3];
        return r;
    }

    var setGalleryProjectCss = function(parent, elcss) {
        var pr_css = CSSJSON.toJSON(elcss)['children'],
            galProjectCssStr = '',
            pr_settings = (typeof parent.settings != 'undefined' && parent.settings) ? $.parseJSON(parent.settings) : {},
            pr_gallery_colorSet = (typeof pr_settings.gallery_color != 'undefined' && pr_settings.gallery_color) ? pr_settings.gallery_color : '';

        $('body').find('.galProjectCss').remove();

        var isElview = ($('.elviewcss').length > 0) ? true : false;
        if (isElview) $('.elviewcss').after('<style class="galProjectCss"></style>');
        else $('#dsgn-body').after('<style class="galProjectCss"></style>');

        var body_selector = (isElview) ? 'body' : 'body > .dsgn-body';
        if (pr_css.hasOwnProperty('.' + parent.element + ' .galProjectBg')) {
            pr_css = pr_css['.' + parent.element + ' .galProjectBg']['attributes'];
            pr_Array = {};
            pr_Array = setGalleryProjectBgCss(body_selector, pr_css);

            galProjectCssStr += '\
                ' + body_selector + ' {\
                    background-color: ' + pr_Array.pr_bgColor + ';\
                    background-image: ' + pr_Array.pr_bgImage + ';\
                    background-position: ' + pr_Array.pr_bgPosition + ';\
                    background-repeat: ' + pr_Array.pr_bgRepeat + ';\
                    background-size: ' + pr_Array.pr_bgSize + ';\
                    height:auto;\
                    /*overflow: auto;\
                    overflow-x: hidden;*/\
                }\
            ';
        }

        if (pr_gallery_colorSet) {
            var pr_rgba = hexToRgba(pr_gallery_colorSet);
            $(body_selector).attr('data-gcolor', pr_gallery_colorSet);
            galProjectCssStr += body_selector + '[data-gcolor="' + pr_gallery_colorSet + '"] .element .p_nsvg .btn-box .active svg,\n\ ' + body_selector + '[data-gcolor="' + pr_gallery_colorSet + '"] .element .data-page-back,\n\
                                ' + body_selector + '[data-gcolor="' + pr_gallery_colorSet + '"] .element .data-page-back svg, ' + body_selector + '[data-gcolor="' + pr_gallery_colorSet + '"] .element .data-page-back span,\n\
                                ' + body_selector + '[data-gcolor="' + pr_gallery_colorSet + '"] .element .btn-box .active, ' + body_selector + '[data-gcolor="' + pr_gallery_colorSet + '"] .element .btn-box .active .btn-nav {\n\ fill: rgba(' + pr_rgba.r + ',' + pr_rgba.g + ',' + pr_rgba.b + ',1);\n\ color: rgba(' + pr_rgba.r + ',' + pr_rgba.g + ',' + pr_rgba.b + ',1);\n\}\n\
                                ' + body_selector + '[data-gcolor="' + pr_gallery_colorSet + '"] .element .btn-box svg,\n\
                                ' + body_selector + '[data-gcolor="' + pr_gallery_colorSet + '"] .element .btn-box .btn-nav-svg,\n\
                                ' + body_selector + '[data-gcolor="' + pr_gallery_colorSet + '"] .element .btn-box .btn-nav {\n\ fill: rgba(' + pr_rgba.r + ',' + pr_rgba.g + ',' + pr_rgba.b + ',0.4);\n\ color: rgba(' + pr_rgba.r + ',' + pr_rgba.g + ',' + pr_rgba.b + ',0.4);\n\ }\n';
        }

        $('.galProjectCss').append(galProjectCssStr);
    }

    var setGalleryProjectBgCss = function(pr_selector, pr_css) {
        var dsgnBody_bgColor = (typeof $(pr_selector).css('background-color') != 'undefined') ? $(pr_selector).css('background-color') : '',
            dsgnBody_bgImage = (typeof $(pr_selector).css('background-image') != 'undefined') ? $(pr_selector).css('background-image') : '',
            dsgnBody_bgPosition = (typeof $(pr_selector).css('background-position') != 'undefined') ? $(pr_selector).css('background-position') : '',
            dsgnBody_bgRepeat = (typeof $(pr_selector).css('background-repeat') != 'undefined') ? $(pr_selector).css('background-repeat') : '',
            dsgnBody_bgSize = (typeof $(pr_selector).css('background-size') != 'undefined') ? $(pr_selector).css('background-size') : '',
            pr_Array = {};

        pr_Array = {
            pr_bgColor: (typeof pr_css['background-color'] != 'undefined') ? pr_css['background-color'] : '',
            pr_bgImage: (typeof pr_css['background-image'] != 'undefined') ? pr_css['background-image'] : ((typeof pr_css['background-color'] != 'undefined' && pr_css['background-color']) ? 'none' : ''),
            pr_bgPosition: (typeof pr_css['background-position'] != 'undefined') ? pr_css['background-position'] : '',
            pr_bgRepeat: (typeof pr_css['background-repeat'] != 'undefined') ? pr_css['background-repeat'] : '',
            pr_bgSize: (typeof pr_css['background-size'] != 'undefined') ? pr_css['background-size'] : '',
        }

        var prbg_Array = getRgbaValArray(pr_Array['pr_bgColor']);

        if ((pr_Array.pr_bgColor == 'transparent' && pr_Array.pr_bgImage == 'none') || (prbg_Array['rgba']['a'] == '0' && pr_Array.pr_bgImage == 'none')) {
            pr_Array['pr_bgColor'] = dsgnBody_bgColor;
            pr_Array['pr_bgImage'] = dsgnBody_bgImage;
            pr_Array['pr_bgPosition'] = dsgnBody_bgPosition;
            pr_Array['pr_bgRepeat'] = dsgnBody_bgRepeat;
            pr_Array['pr_bgSize'] = dsgnBody_bgSize;
        }

        return pr_Array;
    }

    var onlyUnique = function(value, index, self) {
        return self.indexOf(value) === index;
    }

    var arrayDuplicates = function(arr) {
        var duplicates = {};
        for (var i = 0; i < arr.length; i++) {
            if (duplicates.hasOwnProperty(arr[i])) {
                duplicates[arr[i]].push(i);
            } else if (arr.lastIndexOf(arr[i]) !== i) {
                duplicates[arr[i]] = [i];
            }
        }

        return duplicates;
    }

    var arrayLastItem = function(arr) {
        if (Array.isArray(arr))
            return arr.pop();
        else return "";
    }

    var getLang = function(selectorTag, SID) {
        var ch_lang = '';
        if (typeof selectorTag.attr('data-blocklang') != 'undefined') { ch_lang = selectorTag.attr('data-blocklang'); } else {
            if ($('.menu-' + SID + ' .siteLANG').length > 0)
                ch_lang = ($('.menu-' + SID + ' .siteLANG').find('li.active a').attr('data-code') == 'ko') ? 'ko' : 'en';
            else ch_lang = LANG;
        }

        return ch_lang;
    }

    function templateModeChange(e) {
        $('.template-mode').removeClass('active');
        $(e).addClass('active');
        $('#template-site .modal-dialog .modal-content').find('.load-template').css('display', 'block');
        $.processON();

        // var widthSize = ($(e).attr('class').indexOf('desktop') > -1) ? '100%' : '100%';
        // widthSize = ($(e).attr('class').indexOf('tablet') > -1) ? ($(e).attr('class').indexOf('mobile') > -1 ? '360px' : '770px') : widthSize;

        var widthSize = '';
        if($(e).attr('class').indexOf('desktop') > -1) widthSize = '100%';
        else if($(e).attr('class').indexOf('tablet') > -1) widthSize = '785px';
        else  widthSize = '433px';

        $('#template-site .modal-dialog .modal-content').css({
            'max-width': 'unset',
            'width': widthSize,
            'height': '86.5%'
        });
        setTimeout(function() {
            $.processOFF();
            $('#template-site .modal-dialog .modal-content').find('.load-template').fadeOut(200);
        }, 650);
        setTimeout(function() { // aos height resize
            $('#template-site .modal-dialog .modal-content').css('height', '86.6%');
        }, 800);
    }



    function previewModeChange1(e) {

        var hashId = $(e).attr('id');
        location.hash = hashId;

        $('.template-mode').removeClass('active');
        $(e).addClass('active');
        $('#previewmain .modal-content-pre').find('.load-template').css('display', 'block');
        $.processON('Loading...');

        var widthSize = '';
        if ($(e).attr('class').indexOf('desktop') > -1) widthSize = '100%';
        else if ($(e).attr('class').indexOf('tablet') > -1) widthSize = '785px';
        else widthSize = '431px';
        $('#previewmain .modal-content-pre').css({
            'max-width': 'unset',
            'width': widthSize
        });

        // setTimeout(function(){          
        //     $.processOFF();     
        //     $('#previewmain .modal-content-pre').find('.load-template').fadeOut(200);
        // },650);  

        //0206라이브 업뎃 복원용 
        //$("#iframe1").get(0).contentDocument.location.reload();

        //0206 업뎃 후 문제 시 삭제 
        $("#iframe1").get(0).contentWindow.location.reload();

        $("#iframe1").off('load').on('load', function(e) {
            $.processOFF();
            $('#previewmain .modal-content-pre').find('.load-template').fadeOut(200);
        });
    }

    function templateModeDefault(width) {
        var widthSize = '';
        if (width > 1199) {
            widthSize = '100%';
        } else if (width <= 1199 && width >= 768) {
            widthSize = '785px';
        } else if (width <= 767) {
            widthSize = '431px';
        }

        $('#template-site .modal-dialog .modal-content').css({
            'max-width': 'unset',
            'width': widthSize
        });

    }

    // 인증창 호출 함수
    function auth_type_check(outside) {
        if (typeof outside === 'undefined' || !outside) outside = false;

        var auth_form = document.form_auth;

        if (auth_form.ordr_idxx.value == "") {
            alert("요청번호는 필수 입니다.");
            return false;
        } else {
            var hostAry = window.location.hostname.split('.'),
                checkDomain = (hostAry[1] != 'creatorlink' && hostAry[1] != 'addblock') ? true : false;

            if (checkDomain && window.location.protocol == 'http:') {
                alert($.lang[LANG]['manager.cert.disable.domain']);
                return false
            }

            if( navigator.userAgent.indexOf("Android") > - 1 || navigator.userAgent.indexOf("iPhone") > - 1 )
            {
                auth_form.target = "kcp_cert";
                
                document.getElementById( "kcp_cert"  ).style.display = "";
            }
            else // 스마트폰이 아닌경우
            {
                var return_gubun;
                var width = 410;
                var height = 500;

                var leftpos = screen.width / 2 - (width / 2);
                var toppos = screen.height / 2 - (height / 2);

                var winopts = "width=" + width + ", height=" + height + ", toolbar=no,status=no,statusbar=no,menubar=no,scrollbars=no,resizable=no";
                var position = ",left=" + leftpos + ", top=" + toppos;
                var AUTH_POP = window.open('', 'auth_popup', winopts + position);

                auth_form.target = "auth_popup"; // !!주의 고정값 ( 리턴받을때 사용되는 타겟명입니다.)
            }

            auth_form.method = "post";
            auth_form.action = "/cert_req"; // 인증창 호출 및 결과값 리턴 페이지 주소

            if (outside) {
                auth_form.submit();
                return false;
            } else {
                return true;
            }
        }
    }

    // 요청번호 생성 예제 ( up_hash 생성시 필요 ) 
    function init_orderid() {
        var today = new Date();
        var year = today.getFullYear();
        var month = today.getMonth() + 1;
        var date = today.getDate();
        var time = today.getTime();

        if (parseInt(month) < 10) {
            month = "0" + month;
        }

        var vOrderID = year + "" + month + "" + date + "" + time;

        if (document.form_auth !== undefined) {
            document.form_auth.ordr_idxx.value = vOrderID;
        }

        return vOrderID;
    }

    // 인증창 종료후 인증데이터 리턴 함수
    function auth_data(frm) {
        var auth_form = document.form_auth;
        // var nField        = frm.elements.length;
        // var response_data = "";

        // // up_hash 검증 
        if (frm.up_hash != auth_form.veri_up_hash.value) {
            alert("up_hash 변조 위험있음");
        }

        //스마트폰 처리
        if( navigator.userAgent.indexOf("Android") > - 1 || navigator.userAgent.indexOf("iPhone") > - 1 )
        {
            let iframe = document.getElementById("kcp_cert");
            if (iframe) iframe.parentNode.removeChild(iframe);
            // document.getElementById("kcp_cert").style.display = "none";
        }
        /* 리턴 값 모두 찍어보기 (테스트 시에만 사용) */
        // var form_value = "";

        // for ( i = 0 ; i < frm.length ; i++ )
        // {
        //     form_value += "["+frm.elements[i].name + "] = [" + frm.elements[i].value + "]\n";
        // }
        // console.log(form_value);
        if (frm.res_cd == '0000' && frm.birth_day !== undefined) {
            var yyyy = frm.birth_day.substr(0, 4);
            var mm = frm.birth_day.substr(4, 2);
            var dd = frm.birth_day.substr(6, 2);
        }

        switch (frm.start_page) {
            case 'register':
            case 'myinfo':
                if (frm.res_cd == '0000') {
                    $('button.btn-cert').text($.lang[LANG]['siteum.regexp.complete.cert']).prop('disabled', true);
                    if (frm.start_page == 'register') loadRegisterField();
                } else {
                    if (frm.res_cd == 'exist') {
                        var error_title = '';
                        var error_msg = '';
                        var find_btn = $.lang[LANG]['siteum.forgot.id.link'];
                        if (frm.um_id != '') {
                            if (frm.start_page == 'register') {
                                error_title = $.lang[LANG]['siteum.cert.already.registered'];
                                error_msg = $.lang[LANG]['siteum.cert.already.registered.txt'] + '<div class="user-id">' + frm.um_id + '</div>';
                            } else {
                                error_title = $.lang[LANG]['siteum.cert.already.cert'];
                                error_msg = $.lang[LANG]['siteum.cert.already.cert.txt'] + '<div class="user-id">' + frm.um_id + '</div>';
                            }

                            find_btn = $.lang[LANG]['siteum.forgot.pw.link'];
                        }
                        $(this).showModalFlat(error_title, error_msg, true, true, function() {
                            $('input[name="sns_key"]').val('');
                            console.log($('input[name="sns_key"]'));
                            $.getJSON('/umember/login/out', function(r) {
                                if (frm.start_page == 'myinfo') {
                                    if ($.cookie('cert_popup') !== undefined) {
                                        $.removeCookie('cert_popup', true, { path: '/', expires: 12 * 60 * 60 * 1000 });
                                    }
                                }
                                location.href = '/_login';
                            }, 'json');
                        }, 'close', $.lang[LANG]['siteum.cert.login'], 'modal-dialog cl-cmmodal cl-s-btn w560 cl-p70 cl-modal cl-close-btn user-exist-modal', '');
                    } else if (frm.res_cd == 'not_adult') {
                        $(this).showModalFlat($.lang[LANG]['siteum.cert.adult.cannot.complete'], $.lang[LANG]['siteum.cert.adult.cannot.complete.txt'], true, false, '', 'ok', '', 'modal-dialog cl-cmmodal cl-s-btn w560 cl-p70 cl-modal cl-close-btn');
                    }

                    return false;
                }
                var sid = frm.sid;
                var gender = (frm.sex_code !== undefined && frm.sex_code) ? ((frm.sex_code == '01') ? '남' : '여') : '';
                $('#input-name').val(frm.user_name).addClass('has-value');
                $('#input-birth').val(yyyy + '-' + mm + '-' + dd).addClass('has-value');
                $('#input-tel').val(frm.phone_no).addClass('has-value');
                $('#input-gender').val(frm.sex_code).addClass('has-value');
                $('.certified-info .input-name').text(frm.user_name);
                $('.certified-info .input-birth').text(yyyy + '. ' + mm + '. ' + dd + '.');
                $('.certified-info .input-tel').text(frm.phone_no.replace(/^(\d{3})(\d{3,4})(\d{4})$/, '$1-$2-$3'));
                $('.certified-info .input-gender').text(gender);
                $('#cert_data').val(frm.cert_data);
                $('#cert_no').val(frm.cert_no);
                // $('#up_hash').val(frm.up_hash);
                // $('#ci_url').val(frm.ci_url);
                // $('#di_url').val(frm.di_url);
                $('.cl-s-register-btn').removeClass('hide');
                $('.cl-s-cert').addClass('hide');
                if (frm.start_page == 'myinfo') {
                    var formData = $("form[name='myinfo_form']").serializeObject();
                    $.ajax({
                        url: '/_myinfo_proc',
                        data: { sid: sid, data: JSON.stringify(formData) },
                        dataType: 'json',
                        type: 'POST',
                        async: false,
                        cache: false,
                        success: function(data) {
                            // console.log(data);
                            location.reload();
                        }
                    });
                }
                break;
            case 'find_id':
                if (frm.res_cd == '0000') {
                    $('.cl-s-forgot-box').addClass('hide');
                    $('.forgot-result').removeClass('hide');
                    $('.forgot-result .user-id').text(frm.um_id);
                } else {
                    $(this).showModalFlat($.lang[LANG]['siteum.forgot.id.invalid'], $.lang[LANG]['siteum.forgot.id.invalid.txt'], true, true, function() {
                        location.href = '/_register';
                    }, 'close', $.lang[LANG]['siteum.forgot.id.register'], 'modal-dialog cl-cmmodal cl-s-btn w560 cl-p70 cl-modal cl-close-btn', '');
                    return false;
                }
                break;
            case 'sitelock':
                break;
        }
    }

    var iconShowHide = function() {
        var body_w = $('body').width();
        $('.template-mode').removeClass('active');
        if (body_w >= 1200) {
            $('.template-desktop, .template-tablet, .template-mobile').show();
            $('.template-desktop').addClass('active');
        } else if (body_w <= 1199 && body_w >= 768) {
            $('.template-desktop').hide();
            $('.template-tablet, .template-mobile').show();
            $('.template-tablet').addClass('active');
        } else if (body_w <= 767) {
            $('.template-desktop, .template-tablet').hide();
            $('.template-mobile').show().addClass('active');
        }
    }

    var checkOS = function() {
        var os, ua = navigator.userAgent;
        if (ua.match(/Win(dows )?NT 6\.0/)) {
            os = "Windows Vista";
        } else if (ua.match(/Win(dows )?(NT 5\.1|XP)/)) {
            os = "Windows XP";
        } else {
            if ((ua.indexOf("Windows NT 5.1") != -1) || (ua.indexOf("Windows XP") != -1)) {
                os = "Windows XP";
            } else if ((ua.indexOf("Windows NT 7.0") != -1) || (ua.indexOf("Windows NT 6.1") != -1)) {
                os = "Windows 7";
            } else if ((ua.indexOf("Windows NT 8.0") != -1) || (ua.indexOf("Windows NT 6.2") != -1)) {
                os = "Windows 8";
            } else if ((ua.indexOf("Windows NT 8.1") != -1) || (ua.indexOf("Windows NT 6.3") != -1)) {
                os = "Windows 8.1";
            } else if ((ua.indexOf("Windows NT 10.0") != -1) || (ua.indexOf("Windows NT 6.4") != -1)) {
                os = "Windows 10";
            } else if ((ua.indexOf("iPad") != -1) || (ua.indexOf("iPhone") != -1) || (ua.indexOf("iPod") != -1)) {
                os = "Apple iOS";
            } else if (ua.indexOf("Android") != -1) {
                os = "Android OS";
            } else if (ua.match(/Win(dows )?NT( 4\.0)?/)) {
                os = "Windows NT";
            } else if (ua.match(/Mac|PPC/)) {
                os = "Mac OS";
            } else if (ua.match(/Linux/)) {
                os = "Linux";
            } else if (ua.match(/(Free|Net|Open)BSD/)) {
                os = RegExp.$1 + "BSD";
            } else if (ua.match(/SunOS/)) {
                os = "Solaris";
            }
        }
        if (os.indexOf("Windows") != -1) {
            if (navigator.userAgent.indexOf('WOW64') > -1 || navigator.userAgent.indexOf('Win64') > -1) {
                os += ' 64bit';
            } else {
                os += ' 32bit';
            }
        }
        return os;
    }

    var checkBrowser = function() {
        var agt = navigator.userAgent.toLowerCase();
        if (agt.indexOf("chrome") != -1) return 'Chrome';
        if (agt.indexOf("opera") != -1) return 'Opera';
        if (agt.indexOf("staroffice") != -1) return 'Star Office';
        if (agt.indexOf("webtv") != -1) return 'WebTV';
        if (agt.indexOf("beonex") != -1) return 'Beonex';
        if (agt.indexOf("chimera") != -1) return 'Chimera';
        if (agt.indexOf("netpositive") != -1) return 'NetPositive';
        if (agt.indexOf("phoenix") != -1) return 'Phoenix';
        if (agt.indexOf("firefox") != -1) return 'Firefox';
        if (agt.indexOf("safari") != -1) return 'Safari';
        if (agt.indexOf("skipstone") != -1) return 'SkipStone';
        if (agt.indexOf("netscape") != -1) return 'Netscape';
        if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
        if (agt.indexOf("msie") != -1) {
            let rv = -1;
            if (navigator.appName == 'Microsoft Internet Explorer') {
                let ua = navigator.userAgent;
                var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
                if (re.exec(ua) != null)
                    rv = parseFloat(RegExp.$1);
            }
            return 'Internet Explorer ' + rv;
        }
    }

    /**************************************************************************************** Change Profile */
    $('.change-profile, .profile_left').live('click', function(e) {
        if ($('script[src="/js/jquery.fileupload.js"]').length == 0) $('head').append('<script type="text/javascript" src="/js/jquery.fileupload.js"></script>');

        if($(this).hasClass('signinwrap_logo')) return;

        var name = ($(this).attr('class').indexOf('change-profile') > -1) ? $('.site-username').attr('data-user-name') : $('.profile_left').find('.m-profile').text().trim(),
            img = ($(this).attr('class').indexOf('change-profile') > -1) ? $('svg.change-profile').attr('data-user-img') : $('label.m-profile').attr('data-user-img'),
            paid = ($(this).attr('class').indexOf('change-profile') > -1) ? $('svg.change-profile').attr('data-user-plan') : $('label.m-profile').attr('data-user-plan'),
            check_um = ($(this).attr('class').indexOf('change-profile') > -1) ? $('svg.change-profile').attr('data-user-um') : $('label.m-profile').attr('data-user-um');
        if (check_um == 'um-profile') {
            //var mypageModal = $.umember.showMypageModal('<?=$mb["sid"]?>');
            var url = '/_myinfo';
            location.href = url;
        } else if (paid == 'true') {
            img = (typeof img == 'undefined' || img == '') ? 'https://storage.googleapis.com/i.addblock.net/member/profile_default.jpg' : img + '?_' + new Date().getTime();
            var str = '\
                <div class="dashboard-profile">\
                    <div class="dashboard-userimg dashboard-user-wrap">\
                        <svg viewBox="0 0 110 110" >\
                            <pattern id="dashboard-image-popup" patternUnits="userSpaceOnUse" width="120" height="120">\
                                <image xlink:href="' + img + '" x="0" width="110" height="110" />\
                            </pattern>\
                            <circle cx="55" cy="56" r="54" fill="url(#dashboard-image-popup)" stroke="#eeeff0"></circle>\
                        </svg>\
                    </div>\
                    <span class="fileinput-button profile-text-box">\
                        <label for="siteProfilefileupload">' + $.lang[LANG]['siteum.mypage.change.image'] + '</label>\
                        <input id="siteProfilefileupload" class="modal-upload-button site-profile-upload-btn" type="file" name="files[]">\
                    </span>\
                    <p class="p-text">' + $.lang[LANG]['dash.siteprofile.modal.nickname'] + $.lang[LANG]['account.modal.edit-image.size'] + '</p>\
                    <div class="section-username">\
                        <div class="input-group cl-common-form-wrap mypage-cl-form-wrap">\
                            <div class="cl-common-form-group cl-userNick-wrap">\
                                <input type="text" class="input-userNickname" name="usernick_name" required="required"  value="' + name + '">\
                                <label for="input" id="username-label" class="cl-common-control-label change-username-label">' + $.lang[LANG]['account.modal.edit-image.nickname'] + '</label>\
                            </div>\
                        </div>\
                        <p class="siteprofileImg_notice"><span class="profilenotice_icon">※</span><span class="profilenotice_txt">' + $.lang[LANG]['dash.siteprofile.modal.nickname.notice'] + '</span</p>\
                    </div>\
                    <ul class="hide uploadfiles"></ul>\
                </div>\
            ';

            if ($(this).hasClass('profile_left')) $('.m-header_user.menu, .btn-box.m-headerClose.in ').css('zIndex', '1010');

            var modal = $(this).showModalFlat($.lang[LANG]['dash.siteprofile.modal.title'], str, true, true, function() {
                var modal_id = $(this).closest('.modal').attr('id'),
                    $nick = $('.input-userNickname'),
                    org = $('.site-username').attr('data-user-name'),
                    sid = SID,
                    settings = {
                        site_nick: $nick.val().trim()
                    },
                    special_pattern = /[~!@\#$%<>^&*\()\-=+_\’'"]/gi,
                    uploadimg = $('#dashboard-image-popup1 image').attr('xlink:href'),
                    nouploadimg = $('#dashboard-image-top image').attr('xlink:href'),
                    profileimg = ($('label.change-profile').hasClass('um-profile')) ? 'profileimg_um' : 'profileimg_site';

                if ($('#dashboard-image-popup1').length > 0) {
                    $.post('/template/resource/upload-saveprofile', { uploadimg: uploadimg, profileimg: profileimg }, function(data) {
                        if (typeof data.error != "undefined" && data.error) {
                            $(this).showModalFlat('ERROR', data.error, true, false, '', 'ok');
                            return false;
                        }
                        $('svg.change-profile').attr('data-user-img', uploadimg);
                        $('label.m-profile').attr('data-user-img', uploadimg);
                        $('#dashboard-image-top image').attr('xlink:href', uploadimg);
                        $('#m-dashboard-image-top image').attr('xlink:href', uploadimg);

                        modal.modal('hide');
                    }, 'json');
                }

                $nick.removeClass('has-error');
                if (!$nick.val().trim()) {
                    $nick.addClass('has-error');
                    alert($.lang[LANG]['dashbord.settings.info.site-nick.edit-info']);
                    return false;
                } else if ($nick.val().trim() == org) {
                    modal.modal('hide');
                    return false;
                } else if (checkEmojis($nick.val().trim())) {
                    errorEmojisModal();
                    return false;
                }

                if ((special_pattern.test($nick.val().trim()) == true)) {
                    alert($.lang[LANG]['dashbord.settings.info.site-nick.edit-spec']);
                    return false;
                }

                $.post('/template/settings', {
                    'sid': sid,
                    'settings': JSON.stringify(settings),
                    'el': ''
                }, function(data) {
                    if (typeof data.error != 'undefined' && data.error) {
                        $nick.addClass('has-error');
                        alert(data.error);
                        return false;
                    }

                    $('.m-text-size').text(data.data.site_nick).attr('data-user-name', data.data.site_nick);
                    $('.site-username').attr('data-user-name', data.data.site_nick);
                    $('.mb-nickname').text(data.data.site_nick);
                    $('#register-nickname input.edit-input').attr('value', data.data.site_nick);

                    $('.cl-changePro-modal ul.uploadfiles').empty();
                    modal.modal('hide');
                }, 'json');
            }, 'cancel', 'config.change', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-changePro-modal', true, function() {
                //console.log('showCallback-cancel');
                var imgfile = $('.cl-changePro-modal .uploadfiles li').attr('data-source'),
                    files = [];

                $('.cl-changePro-modal .uploadfiles li').each(function() {
                    files.push($(this).attr('data-source'));
                });

                $('.cl-changePro-modal .uploadfiles').empty();
                if ($('#dashboard-image-popup1').length > 0) {
                    $.processON($.lang[LANG]['dash.siteprofile.modal.deleteimg']);
                    $.ajax({
                        type: 'POST',
                        url: '/template/resource/delete-gcloud',
                        data: { s: files },
                        dataType: 'json',
                        async: true,
                        success: function(data) {
                            if (typeof data.error != "undefined" && data.error) {
                                $(this).showModalFlat('ERROR', data.error, true, false, '', 'ok');
                                return false;
                            }
                            $.processOFF();
                        }
                    });
                }
            }, function() {
                $(document).on('click', '.site-profile-upload-btn', function() {
                    $(this).fileupload({
                            url: '/template/resource/upload-myimage-file',
                            dataType: 'json',
                            async: true,
                            pasteZone: null,
                            add: function(e, data) {
                                $('#loading').css('left', '-100%');
                                $.processON();
                                data.submit();
                            },
                            done: function(e, data) {
                                if (typeof data.result.error != 'undefined' && data.result.error) {
                                    alert(data.result.error);
                                    $('.progress .progress-bar').css('width', '0%');
                                    $.processOFF();
                                    return;
                                }

                                if (data.result.src) {
                                    var src1 = '<svg viewBox="0 0 110 110" ><pattern id="dashboard-image-popup1" patternUnits="userSpaceOnUse" width="120" height="120"><image xlink:href="' + data.result.src + '" x="0" width="110" height="110"></image></pattern><circle cx="55" cy="56" r="54" fill="url(#dashboard-image-popup1)" stroke="#eeeff0"></circle></svg>\
                                    ',
                                        src2 = '<svg viewBox="0 0 110 110" ><pattern id="dashboard-image-popup2" patternUnits="userSpaceOnUse" width="120" height="120"><image xlink:href="' + data.result.src + '" x="0" width="110" height="110"></image></pattern><circle cx="55" cy="56" r="54" fill="url(#dashboard-image-popup2)" stroke="#eeeff0"></circle></svg>\
                                        ',
                                        read_upload_file = '<li data-source="' + data.result.file_name + '"><img src="' + data.result.src + '"></li>';

                                    $('.dashboard-userimg').html(src1);
                                    $('.cl-changePro-modal ul.uploadfiles').append(read_upload_file);
                                    //$('label.change-profile').html(src2).attr('data-user-img',data.result.src);
                                    //$('.dashboard-userimg').attr('data-imgsave',data.result.path+'/'+data.result.raw_name);

                                }
                                $.processOFF();
                                $('#loading').css('left', '50%');
                            },
                            progressall: function(e, data) {
                                var progress = parseInt(data.loaded / data.total * 100, 10);
                                $('.progress .progress-bar').css(
                                    'width',
                                    progress + '%'
                                );

                            },
                        }).prop('disabled', !$.support.fileInput)
                        .parent().addClass($.support.fileInput ? undefined : 'disabled');
                });
            }, function() {
                $('.m-header_user.menu, .btn-box.m-headerClose.in ').css('zIndex', '');
            });
        } else {
            siteNotice('nickname');
        }

    });

    /***********************************************************************************************************************************************/

    var setLayoutHeight = function(el) {
        if(typeof el != 'undefined' && $.inArray(el, ['el-menu','el-footer']) > -1) return false;

        var block_selector = (typeof el != 'undefined' && el == 'el_display') ? '#element-display' : '.element[data-layout]';
        if($(block_selector).length == 0) return false;

        $(block_selector).each(function() {
            if($(this).is('[data-mode="thumb"]') || $(this).find('.layout-grid').length ==0) return;

            var lyh = (typeof $(this).find('.lyoption').attr('data-lyh') != 'undefined') ? $(this).find('.lyoption').attr('data-lyh') : 0.6;
            if (typeof lyh == 'undefined' || lyh == 'auto') return;

            var el = $(this).find('.layout-grid').eq(0),
                bl_w = Math.round(parseFloat(el[0].offsetWidth)),
                bl_pl = (el.css('padding-left')) ? Math.round(parseFloat(el.css('padding-left').replace(/[^0-9]/g, ''))) : 15,
                bl_pr = (el.css('padding-right')) ? Math.round(parseFloat(el.css('padding-right').replace(/[^0-9]/g, ''))) : 15,
                bl_w_pd = bl_w - (bl_pl + bl_pr),
                bl_ly_height = Math.round(bl_w_pd * parseFloat(lyh));

            $(this).find('.row .video-content').css('height', bl_ly_height + 'px');
            $(this).find('.ly-img').css('height', bl_ly_height + 'px');
            // if ($(this).attr('data-mode') == 'thumb' && $(this).attr('data-playtype') == 'true') $(this).find('iframe').css('height', bl_ly_height + 'px');

            var bl_svg_val = (bl_w_pd < 233) ? Math.round(parseFloat(bl_w_pd * 0.25)) : 58;
            $(this).find('.playbtn').attr('width', bl_svg_val).attr('height', bl_svg_val);
            $(this).css('overflow', 'hidden');
        });

    }

    var getLayoutData = function(tag) {
        var tag_ly_arr = [],
            tag_pd = (typeof tag.find('.lyoption').attr('data-lypd') != 'undefined' && tag.find('.lyoption').attr('data-lypd')) ? tag.find('.lyoption').attr('data-lypd') : '15',
            tag_pc = (typeof tag.find('.lyoption').attr('data-lycol') != 'undefined' && tag.find('.lyoption').attr('data-lycol')) ? tag.find('.lyoption').attr('data-lycol') : '4',
            tag_t = (typeof tag.find('.lyoption').attr('data-lycol-t') != 'undefined' && tag.find('.lyoption').attr('data-lycol-t')) ? tag.find('.lyoption').attr('data-lycol-t') : '2',
            tag_m = (typeof tag.find('.lyoption').attr('data-lycol-m') != 'undefined' && tag.find('.lyoption').attr('data-lycol-m')) ? tag.find('.lyoption').attr('data-lycol-m') : '2',
            tag_lyw = (typeof tag.find('.lyoption').attr('data-lyw') != 'undefined' && tag.find('.lyoption').attr('data-lyw')) ? tag.find('.lyoption').attr('data-lyw') : (tag_pc == '1' ? '100' : 'auto'),
            tag_lyh = (typeof tag.find('.lyoption').attr('data-lyh') != 'undefined' && tag.find('.lyoption').attr('data-lyh')) ? tag.find('.lyoption').attr('data-lyh') : '0.6',
            tag_orgw = (typeof tag.find('.lyoption').attr('data-org-width') != 'undefined' && tag.find('.lyoption').attr('data-org-width')) ? tag.find('.lyoption').attr('data-org-width') : ''

        var bl_cont = tag.find('.container'),
            bl_cont_w = parseFloat(bl_cont[0].offsetWidth),
            layout_grid = $('.' + selectEL).find('.layout-grid').eq(0),
            bl_w = parseFloat(layout_grid[0].offsetWidth),
            bl_pl = (layout_grid.css('padding-left')) ? parseFloat(layout_grid.css('padding-left').replace(/[^0-9]/g, '')) : 15,
            bl_pr = (layout_grid.css('padding-right')) ? parseFloat(layout_grid.css('padding-right').replace(/[^0-9]/g, '')) : 15,
            bl_lyw = (tag_pc == '1') ? Number(tag_lyw) : '',
            bl_lyw_dot = (tag_pc == '1') ? bl_lyw / 100 : '',
            bl_cont_w_re = (tag_pc == '1') ? (bl_cont_w - (bl_pl + bl_pr)) * bl_lyw_dot : '';

        tag_ly_arr['pc'] = tag_pc;
        tag_ly_arr['t'] = tag_t;
        tag_ly_arr['m'] = tag_m;
        tag_ly_arr['lyw'] = tag_lyw;
        tag_ly_arr['pd'] = tag_pd;
        tag_ly_arr['lyh'] = tag_lyh;
        tag_ly_arr['bl_cont_w'] = bl_cont_w;
        tag_ly_arr['bl_w'] = bl_w;
        tag_ly_arr['bl_pl'] = bl_pl;
        tag_ly_arr['bl_pr'] = bl_pr;
        tag_ly_arr['bl_lyw_dot'] = bl_lyw_dot;
        tag_ly_arr['bl_cont_w_re'] = bl_cont_w_re;

        return tag_ly_arr;
    }


    $(document).on('click', '.guestbook-fr-35, .btn-ico-right', function(e) {
        $(this).prev().click();
    });
    $(document).on('click', '.tpl-forum-toolbar-button.share', function(e) {
        var option = $(this).closest('.tpl-page-toolbar').attr('data-page-option');
        if (option == 'S') {
            $(this).showModalFlat('INFORMATION', $.lang[LANG]['config.gallery.share.cannot.secret-post'], true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title');
            return false;
        }
        if (typeof MODE == 'undefined' && property.PUBLISH) shareModal();
        else $(this).showModalFlat($.lang[LANG]['config.information'], $.lang[LANG]['config.gallery.share.publish'], true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-okbtn-pbt70');
    });

    $(document).on('click', '.tpl-forum-toolbar-button.like', function(e) {
        var page = (PAGE_MODE == 'c') ? PAGE : property.PAGE;
        if (page.indexOf(',') > -1) {
            var page = (PAGE_MODE == 'c') ? PAGE.split(',') : (property.PAGE).split(',');
            var npage = (page[0] == 'forum') ? 'forum' : 'project';
            var $el = (npage == 'forum') ? $(this).find('button') : $(this);
            setLike($el, npage);
        } else {
            return false;
        }
    });
    $(document).on('click', 'a.gallery-like', function(e) {
        setLike($(this), 'gallery');
    });
    $(document).on('click', '.figure.like > *', function(e) {
        var $this = $(this).closest('.figure.like');
        if ($this.closest('.emptyGallery').length > 0) return false;
        setLike($this, 'list');
    });
    // $(document).on('click','.element[data-type2="qna"] .tpl-forum-list-like, .element[data-type2="faq"] .tpl-forum-list-like, .element[data-type2="guestbook"] .tpl-forum-list-like', function(e) {
    //     var $this = $(this);
    //     setLike($this, 'flist');
    // });
    $(document).on('click', '.element a[data-popup][data-popup-name]', function(e){
        e.preventDefault();
        e.stopPropagation();
        var iVALIDPLAN = (PAGE_MODE == 'c') ? VALIDPLAN : property.VALIDPLAN;
        var iVALIDTYPE = (PAGE_MODE == 'c') ? VALIDTYPE : property.VALIDTYPE;
        if(iVALIDPLAN && iVALIDTYPE != 'PK') imgPopupFrame($(this));
    });

    var checkUseCommentFunc = function(mode, eltag) {
        var check = false;
        if (mode == 'project') {
            var notUseComment = ['gallery_38', 'gallery_37', 'gallery_36', 'gallery_28', 'gallery_25', 'gallery_22', 'gallery_21', 'gallery_8', 'gallery_6'];
            var $eltag = $(htmlspecialchars_decode(eltag, 'ENT_QUOTES'));
            var tplImg = $eltag.find('img').attr('src');
            var notUseCommentCnt = 0;
            $.each(notUseComment, function(i, v) {
                if (typeof tplImg !== 'undefined' && tplImg.indexOf(v) > -1) {
                    notUseCommentCnt++;
                    return false;
                }
            });
            check = ($eltag.find('h5.figure').eq(0).hasClass('only-sh') || !$eltag.find('h5.figure').eq(0).hasClass('title') || !$eltag.find('p.figure').eq(0).hasClass('caption') || notUseCommentCnt > 0) ? false : true;
        }

        return check;
    }

    var checkUseLikeFunc = function(mode, eltag) { //like
        var check = false;
        var notUseLike = ['gallery_38', 'gallery_37', 'gallery_36', 'gallery_28', 'gallery_25', 'gallery_22', 'gallery_21', 'gallery_8', 'gallery_6'];
        // var umemberActivate = (PAGE_MODE == 'c')? UMEMBER_ACTIVATE : property.UMEMBER_ACTIVATE;
        // if(umemberActivate == 0) {
        //     return false;
        // }
        var lVALIDPLAN = (PAGE_MODE == 'c') ? VALIDPLAN : property.VALIDPLAN;
        if (!lVALIDPLAN) return false;
        switch (mode) {
            case 'project':
            case 'gallery':
                var $eltag = $(htmlspecialchars_decode(eltag, 'ENT_QUOTES'));
                var tplImg = $eltag.find('img').attr('src');
                var notUseLikeCnt = 0;
                $.each(notUseLike, function(i, v) {
                    if (typeof tplImg !== 'undefined' && tplImg.indexOf(v) > -1) {
                        notUseLikeCnt++;
                        return false;
                    }
                });
                check = ($eltag.find('h5.figure').eq(0).hasClass('only-sh') || !$eltag.find('h5.figure').eq(0).hasClass('title') || !$eltag.find('p.figure').eq(0).hasClass('caption') || notUseLikeCnt > 0) ? false : true;

                break;
        }

        return check;
    }

    var getRgbaValArray = function(bg_color, opacity_val) {
        var bgColorArr = [],
            setColorArr = [],
            opacity_val = (typeof opacity_val != 'undefined' && opacity_val) ? opacity_val : '';

        if (typeof bg_color == 'undefined') return;
        if (bg_color == 'transparent' || !bg_color || bg_color == 'none') opacity_val = '0';
        bg_color = (bg_color == 'transparent' || !bg_color || bg_color == 'none') ? 'rgba(255,255,255,' + opacity_val + ')' : bg_color;

        if (bg_color.indexOf('#') > -1) {
            if (bg_color.length < 5) {
                var str_color = bg_color.substring(1, bg_color.length);
                bg_color += str_color;
            }

            var bgColorArr_re = Object.values(hexToRgba(bg_color));
            setColorArr['r'] = bgColorArr_re['0'].toString();
            setColorArr['g'] = bgColorArr_re['1'].toString();
            setColorArr['b'] = bgColorArr_re['2'].toString();
            setColorArr['a'] = '1';
        } else setColorArr = rgbaToOpacity(bg_color);

        bg_color = 'rgb(' + setColorArr.r + ',' + setColorArr.g + ',' + setColorArr.b + ')'
        if (opacity_val != '' && (setColorArr.a != opacity_val)) setColorArr.a = opacity_val;

        bgColorArr['rgba'] = setColorArr;
        bgColorArr['val'] = bg_color;
        bgColorArr['rgba_txt'] = 'rgba(' + setColorArr.r + ',' + setColorArr.g + ',' + setColorArr.b + ',' + setColorArr.a + ')';

        return bgColorArr;
    }

    var getColorAndOpacity = function(bc_selector, css, css_change_opt, change_color_array) {
        var bg_info = {},
            bg_opt_color = (typeof change_color_array == 'undefined' && !change_color_array) ? getColor(bc_selector, css, css_change_opt) : change_color_array,
            bg_opt_color_val = bg_opt_color['val'],
            bg_transparent_class = (bg_opt_color_val == 'transparent' || !bg_opt_color_val) ? ' transparent' : '',
            bg_opt_opacity_percent = (bg_opt_color_val == 'transparent' || !bg_opt_color_val) ? 0 : (bg_opt_color['rgba']['a'] * 100),
            bg_opt_opacity_dot = (bg_opt_color_val == 'transparent' || !bg_opt_color_val) ? 0 : (bg_opt_opacity_percent / 100);


        if (css_change_opt == 'background-color' &&
            typeof css['children'][bc_selector] != 'undefined' &&
            typeof css['children'][bc_selector]['attributes'] != 'undefined' &&
            typeof css['children'][bc_selector]['attributes']['opacity'] != 'undefined'
        ) {
            var this_opacity = css['children'][bc_selector]['attributes']['opacity'];
            if (this_opacity == '1' && css['children'][bc_selector]['attributes']['background-color'] == 'transparent') {
                bg_opt_opacity_dot = 0;
                bg_opt_opacity_percent = 0;
            } else {
                if (this_opacity.match(/^[0-9\.]*$/g) !== null) {
                    bg_opt_opacity_dot = this_opacity;
                    bg_opt_opacity_percent = this_opacity * 100;
                }
            }

        }

        bg_info = {
            color: bg_opt_color,
            trans: bg_transparent_class,
            op_percent: bg_opt_opacity_percent,
            op_dot: bg_opt_opacity_dot,
        }

        return bg_info;
    }

    var getLoadBlockScript = function(blocks) {
        if (typeof blocks == 'undefined' || blocks.toString().length == 0) return { total: 0, list: {} };

        var script_names = {
                'gallery'   : ['comments','bottomlist'],
                'forum'     : ['forum','comments','bottomlist'],
                'latest'    : ['forum','latest'],
                'sns'       : ['socialfeed'],
                // 'contact'   : ['jqueryFileupload'],
                'countdown' : ['jqueryCountdown'],
                'shopping'  : ['shopping'],
                'review'    : ['reviewContents'],
            },
            script_path = {
                //'loadScript-???' : 'script path', 
                'aos'       : 'https://unpkg.com/aos@2.3.1/dist/aos.js',
                'shopping'  : '/js/shopping.js',
                'forum'     : '/js/module/forum.js',
                'latest'    : '/js/module/latest.js',
                'reviewContents'    : '/js/module/review_contents.js',
                'comments'  : '/js/module/comments.js',
                'bottomlist'    : '/js/module/bottomlist.js',
                'socialfeed'    : '/js/feed/socialfeed.js',
                // 'jqueryFileupload'  : '/js/jquery.fileupload.js',
                'jqueryCountdown'   : '/js/jquery.countdown.js',
            },
            script_total = 0,
            script_result = {};

        $.each(blocks, function(i, v) {
            if (v === false) return true;

            var sct_names = (typeof script_names[i] != 'undefined' && script_names[i]) ? script_names[i] : [];
            $.each(sct_names, function(idx, val) {
                if (typeof script_path[val] != 'undefined' && script_path[val]) {
                    if (typeof script_result[val] == 'undefined') script_total++;
                    script_result[val] = script_path[val];
                }
            })
        });

        return { total: script_total, list: script_result };
    }

    var loadingScript = function(r) {
        var deferred = $.Deferred();
        var script_r = getLoadBlockScript(r),
            script_total = (typeof script_r.total != 'undefined') ? script_r.total : 0,
            script_load = 0;

        if (script_total == 0) deferred.resolve();
        $.each(script_r.list, function(s_n, s_p) {
            if ($('.loadScript-' + s_n).length == 0) {
                $.ajax({
                    async: false,
                    url: s_p,
                    dataType: 'script',
                    success: function(data) {
                        $('head').append('<input type="hidden" class="loadScript-' + s_n + '" value="' + s_p + '">');
                        script_load++;
                    },
                    error: function(request, status, error) {
                        // console.log("code: " + request.status);
                        // console.log("message: " + request.responseText);
                        // console.log("error: " + error);
                    }
                }).done(function() {
                    if (script_load == script_total) deferred.resolve();
                });
            } else {
                script_load++;
                if (script_load == script_total) deferred.resolve();
            }
        });

        return deferred.promise();
    }

    var checkAosForParallax = function(siteSettings, blockSettings, $tag) {

            if ($tag.is('[data-type="gallery"][data-type2="premium"]')) {
                $tag.attr('data-aosinfo', false);
                return false;
            }

            var block_aos_site = (typeof siteSettings.block_aos != 'undefined' && siteSettings.block_aos) ? siteSettings.block_aos : {},
                block_aosAll_site = (typeof block_aos_site['all'] != 'undefined' && block_aos_site['all']) ? block_aos_site['all'] : {},
                aos_time_site = (typeof block_aosAll_site.t != 'undefined' && block_aosAll_site.t) ? block_aosAll_site.t : '',
                aos_motion_site = (typeof block_aosAll_site.m != 'undefined' && block_aosAll_site.m) ? block_aosAll_site.m : '',
                aos_duration_site = (typeof block_aosAll_site.d != 'undefined' && block_aosAll_site.d) ? block_aosAll_site.d : '700';

            var block_aos_page = (typeof blockSettings.block_aos != 'undefined' && blockSettings.block_aos) ? blockSettings.block_aos : {},
                aos_time_page = (typeof block_aos_page.t != 'undefined' && block_aos_page.t) ? block_aos_page.t : '',
                aos_motion_page = (typeof block_aos_page.m != 'undefined' && block_aos_page.m) ? block_aos_page.m : '',
                aos_duration_page = (typeof block_aos_page.d != 'undefined' && block_aos_page.d) ? block_aos_page.d : '700';


            if (block_aos_site && (aos_time_site > aos_time_page) && aos_motion_site != 'no-motion' &&
                $('body').find('.menu-lock-block').length < 1 && $('body').find('.site-lock-block').length < 1) {
                $tag.attr('data-aosinfo', true);
            } else {
                if ($.isEmptyObject(block_aos_page) == false && (aos_time_site < aos_time_page) && aos_motion_page != 'no-motion' &&
                    $('body').find('.menu-lock-block').length < 1 && $('body').find('.site-lock-block').length < 1) {
                    $tag.attr('data-aosinfo', true);
                } else {
                    $tag.attr('data-aosinfo', false);
                }
            }
        }
        // lux shopping
    var ChooseFilters = function(brand, search, mode) {
        var min = (mode == true) ? getProductParams('min_price') : getSearchURL('min_price'),
            max = (mode == true) ? getProductParams('max_price') : getSearchURL('max_price'),
            price = [10, 30, 50, 70, 100, 150, 200, 300, 500];
        s = '';
        if (typeof search == 'undefined') {
            s = '\
            <div class="prod-search-brand"><input type="text" class="search-brand-input" placeHolder="브랜드 검색" enterkeyhint="search">\
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-search" viewBox="0 0 16 16"><path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/></svg>\
            </div>\
            ';
        }
        if (brand) {
            s = s + '\
            <button type="button" class="btn-v2 recommend-filter brand" data-key="brand" data-val="B00000IP">톰포드</button>\
            <button type="button" class="btn-v2 recommend-filter brand" data-key="brand" data-val="B00000DM">마크 제이콥스</button>\
            <button type="button" class="btn-v2 recommend-filter brand" data-key="brand" data-val="B00000BO">생로랑</button>\
            <button type="button" class="btn-v2 recommend-filter brand" data-key="brand" data-val="B00000BQ">버버리</button>\
            <button type="button" class="btn-v2 recommend-filter brand" data-key="brand" data-val="B000000C">구찌</button>\
            ';
        }

        s = s + '\
        <div class="filter-buttons">\
            <div class="btn-group product_type">\
                <button type="button" class="dropdown-toggle recommend-filter list-filter dropdown-button" data-toggle="dropdown">\
                    <span class="type_trend">상품유형</span>\
                    <svg width="12" height="12" fill="currentColor" class="bi bi-chevron-down" viewBox="0 0 16 16">\
                        <path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"></path>\
                    </svg>\
                </button>\
                <ul class="dropdown-menu">\
                    <li data-key="trend" data-val="T0000000">브랜드홈</li>\
                    <li data-key="trend" data-val="T00000CQ">편집샵</li>\
                    <li data-key="trend" data-val="T00000CS">국내배송</li>\
                    <li data-key="trend" data-val="T00000HO">도매부티크</li>\
                </ul>\
            </div>\
            <div class="btn-group">\
                <button type="button" class="dropdown-toggle recommend-filter list-filter dropdown-button" data-toggle="dropdown">\
                    <span class="type_discount_rate">할인율</span>\
                    <svg width="12" height="12" fill="currentColor" class="bi bi-chevron-down" viewBox="0 0 16 16">\
                        <path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"></path>\
                    </svg>\
                </button>\
                <ul class="dropdown-menu">\
                    <li data-key="discount_rate" data-val="sp">특가세일</li>\
                    <li data-key="discount_rate" data-val="10off">10off이하</li>\
                    <li data-key="discount_rate" data-val="10n30">10n30off</li>\
                    <li data-key="discount_rate" data-val="30n50">30n50off</li>\
                    <li data-key="discount_rate" data-val="50off">50off이상</li>\
                </ul>\
            </div>\
            <div class="btn-group">\
                <button type="button" class="dropdown-toggle recommend-filter list-filter dropdown-button" data-toggle="dropdown">\
                    <span class="type_min_price">최저가</span>\
                    <svg width="12" height="12" fill="currentColor" class="bi bi-chevron-down" viewBox="0 0 16 16">\
                        <path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"></path>\
                    </svg>\
                </button>\
                <ul class="dropdown-menu">\
                    <li data-key="min_price" data-val="">선택안함</li>\
                    ' + setPriceHtml(price, 'min_price', max) + '\
                </ul>\
            </div>\
            <div class="btn-group">\
                <button type="button" class="dropdown-toggle recommend-filter list-filter dropdown-button" data-toggle="dropdown">\
                    <span class="type_max_price">최고가</span>\
                    <svg width="12" height="12" fill="currentColor" class="bi bi-chevron-down" viewBox="0 0 16 16">\
                        <path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"></path>\
                    </svg>\
                </button>\
                <ul class="dropdown-menu">\
                    ' + setPriceHtml(price, 'max_price', min) + '\
                    <li data-key="max_price" data-val="">선택안함</li>\
                </ul>\
            </div>\
        </div>\
        ';
        return s;
    }

    var setPriceHtml = function(price, type, selected_price) {
        var s = '';
        $.each(price, function(i, v) {
            var active = '';
            if (type == 'min_price') {
                if (Number(selected_price) > 0 && v >= Number(selected_price)) {
                    active = 'disabled';
                }
            } else {
                if (Number(selected_price) > 0 && v <= Number(selected_price)) active = 'disabled';
            }
            // if(v == Number(getSearchURL(type))) active = 'active';
            s = s + '<li class="' + active + '" data-key="' + type + '" data-val="' + v + '">' + v + '만원</li>';
        });
        return s;
    }

    var lux_all_category;
    var getAllCategory = function(select, category, list, idx, no) {
        $.processON();
        $.ajax({
            type: 'POST',
            url: '/template/lux_category_all',
            data: { sid: SID },
            dataType: 'json',
            async: true,
            cache: false,
            success: function(r) {
                lux_all_category = r.root;
                $.processOFF();
                var html = setSelectCategoryHTML(r, true);
                if (typeof select != 'undefined') {
                    var $html = $(html);

                    $html.find('li').addClass('disable').css('display', 'none');
                    $html.find('li[data-category="' + select + '"]').removeClass('disable').addClass('active').css('display', '').empty().append(category);
                    $html.find('li.click-off').removeClass('disable');
                    if (Number(select) > 1000000) {
                        $html.find('.add-user-category').css('display', '');
                        $html.find('.input-user-category').css('display', 'none');
                    }
                    var s = (list.length == 1) ? displaySubCategoryList(lux_all_category[list[0]]['sub']) : displaySubCategoryList(lux_all_category[list[0]]['sub'][list[1]]['sub'], true);
                    $html.find('.add-user-category').before(s);
                    html = $html.outerHTML();
                }
                var modal = $(this).showModalFlat('상품연결', html, true, true, function() {
                    var choose = $('.choose-select-category li.active').attr('data-category');
                    if (typeof choose == 'undefined') {
                        alert('선택된 카테고리가 없습니다');
                        return false;
                    }
                    var s = '<ul class="active" data-sid="' + SID + '" data-no="' + ((typeof no != 'undefined') ? no : '') + '">',
                        $items = $('.choose-select-category li.active span'),
                        add = [],
                        updated = [];
                    $.each($items, function(i, v) {
                        s += '<li class="' + (($items.length == i + 1) ? 'last' : '') + '" data-category-no="' + $(this).attr('data-category') + '" data-seq="' + ((typeof $(this).attr('data-seq') == 'undefined') ? '' : $(this).attr('data-seq')) + '"><span class="user-category-text">' + $(this).text().trim() + '</span></li>\n';
                        add.push($(this).attr('data-category'));
                        updated.push((typeof $(this).attr('data-seq') == 'undefined') ? '' : $(this).attr('data-seq'));
                    });
                    s += '<div class="user-selected-category-delete" data-no=""><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle" viewBox="0 0 16 16"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"></path><path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"></path></svg></div>';
                    s += '</ul>';

                    // 기존 카테고리 
                    var selected = [];
                    $.each($('#lux-category-text ul'), function(i, v) {
                        var sub_selected = [];
                        $.each($(this).find('li'), function(a, b) {
                            sub_selected.push($(this).attr('data-category-no'));
                        });
                        selected.push(sub_selected.join());
                    });

                    var duplicates = false;
                    $.each(selected, function(i, v) {
                        if (v.indexOf(add.join()) > -1) {
                            alert('이미 추가된 카테고리입니다');
                            duplicates = true;
                        }
                        if (duplicates) return false;
                    });

                    if (duplicates) return false;

                    // 상위 카테고리 중복 제거
                    var depth_arr = []
                    $.each(add, function(i, v) {
                        depth_arr.push(v);
                        var remove_idx = selected.indexOf(depth_arr.join());
                        if (remove_idx > -1) {
                            var $remove_category = $('#lux-category-text ul').eq(remove_idx),
                                remove_deleted = [];
                            $.each($remove_category.find('li'), function(a, b) {
                                if (typeof $(this).attr('data-seq') != 'undefined' && $(this).attr('data-seq') != '')
                                    remove_deleted.push($(this).attr('data-seq'));
                            });
                            var d = $('#category-deleted').val(),
                                deleted = (d.length) ? (d || '').split(',') : [];

                            if (remove_deleted.length) {
                                deleted.push(...remove_deleted);
                                r = deleted.join();
                                $('#category-deleted').val(r);
                            }
                            $('#lux-category-text ul').eq(remove_idx).remove();
                            alert('기존에 선택한 상위 카테고리는 중복으로 제거 됩니다.');
                        }
                    });

                    if (typeof idx != 'undefined') {
                        $('#lux-category-text ul').eq(idx).remove();
                        idx = idx - 1;
                        if (idx > -1) {
                            $('#lux-category-text ul').eq(idx).after(s);
                        } else {
                            $('#lux-category-text').append(s);
                        }
                    } else {
                        $('#lux-category-text').append(s);
                    }

                    // 삭제된 카테고리 처리
                    var prev_category = $('#category-update-deleted').val();
                    if (prev_category.length) {
                        var prev_arr = prev_category.split(',');
                        if (updated.length) {
                            $.each(updated, function(i, v) {
                                if (v.length) prev_arr = arrayRemove(prev_arr, v);
                            });
                        }
                        $('#category-deleted').val(prev_arr.join());
                    }
                    modal.modal('hide');
                }, 'config.close', 'config.ok', 'cl-cmmodal cl-s-btn w700 cl-p70 cl-p0 noActive-domain-check h800', true, function() {
                    // close callback
                    $('#category-update-deleted').val('');
                });
            },
            error: function(xhr, status, error) {
                $.processOFF();
                alert("Error " + xhr.status + " : 관리자에게 문의");
            }
        });
    }

    $(document)
        .on('touchstart', '.carousel', function(e) {
            if(typeof PAGE_MODE != 'undefined' && PAGE_MODE == 'c') return false;

            const slideshow_xClick = e.originalEvent.touches[0].pageX;
            $(this).one('touchmove', function(event){
                const slideshow_xMove = event.originalEvent.touches[0].pageX;
                const slideshow_sensitivityInPx = 5;

                if( Math.floor(slideshow_xClick - slideshow_xMove) > slideshow_sensitivityInPx ){
                    $(this).carousel('next');
                }
                else if( Math.floor(slideshow_xClick - slideshow_xMove) < -slideshow_sensitivityInPx ){
                    $(this).carousel('prev');
                }
            });
            $(this).on('touchend', function(){
                $(this).off('touchmove');
            });
        });


    $(document)
        .off('click', '#lux-category-text ul')
        .on('click', '#lux-category-text ul', function(e) {
            var $selected = $(this),
                s = '',
                first = 0,
                l = [],
                i = $(this).index(),
                u = [],
                no = $(this).attr('data-no');
            if ($(this).attr('data-sid') == 'mlux') return;
            if ($selected.find('li').length) {
                $.each($selected.find('li'), function(i, v) {
                    if (i == 0) first = $(this).attr('data-category-no');
                    s += '<span class="selected" data-category="' + $(this).attr('data-category-no') + '" data-seq="' + $(this).attr('data-seq') + '">' + $(this).text() + ' <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle" viewBox="0 0 16 16"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"></path><path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"></path></svg></span>';
                    l.push($(this).attr('data-category-no'));
                    u.push($(this).attr('data-seq'));
                });
            }
            $('#category-update-deleted').val(u.join());
            getAllCategory(first, s, l, i, no);
        });

    $(document)
        .off('click', '.user-selected-category-delete')
        .on('click', '.user-selected-category-delete', function(e) {
            e.stopPropagation();
            if (confirm('카테고리를 삭제하시겠습니까?')) {
                var selected_category = $(this).parent().find('li'),
                    user_deleted = [];

                $.each(selected_category, function(i, v) {
                    if (typeof $(this).attr('data-seq') != 'undefined' && $(this).attr('data-seq') != '')
                        user_deleted.push($(this).attr('data-seq'));
                });

                var unique = [...new Set(user_deleted)],
                    d = $('#category-deleted').val(),
                    deleted = (d.length) ? (d || '').split(',') : [];
                $(this).parents('ul').remove();
                if (unique.length) {
                    deleted.push(...unique);
                    r = deleted.join();
                    $('#category-deleted').val(r);
                }
            }
        });

    $(document)
        .off('click', '.lux-category-add')
        .on('click', '.lux-category-add', function(e) {
            getAllCategory();
        });

    $(document)
        .off('click', '.choose-select-category.add li .lux-category-modify, .sub-category-item .lux-category-modify')
        .on('click', '.choose-select-category.add li .lux-category-modify, .sub-category-item .lux-category-modify', function(e) {
            e.stopPropagation();
            var category_name = $(this).parent().text().trim(),
                seq = $(this).parent().attr('data-category');

            $('li.orig').addClass('hide');
            $('.sub-category-item').addClass('hide');
            $('.input-user-category').addClass('active').css('display', 'block');
            $('.modal-footer .ok-button-dialog').addClass('disabled');
            $('#input-user-category').val(category_name).attr('data-modify', 'true').attr('data-category', seq);
        });

    $(document)
        .off('click', '.choose-select-category.add li .lux-category-delete, .sub-category-item .lux-category-delete')
        .on('click', '.choose-select-category.add li .lux-category-delete, .sub-category-item .lux-category-delete', function(e) {
            e.stopPropagation();
            var depth = $('.choose-select-category.add li.active .selected').length,
                category_no = $(this).parent().attr('data-category'),
                parent = $('.choose-select-category.add li.active .selected:nth-child(1)').attr('data-category'),
                sub = $('.choose-select-category.add li.active .selected:nth-child(2)').attr('data-category');
            var agree = (confirm('선택하신 카테고리를 삭제하시겠습니까?')) ? true : false;
            if ($('#lux-category-text').find('[data-category-no="' + category_no + '"]').length && agree == true) {
                alert('현재 상품에 적용된 카테고리입니다.');
                agree = false;
            }
            if (agree == false) return;
            $.processON();
            $.ajax({
                type: 'POST',
                url: '/template/lux_category_delete',
                data: { sid: SID, category_no: category_no, depth: depth },
                dataType: 'json',
                async: true,
                cache: false,
                success: function(r) {
                    $.processOFF();
                    if (typeof r.error != 'undefined' && r.error) {
                        alert(r.error);
                        return false;
                    }
                    lux_all_category = r.all_category;
                    if (depth == 0) {
                        $('.choose-select-category li[data-category="' + r.category_no + '"]').remove();
                    } else if (depth == 1) {
                        $('.sub-category-item div[data-category="' + r.category_no + '"]').remove();
                        displaySubCategoryList(lux_all_category[parent]['sub']);
                    } else {
                        $('.sub-category-item div[data-category="' + r.category_no + '"]').remove();
                        displaySubCategoryList(lux_all_category[parent]['sub'][sub]['sub'], true);
                    }
                },
                error: function(xhr, status, error) {
                    $.processOFF();
                    $('.input-user-category.active').removeClass('spinner');
                    alert("Error " + xhr.status + " : 관리자에게 문의");
                }
            });
        });

    $(document)
        .off('click', '.choose-select-category.add li')
        .on('click', '.choose-select-category.add li', function(e) {
            if ($(this).hasClass('click-off')) return;
            var id = $(this).attr('data-category'),
                selected = $(this).text();
            if ($(this).find('.selected').length) return false;
            $('.choose-select-category.add li.orig:not([data-category="' + id + '"]').fadeOut(0).addClass('disable');

            if (Number(id) > 1000000000) {
                if ($('.input-user-category').hasClass('active')) {
                    $('.input-user-category').removeClass('active').hide();
                    $('.modal-footer .ok-button-dialog').removeClass('disabled');
                }
                // addInputCategoryClose(0);
                enableCategoryButton();
            } else addInputCategoryClose(0);

            $('.sub-category-item').removeClass('active').remove();
            $('.choose-select-category.add li').removeClass('active');
            $(this).addClass('active').html('<span class="selected" data-category="' + id + '">' + selected + ' <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle" viewBox="0 0 16 16"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/><path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"/></svg></span>');

            displaySubCategoryList(lux_all_category[id]['sub']);
        })
        .off('hover', '.choose-select-category.add li')
        .on('hover', '.choose-select-category.add li', function(e) {
            var id = $(this).attr('data-category');
            if ($(this).find('.selected').length) return;
            if (Number(id) > 1000000000 && $(this).find('.lux-category-delete').length == 0) {
                $(this).append('<span class="lux-category-delete"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16"><path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"/><path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"/></svg></span>');
                $(this).append('<span class="lux-category-modify"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil" viewBox="0 0 16 16"><path d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325z"/></svg></span>');
            }
        });

    $(document)
        .off('hover', '.sub-category-item > div')
        .on('hover', '.sub-category-item > div', function(e) {
            var id = $(this).attr('data-category');
            if ($(this).find('.selected').length) return;
            if (Number(id) > 1000000 && $(this).find('.lux-category-delete').length == 0) {
                $(this).append('<span class="lux-category-delete"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16"><path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"/><path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"/></svg></span>');
                $(this).append('<span class="lux-category-modify"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil" viewBox="0 0 16 16"><path d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325z"/></svg></span>');
            }
        });

    $(document)
        .off('click', '.choose-select-category.add li.add-user-category')
        .on('click', '.choose-select-category.add li.add-user-category', function(e) {
            var depth = $('.choose-select-category.add .selected').length,
                root = '',
                parent = '';

            $('#input-user-category').attr('data-category', '').attr('data-modify', '');
            if (depth > 0) {
                root = $('.choose-select-category.add .selected').first().attr('data-category');
                parent = $('.choose-select-category.add .selected').last().attr('data-category');
            }
            depth++;

            $('#input-user-category').attr('data-depth', depth).attr('data-parent', parent).attr('data-root', root);
            $(this).fadeOut(0).addClass('disable');
            setTimeout(function() {
                $('.input-user-category').fadeIn(0).addClass('active');
                $('.modal-footer .ok-button-dialog').addClass('disabled');
                $('#input-user-category').focus();
                $('.sub-category-item').addClass('hide');
            }, 0);
        });

    $(document)
        .off('click', '.input-user-category-close svg')
        .on('click', '.input-user-category-close svg', function(e) {
            if ($(this).parent().prev().attr('data-modify') == 'true') {
                $('li.orig').removeClass('hide');
                addInputCategoryClose(0);
            } else {
                addInputCategoryClose(0);
            }
        });

    $(document)
        .off('keyup', '#input-user-category')
        .on('keyup', '#input-user-category', function(e) {
            var key = (e.which) ? e.which : e.keyCode,
                category_no = $(this).attr('data-category'),
                depth = $(this).attr('data-depth'),
                parent = $(this).attr('data-parent'),
                root = $(this).attr('data-root'),
                full_no = [],
                full_name = [],
                val = $(this).val().trim();

            $.each($('.choose-select-category.add .selected'), function(i, v) {
                full_no.push($(this).attr('data-category'));
                full_name.push($(this).text().trim());
            });

            if (key == 13 && val != '') {
                $('.input-user-category.active').addClass('spinner');
                $.ajax({
                    type: 'POST',
                    url: '/template/lux_category_add',
                    data: { val: val, depth: depth, parent_no: parent, root: root, sid: SID, full_no: full_no, full_name: full_name, category_no: category_no },
                    dataType: 'json',
                    async: true,
                    cache: false,
                    success: function(r) {
                        $('.input-user-category.active').removeClass('spinner');
                        if (typeof r.error != 'undefined' && r.error) {
                            alert(r.error);
                            return false;
                        }
                        lux_all_category = r.all_category.all;
                        $('.input-user-category > input').val('');
                        $('.input-user-category').fadeOut(200).removeClass('active');
                        $('.modal-footer .ok-button-dialog').removeClass('disabled');
                        $('.sub-category-item').removeClass('hide');
                        if (category_no.length) {
                            if (r.depth == 1) {
                                $('.choose-select-category li.orig[data-category="' + category_no + '"]').html('<span class="user-category-text">' + val + '</span> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle" viewBox="0 0 16 16"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"></path><path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"></path></svg>');
                            } else {
                                $('.sub-category-item div[data-category="' + category_no + '"]').html('<span class="user-category-text">' + val + '</span><span class="lux-category-delete"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16"><path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"></path><path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"></path></svg></span><span class="lux-category-modify"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil" viewBox="0 0 16 16"><path d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325z"></path></svg></span>');
                            }
                            $('li.orig').removeClass('hide');
                            $('.sub-category-item').removeClass('hide');
                        } else {
                            if (depth == 1) {
                                $('.add-user-category').before('<li class="orig" data-category="' + r.insert_no + '">' + val + '</li>');
                            } else if (depth == 2) {
                                $('.sub-category-item').removeClass('active').remove();
                                displaySubCategoryList(lux_all_category[parent]['sub']);
                            } else {
                                $('.sub-category-item').removeClass('active').remove();
                                displaySubCategoryList(lux_all_category[root]['sub'][parent]['sub'], true);
                            }
                            enableCategoryButton();
                        }

                    },
                    error: function(xhr, status, error) {
                        $('.input-user-category.active').removeClass('spinner');
                        alert("Error " + xhr.status + " : 관리자에게 문의");
                    }
                });
            }
        });

    $(document)
        .off('click', '.sub-category-item div')
        .on('click', '.sub-category-item div', function(e) {
            var id = $(this).attr('data-category'),
                sub = $(this).attr('data-sub'),
                selected = $(this).text();

            $('.choose-select-category.add li.active').append('<span class="selected" data-category="' + id + '">' + selected + ' <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle" viewBox="0 0 16 16"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/><path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"/></svg></span>');
            if ($(this).hasClass('last')) {
                $('.sub-category-item').removeClass('active').remove();
                if ($('.choose-select-category.add .selected').length == 3) $('.add-user-category').addClass('disable');
                return;
            } else $('.sub-category-item').removeClass('active').remove();

            displaySubCategoryList(lux_all_category[sub]['sub'][id]['sub'], true);
        });

    $(document)
        .off('click', '.choose-select-category.add li > .selected')
        .on('click', '.choose-select-category.add li > .selected', function(e) {
            e.stopPropagation();
            if ($('.input-user-category').hasClass('active')) {
                $('.input-user-category').removeClass('active').hide();
                $('.modal-footer .ok-button-dialog').removeClass('disabled');
            }
            $('.sub-category-item').removeClass('active').remove();
            var category_no = Number($(this).attr('data-category'));
            switch ($(this).index()) {
                case 0:
                    $(this).parent().removeClass('active');
                    $(this).parent().text($(this).text());
                    // $('.add-user-category').addClass('disable').fadeOut(200);
                    // setTimeout(function() {
                    $('.choose-select-category.add li.disable').fadeIn(200).removeClass('disable');
                    // },200);
                    break;
                case 1:
                    $(this).parent().html($('.choose-select-category.add li > .selected').first().outerHTML());
                    var id = $('.choose-select-category.add li > .selected').last().attr('data-category');
                    displaySubCategoryList(lux_all_category[id]['sub']);
                    if (category_no > 1000000000) setTimeout(function() { enableCategoryButton(); }, 500);
                    break;
                case 2:
                    $(this).remove();
                    var id = $('.choose-select-category.add li > .selected').last().attr('data-category'),
                        sub = $('.choose-select-category.add li > .selected').first().attr('data-category');
                    displaySubCategoryList(lux_all_category[sub]['sub'][id]['sub'], true);
                    if (category_no > 1000000000) setTimeout(function() { enableCategoryButton(); }, 500);
                    break;
            }
        });

    var addInputCategoryClose = function(out) {
        $('.sub-category-item').removeClass('hide');
        $('.input-user-category > input').val('');
        $('.input-user-category').removeClass('active').fadeOut(out, function() {
            if (out > 0) $('.choose-select-category.add li.add-user-category').removeClass('disable');
            $('.modal-footer .ok-button-dialog').removeClass('disabled');
        });
    }

    var enableCategoryButton = function() {
        $('.choose-select-category.add li.add-user-category').removeClass('disable').show();
    }

    var displaySubCategoryList = function(o, last, out) {
        $('.sub-category-item').remove();
        var s = '<div class="sub-category-item">';
        $.each(o, function(i, v) {
            s += '<div class="' + ((last) ? 'last' : '') + '" data-category="' + v.category_no + '" data-sub="' + v.parent_category_no + '"><span class="user-category-text">' + v.category_name + '</span></div>';
        });
        s += '</div>';
        $('.add-user-category').before(s);
        // setTimeout(function() {
        $('.sub-category-item').addClass('active');
        // },200);
        if (typeof out != 'undefined') return s;
    }

    var setSelectCategoryHTML = function(r, add) {
        var category_add = (typeof add != 'undefined' && add == true) ? ' add' : '',
            li = '',
            active = '',
            prev_str = '',
            used = [];

        $.each(r.use_category, function(i, v) {
            used.push(v);
        });

        $.each(r.root, function(i, v) {
            var disabled = (used.indexOf(Number(v.category_no)) > -1) ? ' disabled' : '';
            if (typeof r.use_category[Number(selectID)] != 'undifined' && r.use_category[Number(selectID)] == v.category_no) {
                disabled = '';
            }

            active = (v.category_no == r.category_no) ? 'active' : '';
            if (active == 'active') prev_str = v.category_no + ',' + v.category_name;
            if (v.count == -1) v.count = 0;
            li += '<li class="' + active + disabled + ' orig" data-category="' + v.category_no + '"><span class="user-category-text">' + v.category_name + ((add) ? '</span> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle" viewBox="0 0 16 16"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/><path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"/></svg>' : '</span><span class="count">' + number_format(v.count) + '</span></li>');
        });

        var s = '<ul class="choose-select-category' + category_add + '" data-prev="' + prev_str + '">' + li;
        if (add == true) {
            s += '<li class="click-off add-user-category orig"><svg xmlns="http://www.w3.org/2000/svg" width="17" height="17" fill="currentColor" class="bi bi-plus-lg" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 2a.5.5 0 0 1 .5.5v5h5a.5.5 0 0 1 0 1h-5v5a.5.5 0 0 1-1 0v-5h-5a.5.5 0 0 1 0-1h5v-5A.5.5 0 0 1 8 2Z"/></svg> 카테고리 추가</li>';
            s += '<li class="click-off input-user-category" data-depth="1"><input type="text" id="input-user-category" maxlength="20" placeholder="카테고리명을 입력하세요"><span class="input-user-category-close"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-lg" viewBox="0 0 16 16"><path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"></path></svg></span></li>';
            s += '';
        }
        s += '</ul>';
        return s;
    }

    var selectShoppingCategory = function(seq, mode, r, replace) {
        var modal = $(this).showModalFlat('상품 연결', setSelectCategoryHTML(r), true, true, function() {
            modal.modal('hide');

            var choose = $('.choose-select-category li.active').attr('data-category');
            if (typeof choose == 'undefined') {
                alert('선택된 카테고리가 없습니다');
                return false;
            }
            $.modalON();
            setTimeout(function() {
                $('.gallerytype-choose').modal('hide');
                if (replace == true) selectGalleryTypeNreloadList(seq, mode, choose);
                else selectGalleryElement(seq, mode, choose);
            }, 500);
        }, 'config.close', 'config.ok', 'cl-cmmodal cl-s-btn w700 cl-p70 cl-p0 noActive-domain-check,zindex', true, '', '', function() {
            $('.flat-modal.zindex').remove();
            $('.choose-gallery-type li[data-gallery-type]').attr('style', '');
        });
    }

    $(document).on({
        mouseenter: function(e) {
            $(this).parent().addClass('show-category');
        },
        mouseleave: function(e) {
            $(this).parent().removeClass('show-category');
        }
    }, ".cl-s-product-lux-info .lux-category-wrap");

    $(document).on('click', '.choose-select-category li:not(.click-off)', function(e) {
        if ($(this).hasClass('disabled')) return false;
        $('.choose-select-category li').removeClass('active');
        $(this).addClass('active');
    });

    $(document)
        .off('click', '.shop-filter-header .recommend-filter ~ .dropdown-menu li, .shop-filter-header .recommend-filter.brand')
        .on('click', '.shop-filter-header .recommend-filter ~ .dropdown-menu li, .shop-filter-header .recommend-filter.brand', function(e) {
            var key = $(this).attr('data-key'),
                val = $(this).attr('data-val'),
                selected_param = ($('.gallery-modal').length) ? localStorage.getItem(key) : getSearchURL(key);
            if ($(this).hasClass('disabled')) return;

            if ($(this).hasClass('active')) {
                val = ($('.gallery-modal').length) ? removeParameter(key, val, true) : removeParameter(key, val);
            } else {
                if (key == 'brand' || key == 'trend' || key == 'discount_rate') {
                    if ((selected_param || '').indexOf(val) < 0) {
                        val = (selected_param) ? selected_param + ',' + val : val;
                    } else {
                        val = ($('.gallery-modal').length) ? removeParameter(key, val, true) : removeParameter(key, val);
                    }
                }
            }

            if ($('.gallery-modal').length) {
                localStorage.setItem(key, val);
                $.gallery.show($.gallery.block_id, 1);
            } else {
                $.processON();
                location.href = setSearchURL(key, val);
            }
        });

    $(document)
/* head
        .off('click', '.shop-filter-header .checked-filters .item-filter .dropdown-menu li')
        .on('click', '.shop-filter-header .checked-filters .item-filter .dropdown-menu li', function(e) {
            var key = $(this).attr('data-key'),
                val = $(this).attr('data-val');

            if ($('.gallery-modal').length) {
                localStorage.setItem(key, val);
                $.gallery.show($.gallery.block_id, 1);
            } else {
                location.href = setSearchURL(key, val);
            }
        });

    $(document)
        .off('click', '.shop-filter-header .checked-filters li svg')
        .on('click', '.shop-filter-header .checked-filters li svg', function(e) {
            e.stopPropagation();
            var key = $(this).parent().attr('data-key'),
                val = $(this).parent().attr('data-val');

            val = ($('.gallery-modal').length) ? removeParameter(key, val, true) : removeParameter(key, val);
            if ($('.gallery-modal').length) {
                localStorage.setItem(key, val);
                $.gallery.show($.gallery.block_id, 1);
            } else {
                location.href = setSearchURL(key, val);
            }
        });
================================================================        
*/
    .off('click','.shop-filter-header .item-filter .dropdown-menu li')
    .on ('click','.shop-filter-header .item-filter .dropdown-menu li', function(e) {
        var key = $(this).attr('data-key'),
            val = $(this).attr('data-val');

        if($('.gallery-modal').length) { 
            localStorage.setItem(key,val);
            $.gallery.show($.gallery.block_id,1);
        } else {
            location.href = setSearchURL(key,val);
        }
    });

    $(document)
    .off('click','.shop-filter-header .checked-filters .user-checked svg')
    .on ('click','.shop-filter-header .checked-filters .user-checked svg', function(e) {
        e.stopPropagation();
        var key = $(this).parent().attr('data-key'),
            val = $(this).parent().attr('data-val');

        val = ($('.gallery-modal').length) ? removeParameter(key,val,true) : removeParameter(key,val);
        if($('.gallery-modal').length) { 
            localStorage.setItem(key,val);
            $.gallery.show($.gallery.block_id,1);
        } else {
            location.href = setSearchURL(key,val);
        }
    });
/* ============================================================ */

    $(document)
        .off('click', '.shop-filter-header .sub-category, .shop-filter-header .selected-category-item')
        .on('click', '.shop-filter-header .sub-category, .shop-filter-header .selected-category-item', function(e) {
            var key = $(this).attr('data-key'),
                val = $(this).attr('data-val');

            if ($('.gallery-modal').length) {
                localStorage.setItem(key, val);
                $.gallery.show($.gallery.block_id, 1);
            } else {
                location.href = setSearchURL(key, val);
            }
        });

    $(document)
        .off('keyup', '.product-name-input')
        .on('keyup', '.product-name-input', function(e) {
            var key = (e.which) ? e.which : e.keyCode,
                search_name = $(this).val().trim();
            if (key == 13) {
                if (search_name.indexOf(',') > -1 || search_name.indexOf('"') > -1 || search_name.indexOf('%') > -1) {
                    alert('\, \% \" 검색어에 포함될 수 없습니다');
                    return false;
                }
                
                searchProductName($(this));
            }
        });

    $(document)
        .off('click','.search-product-cancel')
        .on ('click','.search-product-cancel', function(e) {
            if($(this).prev().val().trim() == '') return;
            localStorage.removeItem('product_name');
            $('.product-name-input').val('');
            $.processON();
            ($('.gallery-modal').length) ? 
                $.gallery.show($.gallery.block_id,1) :
                location.href = setSearchURL('product_name','');
        });

    $(document)
        .off('click', '.search-product-remove')
        .on('click', '.search-product-remove', function(e) {
            if ($(this).prev().val().trim() == '') return;
            localStorage.removeItem('product_name');
            $('.product-name-input').val('');
            $.processON();
            ($('.gallery-modal').length) ?
                $.gallery.show($.gallery.block_id, 1):
                location.href = setSearchURL('product_name', '');
        });
    /*
        $(document)
        .off('keyup','.prod-search-brand .search-brand-input')
        .on ('keyup','.prod-search-brand .search-brand-input', function(e) {
            var key = (e.which) ? e.which : e.keyCode,
                search_brand = $(this).val().trim(),
                brand_code = '';
            if(key == 13) {
                $.each(product_brand_list, function(i,v) {
                    if(v.brand_name == search_brand) {
                        brand_code = v.brand_code;
                        return false;
                    }
                });
                if(brand_code) {
                    if($('.gallery-modal').length) {
                        localStorage.setItem('brand',brand_code);
                        $.gallery.show(selectID,1);
                    } else location.href = setSearchURL('brand',brand_code);
                }
            }
        });
    */
    function searchProductName($input) {
        var params = getProductParams(),
            stx = $input.val().trim();

        if (stx.length) {
            if ($('.gallery-modal').length) {
                localStorage.setItem('product_name', stx);
                $.gallery.show($.gallery.block_id, 1);
            } else {
                $.processON();
                location.href = setSearchURL('product_name', stx);
            }
        }
    }

    function removeElementByIndex(array, index) {
        if (index > -1) { // 제거할 인덱스가 배열 범위 내에 있는 경우
            array.splice(index, 1); // 해당 인덱스의 원소를 제거
        }
        return array;
    }

    function getAddSearches() {
        var searches = (localStorage.getItem('searches_' + $.lux.select_type) === null || localStorage.getItem('searches_' + $.lux.select_type) == '[null]') ? [] : JSON.parse(localStorage.getItem('searches_' + $.lux.select_type)),
            sort = $('.lux-product-search .sort-filter .type_filter').attr('data-val');
        sort = (sort) ? sort : 'new';
        $.each(searches, function(i,v) {
            if(v == null) return true;            
            searches[i]['sort'] = sort;
        });        
               
        return searches;
    }

    function resetAddSearches() {
      var s = getAddSearches();
      localStorage.removeItem('searches_' + $.lux.select_type);
    }

    function defaultProductParams() {
        return {
            'category_no': '',
            'brand': '',
            'trend': '',
            'discount_rate': '',
            'min_sale': '',
            'max_sale': '',
            'min_price': '',
            'max_price': '',
            'filter': '',
            'product_name': '',
            'sort': '',
            'prod_case': ''
        }
    }

    function getStorageItem(key) {
        if(typeof key == 'undefined' || key == '') return '';

        $default_val = '';
        switch(key) {
            case 'gallery-product-filter':  $default_val = 'all'; break;
            case 'gallery-product-view':    $default_val = 0; break;
            case 'gallery-product-page':    $default_val = 1; break;
            default:                        $default_val = ''; break;
        }

        return (localStorage.getItem(key) === null) ? $default_val : localStorage.getItem(key);
    }

    function getProductParams(key) {
        var r = {
            'category_no': (localStorage.getItem('category_no') === null) ? '' : localStorage.getItem('category_no'),
            'brand': (localStorage.getItem('brand') === null) ? '' : localStorage.getItem('brand'),
            'trend': (localStorage.getItem('trend') === null) ? '' : localStorage.getItem('trend'),
            'discount_rate': (localStorage.getItem('discount_rate') === null) ? '' : localStorage.getItem('discount_rate'),
            'min_sale': (localStorage.getItem('min_sale') === null) ? '' : localStorage.getItem('min_sale'),
            'max_sale': (localStorage.getItem('max_sale') === null) ? '' : localStorage.getItem('max_sale'),
            'min_price': (localStorage.getItem('min_price') === null) ? '' : localStorage.getItem('min_price'),
            'max_price': (localStorage.getItem('max_price') === null) ? '' : localStorage.getItem('max_price'),
            'filter': (localStorage.getItem('filter') === null) ? '' : localStorage.getItem('filter'),
            'product_name': (localStorage.getItem('product_name') === null) ? '' : localStorage.getItem('product_name'),
            'sort': (localStorage.getItem('sort') === null) ? '' : localStorage.getItem('sort'),
            'prod_case': (localStorage.getItem('prod_case') === null) ? '' : localStorage.getItem('prod_case'),
        }
        if (typeof key != 'undefined') return r[key];
        else {
            var isNull = true;
            $.each(r, function(i, v) {
                if (v.length) isNull = false;
            });
            if (isNull) return null;
            else return r;
        }
    }

    function setSearchesIndexValue(key, value) {
        var idx = $('.search-list .search-group.active').index(),
            searches = getAddSearches();

        if (idx < 0 || typeof key == 'undefined') return false;

        // var o = searches[idx][key];
        // if(o.length) {
        //     o+= ',' + value;
        // } else o = value;
        if (searches.length == 0 || searches === null || searches[0] == null) {
            searches = [];
            searches.push(defaultProductParams());
            searches[idx][key] = value;
        } else {
            searches[idx][key] = value;
        }

        // localStorage.setItem('searches', JSON.stringify(searches));
        localStorage.setItem('searches_' + $.lux.select_type, JSON.stringify(searches));        
        resetLocalStorageSearch();
        return true;
    }

    function setProductParams(params) {
        $.each(params, function(k, v) {
            if (v.length) {
                localStorage.setItem(k, v);
            }
        });
    }

    function resetProductParams() {
        localStorage.removeItem('category_no');
        localStorage.removeItem('brand');
        localStorage.removeItem('trend');
        localStorage.removeItem('discount_rate');
        localStorage.removeItem('min_sale');
        localStorage.removeItem('max_sale');
        localStorage.removeItem('min_price');
        localStorage.removeItem('max_price');
        localStorage.removeItem('filter');
        localStorage.removeItem('product_name');
        localStorage.removeItem('sort');
        localStorage.removeItem('prod_case');
        localStorage.removeItem('add_search');
        localStorage.removeItem('searches');
    }

    function resetLocalStorageSearch() {
        localStorage.removeItem('category_no');
        localStorage.removeItem('brand');
        localStorage.removeItem('trend');
        localStorage.removeItem('discount_rate');
        localStorage.removeItem('min_sale');
        localStorage.removeItem('max_sale');
        localStorage.removeItem('min_price');
        localStorage.removeItem('max_price');
        localStorage.removeItem('filter');
        localStorage.removeItem('product_name');
        localStorage.removeItem('sort');
        localStorage.removeItem('prod_case');
    }

    function resetSearches() {
        localStorage.removeItem('searches_lux');
        localStorage.removeItem('searches_shopping');
        localStorage.removeItem('searches_project');
        localStorage.removeItem('searches_gallery');
    }

    function removeParameter(key, remove, mode) {
        var param = (mode == true) ? localStorage.getItem(key) : getSearchURL(),
            s = (mode == true) ? param : param[key],
            val = (s || '').split(',');

        var r = arrayRemove(val, remove);
        return (r.length) ? r.join(',') : '';
    }

    function getSearchURL(key) {
        var location = window.location.href,
            url = new URL(location),
            param = url.searchParams;

        var r = {};
        if(typeof key != 'undefined' && key) {
            r[key] = (param.get(key) == null) ? '' : param.get(key);
        } else {
            r = {
                'category_no' : (param.get('category_no') == null) ? '' : param.get('category_no'),
                'brand' : (param.get('brand') == null) ? '' : param.get('brand'),
                'trend' : (param.get('trend') == null) ? '' : param.get('trend'),
                'discount_rate' : (param.get('discount_rate') == null) ? '' : param.get('discount_rate'),
                'min_sale' : (param.get('min_sale') == null) ? '' : param.get('min_sale'),
                'max_sale' : (param.get('max_sale') == null) ? '' : param.get('max_sale'),
                'min_price' : (param.get('min_price') == null) ? '' : param.get('min_price'),
                'max_price' : (param.get('max_price') == null) ? '' : param.get('max_price'),
                'filter' : (param.get('filter') == null) ? '' : param.get('filter'),
                'product_name' : (param.get('product_name') == null) ? '' : param.get('product_name'),
                'sort' : (param.get('sort') == null) ? '' : param.get('sort'),
            }
        }

        $.each(r, function(r_k, r_v) {
            switch(r_k) {
                case 'trend':
                    var trend = (r_v) ? r_v.split(',') : [];
                    $(trend).each(function(k, v) {
                        $('.recommend-filter.list-filter + .dropdown-menu [data-key="trend"][data-val="' + v + '"]').addClass('active');
                    });
                    break;
                case 'min_sale':
                case 'max_sale':
                    break;
                case 'discount_rate':
                    var discount_rate = (r_v) ? r_v.split(',') : [];
                    $(discount_rate).each(function(k, v) {
                        $('.recommend-filter.list-filter + .dropdown-menu [data-key="discount_rate"][data-val="' + v + '"]').addClass('active');
                    });
                    break;

                case 'product_name':
                    $('.search-product input.product-name-input').val(r_v);
                    break;

                case 'sort':
                    if(r_v == '') r_v = 'new'; 
                    $('.checked-filters li[data-key="sort"][data-val="' + r_v + '"]').addClass('active');
                    var sort_active_str = $('.checked-filters li[data-key="sort"].active').eq(0).text();
                    $('.checked-filters .type_filter').text(sort_active_str);
                    break;

                default:
                    if($.inArray(r_k, ['min_price', 'max_price']) > -1 && r_v) {
                        $('.recommend-filter.list-filter + .dropdown-menu [data-key="' + r_k + '"][data-val="' + r_v + '"]').addClass('active');
                    }
                    break;
            }
        });

        return (typeof key != 'undefined') ? r[key] : r;
    }

    function setSearchURL(k, v) {
        var param = getSearchURL();
        // 초기 category_no
        if (param.category_no == '') {
            var searches = getAddSearches();
            param.category_no = searches[0].category_no;
        }
        param[k] = v;
        setProductParams(param);
        var page = (typeof PAGE == 'undefined') ? property.PAGE : PAGE;
        if (typeof MODE == 'undefined') { // render
            var url = (property.LOAD == 'RENDER') ? '/render/' : '/';
            return url + page + 
              '?category_no=' + param.category_no + 
              '&brand=' + param.brand + 
              '&trend=' + param.trend + 
              '&discount_rate=' + param.discount_rate + 
              '&min_sale=' + param.min_sale + 
              '&max_sale=' + param.max_sale + 
              '&min_price=' + param.min_price + 
              '&max_price=' + param.max_price + 
              '&filter=' + param.filter + 
              '&product_name=' + param.product_name + 
              '&sort=' + param.sort;
        } else { // config
            return '/config/page/' + page + 
              '?category_no=' + param.category_no + 
              '&brand=' + param.brand + 
              '&trend=' + param.trend + 
              '&discount_rate=' + param.discount_rate + 
              '&min_sale=' + param.min_sale + 
              '&max_sale=' + param.max_sale + 
              '&min_price=' + param.min_price + 
              '&max_price=' + param.max_price + 
              '&filter=' + param.filter + 
              '&product_name=' + param.product_name + 
              '&sort=' + param.sort;
        }
    }

    var shopHeaderDisplaySkin = function($tag,data) {
        if(typeof data.mode == 'undefined' || data.mode != 'shopping') return;
        var checkDefaultCall = false;

        var shd_skin = $tag.attr('data-skin'),
            shd_row_class = 'goption-row',
            shd_r = data.category_info;

        var $cate_selected_ul = $('<ul class="selected-category-list"></ul>'),
            cate_full = (typeof shd_r.selected != 'undefined' && shd_r.selected.full_category_no != null) ? shd_r.selected.full_category_no : [],
            cate_last_name = '',
            cate_last_val = '';
        if(typeof shd_r != 'undefined' && typeof shd_r.selected != 'undefined' && typeof shd_r.selected.full_category_name != 'undefined' && shd_r.selected.full_category_name != null) {
            $.each(shd_r.selected.full_category_name, function(i,v) {
                if(v != null && i < 3) {
                    cate_last_name = v;
                    cate_last_val = cate_full[i];
                    $cate_selected_ul.append('<li class="selected-category-item hand" data-key="category_no" data-val="' + cate_last_val + '">' + cate_last_name + '</li>');
                }
            });
        }
        $cate_selected_ul.find('li:last').addClass('active');

        var $cate_h1 = $('<h1 class="selected-category-h1">' + cate_last_name + '</h1>');

        var $cate_sub_ul = $('<ul class="sub-category-list"></ul>'),
            checkCateSub = false;
        $.each(shd_r.sub, function(i,o) {
            var cate_sub_active = (shd_r.selected.category_no == o.category_no) ? 'active' : '';
            if(cate_sub_active != '') checkCateSub = true;

            var cate_sub_name = o.category_name;
            if($.inArray(shd_skin, ['000']) > -1) cate_sub_name += '<span class="count">' + number_format(s.count) + '</span>';
            if($.inArray(shd_skin, ['001','002','003']) > -1) cate_sub_name = '<span class="sub-category-name">' + cate_sub_name + '</span>';

            $cate_sub_ul.append('<li class="sub-category ' + cate_sub_active + '" data-key="category_no" data-val="' + o.category_no + '">' + cate_sub_name + ' </li>');
        });
        if(typeof shd_r.selected != 'undefined' && typeof shd_r.selected.category_no != 'undefined') {
            var all_cate_sub_name = ($.inArray(shd_skin, ['001','002','003']) > -1) ? '<span class="sub-category-name">전체</span>' : '전체';
            $cate_sub_ul.prepend('<li class="sub-category all-sub-category ' + ((checkCateSub) ? '' : 'active') + '" data-key="category_no" data-val="' + cate_last_val + '">' + all_cate_sub_name + '</li>');
        }

        var $search_product = $('<div class="search-product"></div>'),
            $search_product_input = $('<input type="text" class="product-name-input form-control" placeholder="상품명 검색" enterkeyhint="search" value="">'),
            $search_product_cancel = $('<span class="search-product-cancel">' + clSVG('close_m','16','16',false,'') + '</span>'),
            $search_product_search = $('<span class="search-product-btn">' + clSVG('search','16','16',false,'') + '</span>');


        var checkBrand = (  typeof data.category_info.uri != 'undefined' && 
                            typeof data.category_info.uri.brand != 'undefined' && (data.category_info.uri.brand).length
                        ) ? false : (($.inArray(shd_skin, ['001','002','003']) > -1) ? false : true),
            $search_filter = $('<div class="filter-wrap">' + ChooseFilters(checkBrand) + '</div>');

        var sort_filter_ul = ($.inArray(shd_skin, ['001','002','003']) > -1) ? 'div' : 'ul',
            sort_filter_li = ($.inArray(sort_filter_ul, ['div']) > -1) ? sort_filter_ul : 'li',
            $sort_filter = $('\
                <'+ sort_filter_ul + '>\
                    <' + sort_filter_li + ' class="btn-group">\
                        <button type="button" class="dropdown-toggle recommend-filter list-filter dropdown-button item-filter" data-toggle="dropdown">\
                            <span class="type_filter">신상품</span>\
                            <svg width="12" height="12" fill="currentColor" class="bi bi-chevron-down" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"></path></svg>\
                        </button>\
                        <ul class="dropdown-menu">\
                            <li data-key="sort" data-val="new">신상품</li>\
                            <li data-key="sort" data-val="name">상품명</li>\
                            <li data-key="sort" data-val="low">낮은가격</li>\
                            <li data-key="sort" data-val="high">높은가격</li>\
                        </ul>\
                    </' + sort_filter_li + '>\
                </'+ sort_filter_ul + '>\
            ');


        var checked_filter_ul = ($.inArray(shd_skin, ['001']) > -1) ? 'div' : 'ul',
            checked_filter_li = ($.inArray(checked_filter_ul, ['div']) > -1) ? checked_filter_ul : 'li',
            $checked_filter_item = $('<' + checked_filter_li + ' class="user-checked"><span></span> ' + clSVG('close_m_thin',16,16,false) + '</' + checked_filter_li + '>'),
            $checked_filter = $('<' + checked_filter_ul + ' class="checked-filters"></' + checked_filter_ul + '>');
        if(typeof shd_r.checked != 'undefined' && shd_r.checked) {
            $.each(shd_r.checked, function(i,o) {
                var $tmp_cf = $checked_filter_item.clone();
                $tmp_cf.attr({'data-key': o.key, 'data-val': o.val});
                $tmp_cf.find(' > span').text(o.str);
                $checked_filter.append($tmp_cf);
            });
        }

        var result_total = (typeof data.total != 'undefined' && typeof data.total.list_total != 'undefined' && data.total.list_total) ? data.total.list_total : 0,
            result_title = ($.inArray(shd_skin, ['001','002','003']) > -1) ? '<h1>검색결과</h1>' : '',
            $result_summary = $('<div class="result-summary">' + result_title + ' <span class="total">' + addCommas(result_total) + '</span><span class="unit">개</span></div>');

        switch(shd_skin) {
            case '001':
                $tag.append($search_product.addClass('clearfix').append($search_product_input.attr('placeholder', '상품 검색')).append($search_product_search))
                    .append($cate_selected_ul)
                    .append($cate_sub_ul)
                    .append('<div class="line-wrap"><hr class="line"/></div>')
                    .append($search_filter.addClass('clearfix'))
                    .append($checked_filter);
                
                $sort_filter.find('.type_filter + svg').replaceWith(clSVG('caret',8,4,false));
                $sort_filter.find('.btn-group').addClass('pull-right');
                $tag.append($sort_filter.addClass('last clearfix').prepend($result_summary));
                break;

            case '002':
                $tag.append($cate_selected_ul.addClass('clearfix'))
                    .append($search_product.addClass('clearfix').append($search_product_input.attr('placeholder', '상품 검색')).append($search_product_search))
                    .append('<div class="clearfix"></div>')
                    .append($cate_h1.addClass('clearfix'))
                    .append($cate_sub_ul)
                    .append('<div class="line-wrap"><hr class="line"/></div>')
                    .append($search_filter.addClass('clearfix'))
                    .append($checked_filter);

                $sort_filter.find('.type_filter + svg').replaceWith(clSVG('caret',8,4,false));
                $sort_filter.find('.btn-group').addClass('pull-right');
                $tag.append($sort_filter.addClass('last clearfix').append($result_summary));

                if($tag.find('.checked-filters').is(':empty')) $tag.find('.last.clearfix > div').css('margin-right', '8px');
                break;

            case '003':
                $tag.append($cate_selected_ul.addClass('clearfix'))
                    .append('<div class="clearfix"></div>')
                    .append($cate_h1.addClass('clearfix'))
                    .append($cate_sub_ul)
                    .append('<div class="line-wrap"><hr class="line"/></div>')
                    .append($search_filter.addClass('clearfix'))
                    .append($checked_filter);

                $sort_filter.find('.type_filter + svg').replaceWith(clSVG('caret',8,4,false));
                $sort_filter.find('.btn-group').addClass('pull-right');
                $tag.append($sort_filter.addClass('last clearfix').append($result_summary));
                $tag.find('h1.selected-category-h1').append('<div class="result-summary"><span class="total">' + addCommas(result_total) + '</span><span class="unit">개 상품</span></div>').wrap('<div></div>');
                $tag.find('h1.selected-category-h1').before($search_product.addClass('clearfix').append($search_product_input.attr('placeholder', '상품 검색')).append($search_product_search));

                if($tag.find('.checked-filters').is(':empty')) $tag.find('.last.clearfix > div').css('margin-right', '8px');
                break;

            default:
                checkDefaultCall = true;
                break;
        }

        if(checkDefaultCall) {
            $tag.removeAttr('data-skin');
            shopHeaderDisplay($tag,data);
            return;
        } else {
            getSearchURL();

            if($tag.closest('[class*="el_"]').length > 0 && $tag.closest('[class*="el_"]').find('.full-width').length > 0) $tag.addClass('full-width');
            else $tag.removeClass('full-width');

            $tag.children().addClass('goption-row');
        }

        var brand_search = (typeof data.brand_search != 'undefined' && typeof data.brand_search.tag != 'undefined' && data.brand_search.tag) ? data.brand_search.tag : '';
        shopBrandInputAutocomplete(data.brand_list, brand_search);

    }

    var shopHeaderDisplay = function($tag,data) {
        var checkLUX = typeof LUX != 'undefined' ? LUX : property.LUX;
        if(checkLUX && $tag.closest('.element').is('[data-type="gallery"][data-mode="shopping"]')) $tag.closest('.element').addClass('cl-lux-gallery');

        if(typeof data.category_info == 'undefined' || data.only_category == 'false' || data.only_category == false) return;
        if(typeof $tag.attr('data-skin') != 'undefined' && $tag.attr('data-skin')) {
            shopHeaderDisplaySkin($tag,data);
            return;
        }
        var brandChecked = (typeof data.category_info.uri != 'undefined' && 
                            typeof data.category_info.uri.brand != 'undefined' && (data.category_info.uri.brand).length
                          ) ? false : true;
        $tag.prepend('<ul class="goption-row checked-filters"></ul>');
        $tag.prepend('<div class="goption-row filter-wrap">' + ChooseFilters(brandChecked) + '</div>');
        $tag.prepend('<ul class="goption-row sub-category-list"></ul>');
        $tag.prepend('<ul class="goption-row selected-category-list"></ul>');
        selected_category = data.category_info;

        // lux shopping selected category
        if (typeof selected_category == 'object' && data.mode == 'shopping') {
            var $category_nav = $tag.find('.selected-category-list'),
                full_category_no = selected_category.selected.full_category_no;
            last_category_no = '';
            if (selected_category.selected.full_category_name !== null) {
                $.each(selected_category.selected.full_category_name, function(c, s) {
                    if (s != null && c < 3) {
                        $category_nav.append('<li class="selected-category-item hand" data-key="category_no" data-val="' + full_category_no[c] + '">' + s + '</li>');
                        last_category_no = full_category_no[c];
                    }
                });
            }
            // search 
            var product_name_input = ($('.gallery-modal').length) ? getProductParams('product_name') : getSearchURL('product_name');
            $category_nav.append('<li class="search-product"><input type="text" class="form-control product-name-input" placeholder="상품명 검색" enterkeyhint="search" value="' + product_name_input + '"><span class="search-product-cancel"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-lg" viewBox="0 0 16 16"><path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"/></svg></span></li>');

            var $sub_category = $tag.find('.sub-category-list'),
                sub_category_selected = false;
            $.each(selected_category.sub, function(c, s) {
                var active = (selected_category.selected.category_no == s.category_no) ? 'active' : '';
                if (active.length) sub_category_selected = true;

                $sub_category.append('<li class="sub-category ' + active + '" data-key="category_no" data-val="' + s.category_no + '">' + s.category_name + ' <span class="count">' + number_format(s.count) + '</span></li>');
            });

            if (typeof selected_category.selected != 'undefined' && typeof selected_category.selected.category_no != 'undefined') {
                $sub_category.prepend('<li class="sub-category all-sub-category ' + ((sub_category_selected) ? '' : 'active') + '" data-key="category_no" data-val="' + last_category_no + '">전체</li>');
            }

            $.each(selected_category.checked, function(s,l) {
                $tag.find('.checked-filters').append('<li class="user-checked" data-key="' + l.key + '" data-val="' + l.val + '">' + l.str + ' ' + clSVG('close_m_thin',16,16,false) + '</li>');
            });

            if ($tag.find('.checked-filters .list-filter').length == 0) {
                var selected = ($('.gallery-modal').length) ? getProductParams('sort') : getSearchURL('sort'),
                    filters = {
                        'new': '신상품',
                        'name': '상품명',
                        'low': '낮은가격',
                        'high': '높은가격'
                    };
                if (selected == '') selected = 'new';
                var s = '\
                <div class="btn-group list-filter">\
                    <button type="button" class="dropdown-toggle recommend-filter dropdown-button item-filter" data-toggle="dropdown">\
                        <span class="type_filter">' + filters[selected] + '</span>\
                        <svg width="12" height="12" fill="currentColor" class="bi bi-chevron-down" viewBox="0 0 16 16">\
                            <path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"></path>\
                        </svg>\
                    </button>\
                    <ul class="dropdown-menu">\
                        <li data-key="sort" data-val="new">신상품</li>\
                        <li data-key="sort" data-val="name">상품명</li>\
                        <li data-key="sort" data-val="low">낮은가격</li>\
                        <li data-key="sort" data-val="high">높은가격</li>\
                    </ul>\
                </div>\
                ';
                /*
                <li data-key="filter" data-val="hot">인기상품</li>\
                <li data-key="filter" data-val="review">사용후기</li>\
                */

                var prod_cases = { 'A': '전체', 'M': '수정상품', 'O': '사입상품', 'H': '숨김상품', 'S': '품절상품' };
                var prod_case_value = getProductParams('prod_case');
                if (!prod_case_value) prod_case_value = 'A'; 
                if ($('.gallery-modal').length) { // 상품관리 모달 열린상태
                    s += '<div class="btn-group list-filter">\
                            <button type="button" class="dropdown-toggle recommend-filter list-filter dropdown-button" data-toggle="dropdown">\
                                <span class="type_prod_case">' + prod_cases[prod_case_value] + '</span>\
                                <svg width="12" height="12" fill="currentColor" class="bi bi-chevron-down" viewBox="0 0 16 16">\
                                    <path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"></path>\
                                </svg>\
                            </button>\
                            <ul class="dropdown-menu">\
                    ';
                    $.each(prod_cases, function(k, v) {
                        s += '<li class="" data-key="prod_case" data-val="' + k + '">' + v + '</li>';
                    });

                    s += '\
                            </ul>\
                        </div>';
                }

                $tag.find('.checked-filters').append(s);
            }
        }

        // lux shopping filter active
        if(data.mode == 'shopping') {
            if($('.gallery-modal').length == 0) var tmp_filter = getSearchURL();
            var trend = localStorage.getItem('trend'),
                discount_rate = localStorage.getItem('discount_rate'),
                min_sale = localStorage.getItem('min_sale'),
                max_sale = localStorage.getItem('max_sale'),
                min_price = localStorage.getItem('min_price'),
                max_price = localStorage.getItem('max_price'),
                filter = localStorage.getItem('filter');

            $.each((trend || '').split(','), function(s, l) {
                $tag.find('.filter-wrap li[data-key="trend"][data-val="' + l + '"]').addClass('active');
            });
            $.each((discount_rate || '').split(','), function(s, l) {
                $tag.find('.filter-wrap li[data-key="discount_rate"][data-val="' + l + '"]').addClass('active');
            });
            $tag.find('.filter-wrap li[data-key="min_price"][data-val="' + min_price + '"]').addClass('active');
            $tag.find('.filter-wrap li[data-key="max_price"][data-val="' + max_price + '"]').addClass('active');
            $tag.find('.filter-wrap li[data-key="filter"][data-val="' + filter + '"]').addClass('active');
        }
        // lux brand
        // var tags = [];
        // $.each(data.brand_list, function(i,v) {
        //     tags.push(v.brand_name);
        // });
        
        var brand_search = (typeof data.brand_search != 'undefined' && typeof data.brand_search.tag != 'undefined' && data.brand_search.tag) ? data.brand_search.tag : '';
        shopBrandInputAutocomplete(data.brand_list, brand_search);
    }

    var shopBrandInputAutocomplete = function(list, search) {
        if(typeof search == 'undefined') search = '';

        $('.search-brand-input').autocomplete({
            source: search,
            appendTo: '.prod-search-brand',
            focus: function(event, ui) {
                $('.ui-autocomplete li').removeClass('active');
                if (ui.item.value == '') return false;
                $('.ui-autocomplete li a:contains("' + ui.item.value + '")').parent().addClass('active');
                return false;
            },
            select: function(event, ui) {
                if (ui.item.value == '') {
                    event.preventDefault();
                    return false;
                }
                var selected = ui.item.value,
                    val = selected.split(" ["),
                    search_brand = '',
                    brand_code = '';
                ui.item.value = val[0];

                search_brand = val[0];
                $.each(list, function(i,v) {
                    if(v.brand_name == search_brand) {
                        brand_code = v.brand_code;
                        return false;
                    }
                });
                if (brand_code) {
                    if ($('.gallery-modal').length) {
                        localStorage.setItem('brand', brand_code);
                        $.gallery.show($.gallery.block_id, 1);
                    } else {
                        $.processON();
                        location.href = setSearchURL('brand', brand_code);
                    }
                }
            },
            response: function(event, ui) {
                if (ui.content.length == 0) {
                    ui.content.push({ value: '', label: '검색되는 브랜드가 없습니다.' });
                }
            }
        });
    }
    var getRecordHtml = function(service) {
        var str = '';
        switch (service) {
            case 'go':
                str += '\
                <div class="table-wrap">\
                    <table>\
                        <colgroup>\
                            <col width="120px"></col>\
                            <col width="75px"></col>\
                            <col width="85px"></col>\
                            <col width="60px"></col>\
                            <col width="*"></col>\
                        </colgroup>\
                        <thead>\
                            <tr><td>' + $.lang[LANG]['domain.connect.record.title.name'] + '</td><td>' + $.lang[LANG]['domain.connect.record.title.ttl'] + '</td><td>' + $.lang[LANG]['domain.connect.record.title.type'] + '</td><td>' + $.lang[LANG]['domain.connect.record.title.priority'] + '</td><td>' + $.lang[LANG]['domain.connect.record.title.val'] + '</td></tr>\
                        </thead>\
                        <tbody>\
                            <tr><td>' + $.lang[LANG]['domain.connect.record.content.blank.1'] + '</td><td>3600</td><td>MX</td><td>1</td><td>ASPMX.L.GOOGLE.COM</td></tr>\
                            <tr><td>' + $.lang[LANG]['domain.connect.record.content.blank.1'] + '</td><td>3600</td><td>MX</td><td>5</td><td>ALT1.ASPMX.L.GOOGLE.COM</td></tr>\
                            <tr><td>' + $.lang[LANG]['domain.connect.record.content.blank.1'] + '</td><td>3600</td><td>MX</td><td>5</td><td>ALT2.ASPMX.L.GOOGLE.COM</td></tr>\
                            <tr><td>' + $.lang[LANG]['domain.connect.record.content.blank.1'] + '</td><td>3600</td><td>MX</td><td>10</td><td>ALT3.ASPMX.L.GOOGLE.COM</td></tr>\
                            <tr><td>' + $.lang[LANG]['domain.connect.record.content.blank.1'] + '</td><td>3600</td><td>MX</td><td>10</td><td>ALT4.ASPMX.L.GOOGLE.COM</td></tr>\
                        </tbody>\
                    </table>\
                </div>\
                </div>';
                break;

            case 'nv':
                str += '\
                <div class="table-wrap">\
                    <table>\
                        <colgroup>\
                            <col width="180px"></col>\
                            <col width="60px"></col>\
                            <col width="*"></col>\
                        </colgroup>\
                        <thead>\
                            <tr><td>' + $.lang[LANG]['domain.connect.record.title.name'] + '</td><td>' + $.lang[LANG]['domain.connect.record.title.priority'] + '</td><td>' + $.lang[LANG]['domain.connect.record.title.record'] + '</td></tr>\
                        </thead>\
                        <tbody>\
                            <tr><td>' + $.lang[LANG]['domain.connect.record.content.blank.2'] + '</td><td>10</td><td>kr1-aspmx1.worksmobile.com.</td></tr>\
                            <tr><td>' + $.lang[LANG]['domain.connect.record.content.blank.2'] + '</td><td>20</td><td>kr1-aspmx2.worksmobile.com.</td></tr>\
                        </tbody>\
                    </table>\
                </div>\
                </div>';
                break;

            case 'dm':
                str += '\
                <div class="table-wrap">\
                    <table>\
                        <colgroup>\
                            <col width="160px"></col>\
                            <col width="60px"></col>\
                            <col width="*"></col>\
                        </colgroup>\
                        <thead>\
                            <tr><td>' + $.lang[LANG]['domain.connect.record.title.name'] + '</td><td>' + $.lang[LANG]['domain.connect.record.title.priority'] + '</td><td>' + $.lang[LANG]['domain.connect.record.title.record'] + '</td></tr>\
                        </thead>\
                        <tbody>\
                            <tr><td>' + $.lang[LANG]['domain.connect.record.content.blank.2'] + '</td><td>10</td><td>ASPMX.daum.net.</td></tr>\
                            <tr><td>' + $.lang[LANG]['domain.connect.record.content.blank.2'] + '</td><td>20</td><td>ALT.ASPMX.daum.net.</td></tr>\
                        </tbody>\
                    </table>\
                </div>\
                </div>';
                break;

            case 'hi':
                str += '\
                <div class="table-wrap">\
                    <table>\
                        <colgroup>\
                            <col width="130px"></col>\
                            <col width="85px"></col>\
                            <col width="60px"></col>\
                            <col width="*"></col>\
                        </colgroup>\
                        <thead>\
                            <tr><td>' + $.lang[LANG]['domain.connect.record.title.name'] + '</td><td>' + $.lang[LANG]['domain.connect.record.title.type'] + '</td><td>' + $.lang[LANG]['domain.connect.record.title.priority'] + '</td><td>' + $.lang[LANG]['domain.connect.record.title.val'] + '</td></tr>\
                        </thead>\
                        <tbody>\
                            <tr><td>@</td><td>MX</td><td>1</td><td>mailapp.hiworks.co.kr.</td></tr>\
                            <tr><td>hiworks</td><td>CNAME</td><td>5</td><td>hiworksapp.hiworks.co.kr.</td></tr>\
                            <tr><td>webmail</td><td>CNAME</td><td>5</td><td>hiworksapp.hiworks.co.kr.</td></tr>\
                            <tr><td>mail</td><td>CNAME</td><td>10</td><td>mailapp.hiworks.co.kr</td></tr>\
                            <tr><td>pop3</td><td>CNAME</td><td>10</td><td>mailapp.hiworks.co.kr.</td></tr>\
                            <tr><td>@</td><td>TXT(SPF)</td><td>10</td><td>v=spf1 include:_spf.hiworks.co.kr ~all</td></tr>\
                        </tbody>\
                    </table>\
                </div>\
                </div>';
                break;

            case 'mp':
                str += '\
                <div class="table-wrap">\
                    <table>\
                        <colgroup>\
                            <col width="130px"></col>\
                            <col width="85px"></col>\
                            <col width="60px"></col>\
                            <col width="*"></col>\
                        </colgroup>\
                        <thead>\
                            <tr><td>' + $.lang[LANG]['domain.connect.record.title.name'] + '</td><td>' + $.lang[LANG]['domain.connect.record.title.type'] + '</td><td>' + $.lang[LANG]['domain.connect.record.title.priority'] + '</td><td>' + $.lang[LANG]['domain.connect.record.title.val'] + '</td></tr>\
                        </thead>\
                        <tbody>\
                            <tr><td>' + $.lang[LANG]['domain.connect.record.content.blank.2'] + '</td><td>MX</td><td>10</td><td>mx01.mailplug.com.</td></tr>\
                            <tr><td>' + $.lang[LANG]['domain.connect.record.content.blank.2'] + '</td><td>MX</td><td>20</td><td>mx02.mailplug.com.</td></tr>\
                            <tr><td>mail</td><td>CNAME</td><td></td><td>m79.mailplug.com</td></tr>\
                            <tr><td>' + $.lang[LANG]['domain.connect.record.content.blank.2'] + '</td><td>TXT(SPF)</td><td></td><td>v=spf1 mx include:mailplug.com ~all</td></tr>\
                        </tbody>\
                    </table>\
                </div>\
                </div>';
                break;

            case 'etc':
                var suadmin = '<?=SU_EADMIN?>',
                    url = (suadmin) ? "https://creatorlink.net/help" : "";

                str += '\
                <div class="etc-info">\
                    <p>' + $.lang[LANG]['domain.connect.mx.info.text.1'] + '<a href="' + url + '" target="_blank">' + $.lang[LANG]['domain.connect.mx.info.text.2'] + '</a>' + $.lang[LANG]['domain.connect.mx.info.text.3'] + '</p>\
                    <div class="info-text">\
                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13zm0 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><path d="M6 3h1v5H6zM6 9h1v1H6z"/></svg>' + $.lang[LANG]['domain.connect.mx.info.text.4'] + '\
                    </div>\
                </div>';
                break;
        }

        return str;
    }

    var setFixedMenuCss = function(checkEllist) {      
        // console.log('setFixedMenuCss :: 로고 / 확장기능 버튼 height,line-height 추가');
        var fh_selector = (checkEllist) ? '.elviewhtml header.navbar[data-fixtype]' : 'header.navbar[data-fixtype]',
            $fh = $(fh_selector);

        if($fh.length == 0) return false;
        var fh_type = $fh.attr('data-fh-type'),
            fixtypeNum = $fh.attr('data-fixtype').replace(/(top|sidebar)\_/gi, ''),
            fixtypeArr = ['01', '02', '03', '08'];
        if($fh.find('#fixed-menu').find('.cl-visible').length == 0 && fh_type=='top') $fh.find('.fh-container').remove();

        var check_color_panel = ($('.elmenu-content').length > 0) ? 60 : 49,
            fixed_mn_width = $fh.find('.cl-fixed-menu').width() + check_color_panel,
            fixed_mn_height = $fh.find('#tpl-menu li').height(),
            navbarHeader_width = $fh.find('.navbar-header').width(),
            check_fixed_mn = ($fh.find('.cl-fixed-menu').length>0) ? true : false;

        logo_mn_height = ($fh.find('.navbar-brand img').height() > $fh.find('#tpl-menu').height()) ? '' : fixed_mn_height;

        if($fh.find('.cl-menu-option').length > 0) {
            if($fh.find('.cl-menu-option').is('[data-mwidth="all"]') && $fh.is('[data-fh-type="right"]')) {
                var fixed_m_w = $fh.find('.cl-fixed-menu').outerWidth(),
                    moption_row_padding = {};

                if($fh.find('.cl-menu-option').is('.nfullDrop')) moption_row_padding = {};
                else if($fh.is('[data-fixtextalign="center"]')) moption_row_padding = {'padding-left':fixed_m_w+'px','padding-right':fixed_m_w+'px'};
                else if($fh.is('[data-fixtextalign="right"]')) moption_row_padding = {'padding-right':fixed_m_w+'px'};

                if($.isEmptyObject(moption_row_padding)) {
                    document.querySelector(fh_selector+' .moption-row').style.removeProperty('padding-left');
                    document.querySelector(fh_selector+' .moption-row').style.removeProperty('padding-right');
                } else {
                    if($fh.is('[data-fixtextalign="center"]')) $fh.find('#tpl-menu').css('padding-left',fixed_m_w + 'px');
                    else document.querySelector(fh_selector+' #tpl-menu').style.removeProperty('padding-left');
                    $fh.find('.moption-row').css(moption_row_padding);
                }
            }
        } else {
            /* menu width ****************/
            $fh.find('#tpl-menu').css({
                'width': (fh_type == 'right') ? (($fh.find(' > .container[data-fh-align]').length > 0) ? '100%' : '') : (!check_fixed_mn && (fh_type=='top') ? '100%' : ''),
                'max-width': (fh_type == 'right') ? (($fh.find(' > .container[data-fh-align]').length > 0) ? 'calc(100% - ' + fixed_mn_width + 'px)' : '') : (!check_fixed_mn && (fh_type=='top') ? 'calc(100% - ' + navbarHeader_width + 'px)' : '')
            });

            /* menu 확장기능 ul, li, a => 메뉴 행간별 line-height, height :: 확장기능 행간 조절 ****************/
            $fh.find('.cl-fixed-menu#fixed-menu').css('line-height', (fh_type == 'right') ? fixed_mn_height + 'px' : '');
            $fh.find('.cl-fixed-menu#fixed-menu li > a:not(.cl-langlist):not(.cl-umMenu):not(.cl-lang)').css('line-height', (fh_type == 'right') ? (fixed_mn_height - 1) + 'px' : '');
            $fh.find('.cl-fixed-menu#fixed-menu,.cl-fixed-menu#fixed-menu li > a:not(.cl-langlist):not(.cl-umMenu):not(.cl-lang)').css({
                'height': (fh_type == 'right') ? fixed_mn_height + 'px' : '',
            });

            /* menu 확장기능 ul, li, a => 메뉴 행간별 line-height, height :: 확장기능 다국어 행간 조절  ****************/
            $fh.find('.cl-fixed-menu#fixed-menu .cl-visible.siteLANG, .cl-fixed-menu#fixed-menu .cl-visible.siteLANG .slang-active,\
                     .cl-fixed-menu#fixed-menu .cl-visible.siteLANG .cl-lang').css({
                'line-height': (fh_type == 'right') ? ($fh.find('.cl-fixed-menu li.cl-fixbtn').height() - 1) + 'px' : '',
                'height': (fh_type == 'right') ? $fh.find('.cl-fixed-menu li.cl-fixbtn').height() + 'px' : '',
            });

            /* menu 로고 a => 메뉴 행간별 line-height, height ****************/
            if ($('body').width() > 768) {
                $fh.find('.navbar-brand').css({
                    'line-height': (fh_type == 'sidebar' || (fh_type != 'sidebar' && $fh.find(' > .container[data-fh-align]').length == 0)) ? '' : logo_mn_height + 'px',
                });
            } else {
                $fh.find('.navbar-brand').css('line-height', '');
            }
        }


        if (fh_type == 'sidebar' && window.innerWidth > 768) {
            var siteLANG_hght = Number($fh.find('.cl-visible.siteLANG').outerHeight());
            siteLANG_hght = (typeof MODE == 'undefined') ? siteLANG_hght : siteLANG_hght + 35;

            $fh.find('.menu-inner').css('height', 'calc(100% - ' + siteLANG_hght + 'px)');
        }

        if (checkEllist) {
            if (fh_type == 'right' && $fh.find('.mini-home').length > 0) {
                if ($('body').width() > 768) {
                    $fh.find('.mini-home').closest('.navbar-collapse').attr('style', 'display: inline-block !important');
                } else $fh.find('.mini-home').parent().removeAttr('style');
            }
        }
    }

    $(document).on('mouseenter', '.el-menu [data-fixtype^="sidebar_"] .siteLANG.cl-fixbtn, .el-menu [data-fixtype^="sidebar_"] .siteUM.cl-fixbtn, #elmenu-display .siteLANG.cl-fixbtn', function() {
        var fixtypeNum = $('.el-menu header.navbar').attr('data-fixtype').replace(/(top|sidebar)\_/gi, ''),
            $dropdown = $(this).find('.dropdown-menu'),
            checkSiteLang = ($(this).hasClass('siteLANG')) ? 'siteLang' : 'um',
            $toggle = (checkSiteLang == 'siteLang') ? $(this).find('.cl-lang.dropdown-toggle') : $(this).find('.cl-logout.dropdown-toggle'),
            $dropdown_width = $dropdown.outerWidth(),
            $toggle_width = $toggle.outerWidth(),
            pos_left = $toggle.offset().left.toFixed(0),
            fixedMenu_pdlf = (checkSiteLang == 'um') ? Number($('.el-menu .cl-fixed-menu').css('padding-left').replace(/px/gi, '')) : '',
            fixedSiteLang_pdlf = (checkSiteLang == 'siteLang') ? Number($('.el-menu .siteLANG.cl-visible').css('padding-left').replace(/px/gi, '')) : 0,
            fixedMenu_textalign = ($('header.navbar[data-fixtype]').attr('data-fixtextalign')) ? $('header.navbar[data-fixtype]').attr('data-fixtextalign') : 'center',
            checkSidebar = ($('header.navbar[data-fixtype]').hasClass('sidebar')) ? true : false,
            fixtypeArr = ['01', '02', '03', '08'],
            check_scroll = (checkSidebar) ? $('header.navbar[data-fixtype] .menu-inner').hasVerticalScrollbar() : false;

        pos_left = ($(this).parents('#elmenu-display').hasClass('elmenu-color-edit') && checkSiteLang == 'siteLang') ? $toggle.position().left.toFixed(0) : pos_left;

        if (checkSiteLang == 'um') {
            if ($.inArray(fixtypeNum, fixtypeArr) > -1) {
                var left_val = 0;
                pos_left -= fixedMenu_pdlf;
                if (fixedMenu_textalign == 'center') {
                    var left_val = pos_left - $dropdown_width / 2 + $toggle_width / 2;
                    left_val = (check_scroll) ? left_val - 8 : left_val;
                    $dropdown.css('left', left_val);
                } else if (fixedMenu_textalign == 'left') {
                    $dropdown.css('left', 0);
                } else $dropdown.css({
                    'left': 'auto',
                    'right': 0
                });
            } else {
                $dropdown.css('left', -$dropdown_width / 2 + $toggle_width / 2);
            }
        } else {
            var cl_lang_top = Number($(this).find('.cl-lang').position().top.toFixed(0)),
                cl_lang_hght = Number($(this).find('.cl-lang').outerHeight());

            if (checkSidebar) {
                if (fixedMenu_textalign == 'center') {
                    $dropdown.css('left', pos_left - $dropdown_width / 2 + $toggle_width / 2);
                } else if (fixedMenu_textalign == 'left') {
                    $dropdown.css('left', fixedSiteLang_pdlf);
                } else $dropdown.css({
                    'left': 'auto'
                });
            } else {
                if($('.el-menu header.navbar .cl-menu-option').length == 0)  $dropdown.css('left', pos_left - $dropdown_width / 2 + $toggle_width / 2);
            }

            if (!$(this).parents('#elmenu-display').hasClass('elmenu-color-edit')) $dropdown.css('bottom', cl_lang_top + cl_lang_hght + 10);
        }
    });

    $.fn.hasVerticalScrollbar = function() {
        // This will return true, when the div has vertical scrollbar
        if (typeof this.get(0) == 'undefined') return false;
        return this.get(0).scrollHeight > this.height();
    }

    function isObjectEmpty(obj) {
        return Object.values(obj).every(value => {
            if (typeof value === 'object' && !Array.isArray(value)) {
                return isObjectEmpty(value);
            }
            return value === null || value === undefined || value === '';
        });
    }

    // 이미지/텍스트 슬라이드 함수
    function sliderClean(select) {
        // console.log(select);
        $(select).find('.swiper-slide-duplicate').remove();
		$(select).find('.swiper-notification').remove();
        $(select).find('.swiper-slide-invisible-blank').remove();
        $(select).find('.swiper-slide.delete').remove();
    }
    
    function sliderModify(slide) {
        document.querySelector(slide).swiper.destroy();
		slider(slide);
    }

    function sliderUnitModify(slide) {
        document.querySelector(slide).swiper.destroy();
		sliderUnit(slide);
    }

    // function textSliderModify(slide) {
    //     document.querySelector(slide).swiper.destroy();
	// 	textSlider(slide);
    // }

    //showcase logoSlide
    var sswiper;
    var uswiper;
    var tswiper;

    //이미지 / 텍스트 슬라이드 미리보기///////////////////////////
    // $(window).resize(function(){
    //     slideshow();
    //     textslideshow();
    // });

    function slideshow() {
        new Swiper( '.logoSlide', { slidesPerView: 'auto', simulateTouch: false, loop: true, speed: 5000, autoplay: { delay: 0, disableOnInteraction: false, }, });
    }
    function textslideshow() {
        new Swiper( '.reviewSlide', { slidesPerView: 'auto', simulateTouch: false, loop: true, speed: 7000, autoplay: { delay: 0, disableOnInteraction: false, }, });
    }
    ///////////////////////////////////////////////////////////

    //showcase logoSlide(flow)
    function slider(t) {
        var elem = document.querySelector(t).children[0];
        if($(elem).hasClass('cl-ns-wrap')) return false;
        let ss = $(elem).attr('data-scroll-speed');
        
        // let mleft = $(elem).find('.item:eq(0)').css('margin-left').replace(/[^0-9]/g, "");
        var w = $(window).width();
        // if(w < 991) $(elem).find('.swiper-slide').css('margin-left', (mleft / 3) + 'px');
        // if(w < 767) $(elem).find('.swiper-slide').css('margin-left', (mleft / 4) + 'px');
        // if(w < 480) $(elem).find('.swiper-slide').css('margin-left', 0 + 'px');
        let space = Number($(elem).attr('slide-space'));
        if(w < 767) { //모바일버전 간격조정
            if(space == 1) $(elem).find('.swiper-slide:not(.bmove)').css('margin-left', '0px');
            else $(elem).find('.swiper-slide:not(.bmove)').css('margin-left', (space * 10 - 10) +'px');
        }

        if (ss == 1000) {
            sswiper = new Swiper( t, { slidesPerView: 'auto', allowTouchMove: false, simulateTouch: false, loop: true, speed: 1000, autoplay: { delay: 0, disableOnInteraction: false, }, });
        } else if (ss == 1500) {
            sswiper = new Swiper( t, { slidesPerView: 'auto', allowTouchMove: false, simulateTouch: false, loop: true, speed: 1500, autoplay: { delay: 0, disableOnInteraction: false, }, });
        } else if (ss == 2200) {
            sswiper = new Swiper( t, { slidesPerView: 'auto', allowTouchMove: false, simulateTouch: false, loop: true, speed: 2200, autoplay: { delay: 0, disableOnInteraction: false, }, });
        } else if (ss == 3000) {
            sswiper = new Swiper( t, { slidesPerView: 'auto', allowTouchMove: false, simulateTouch: false, loop: true, speed: 3000, autoplay: { delay: 0, disableOnInteraction: false, }, });
        } else if (ss == 5000) {
            sswiper = new Swiper( t, { slidesPerView: 'auto', allowTouchMove: false, simulateTouch: false, loop: true, speed: 5000, autoplay: { delay: 0, disableOnInteraction: false, }, });
        } else {
            sswiper = new Swiper( t, { slidesPerView: 'auto', allowTouchMove: false, simulateTouch: false, loop: true, speed: 7000, autoplay: { delay: 0, disableOnInteraction: false, }, });
        }
    }

    //showcase logoSlide(unit)
    function sliderUnit(t) {
        if($(t).find('.item').length == 0 || $(t).hasClass('cl-not-supported') || $(t).find('.cl-ns-wrap').length > 0) return false;

        var elem = document.querySelector(t).children[0];
        $(elem).find('.item').removeAttr('style');
        let ss = $(elem).attr('data-scroll-speed');
        let unit = Number($(elem).attr('data-page-unit'));
        let delay = Number($(elem).attr('data-delay-time'));
        let slide_time = Number($(elem).attr('data-slide-time'));
        var newTransitionDuration = slide_time;
        var option = { slidesPerView : 1, loop : true, slidesPerGroup : 1, loopFillGroupWithBlank : true, allowTouchMove: false, simulateTouch: false, autoplay : { delay : delay, disableOnInteraction : false}};
        option['speed'] = newTransitionDuration * 1000;
        option['slidesPerView'] = Number(unit);
        option['slidesPerGroup'] = Number(unit);
        if(unit == 5) {
            option['breakpoints'] = { 320 : { slidesPerView : 4, slidesPerGroup : 4 }, 767 : { slidesPerView : 4, slidesPerGroup : 4 }, 991 : { slidesPerView : 5, slidesPerGroup : 5 }};
        } else if(unit == 6) {
            option['breakpoints'] = { 320 : { slidesPerView : 4, slidesPerGroup : 4 }, 767 : { slidesPerView : 4, slidesPerGroup : 4 }, 991 : { slidesPerView : 6, slidesPerGroup : 6 }};
        } else if(unit == 7) {
            option['breakpoints'] = { 320 : { slidesPerView : 4, slidesPerGroup : 4 }, 767 : { slidesPerView : 4, slidesPerGroup : 4 }, 991 : { slidesPerView : 7, slidesPerGroup : 7 }};
        } else if(unit == 8) {
            option['breakpoints'] = { 320 : { slidesPerView : 4, slidesPerGroup : 4 }, 767 : { slidesPerView : 4, slidesPerGroup : 4 }, 991 : { slidesPerView : 8, slidesPerGroup : 8 }};
        } else if(unit == 9) {
            option['breakpoints'] = { 320 : { slidesPerView : 4, slidesPerGroup : 4 }, 767 : { slidesPerView : 4, slidesPerGroup : 4 }, 991 : { slidesPerView : 9, slidesPerGroup : 9 }};
        } else if(unit == 10) {
            option['breakpoints'] = { 320 : { slidesPerView : 4, slidesPerGroup : 4 }, 767 : { slidesPerView : 4, slidesPerGroup : 4 }, 991 : { slidesPerView : 10, slidesPerGroup : 10 }};
        } else {
            option['breakpoints'] = { 320 : { slidesPerView : 4, slidesPerGroup : 4 }, 767 : { slidesPerView : 4, slidesPerGroup : 4 }, 991 : { slidesPerView : 4, slidesPerGroup : 4 }};
        }
        new Swiper(t, option);

    }

    //showcase textSlide
    function textSlider(t) {
        var elem = document.querySelector(t).children[0];
        // if($(elem).hasClass('cl-ns-wrap')) return false;
        if($(t).find('.item').length == 0 || $(t).hasClass('cl-not-supported') || $(t).find('.cl-ns-wrap').length > 0) return false;
        let ts = $(elem).attr('data-scroll-speed');
        if(ts == 3000){
            tswiper = new Swiper( t, { watchSlidesProgress: true, slidesPerView: 'auto', allowTouchMove: false, simulateTouch: false, loop: true, speed: 3000, autoplay: { delay: 0, disableOnInteraction: false, }, });
        } else if(ts == 5000){
            tswiper = new Swiper( t, { watchSlidesProgress: true, slidesPerView: 'auto', allowTouchMove: false, simulateTouch: false, loop: true, speed: 5000, autoplay: { delay: 0, disableOnInteraction: false, }, });
        } else if (ts == 7000) {
            tswiper = new Swiper( t, { watchSlidesProgress: true, slidesPerView: 'auto', allowTouchMove: false, simulateTouch: false, loop: true, speed: 7000, autoplay: { delay: 0, disableOnInteraction: false, }, });
        } else if (ts == 9000) {
            tswiper = new Swiper( t, { watchSlidesProgress: true, slidesPerView: 'auto', allowTouchMove: false, simulateTouch: false, loop: true, speed: 9000, autoplay: { delay: 0, disableOnInteraction: false, }, });
        } else if (ts == 12000) {
            tswiper = new Swiper( t, { watchSlidesProgress: true, slidesPerView: 'auto', allowTouchMove: false, simulateTouch: false, loop: true, speed: 12000, autoplay: { delay: 0, disableOnInteraction: false, }, });
        } else {
            tswiper = new Swiper( t, { watchSlidesProgress: true, slidesPerView: 'auto', allowTouchMove: false, simulateTouch: false, loop: true, speed: 8000, autoplay: { delay: 0, disableOnInteraction: false, }, });
        }

        $(tswiper.$el).data('tswiper', tswiper);
    }
}


function channelTalkHide(isHide) {        
    if(isHide) {
        $('#ch-plugin, .cl-cts-banner').fadeOut().attr('style','z-index: 1 !important; pointer-events: none !important;');
    } else {
        $('#ch-plugin, .cl-cts-banner').fadeIn().attr('style','z-index: 10000000 !important; pointer-events: auto !important;');
    }
}

window.onload = function() {
    var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ? true : false,
        scroll_body = '.dashbottom-wrap',
        scrollTarget = document.querySelector('.dashbottom-wrap');

    switch(this_page) {
        case 'plan':
        case 'billing':
            scroll_body = '.sub.sub-page';
            scrollTarget = document.querySelector('.sub.sub-page');
            break;
        
        case 'message':
            scroll_body = 'html';
            scrollTarget = window;
            break;

        default:
            break;
    }

    if(scrollTarget != null) {
        scrollTarget.addEventListener('scroll', function(e) {
            if($('#ch-plugin, .cl-cts-banner').length == 0) return;
            var isScrollAtBottom = (($(scroll_body).outerHeight() + $(scroll_body).scrollTop() + (isMobile ? 10 : 0)) >=  $(scroll_body).get(0).scrollHeight) ? true : false;
            // $('#popup-title').html('<p style="font-size: 9px;">'+isScrollAtBottom+' = '+($(scroll_body).outerHeight() + $(scroll_body).scrollTop() + (isMobile ? 10 : 0))+' >= '+$(scroll_body).get(0).scrollHeight+'</p>');
            if (isScrollAtBottom) {
                if(!$('body').is('.channelTalkHide')) {
                    $('body').addClass('channelTalkHide');
                    channelTalkHide(true);
                }
            } else {
                if($('body').is('.channelTalkHide')) {
                    $('body').removeClass('channelTalkHide');
                    channelTalkHide(false);
                }
            }
        });
    }

    if(this_page == 'settings' && typeof faviconPreload == 'function') faviconPreload();
}

function emojiEncode(text) {
    // 이모지만을 포함하는 정규 표현식
    var emojiRegex = /[\u{1F300}-\u{1F5FF}\u{1F600}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{2B50}\u{2B55}]/gu;
    
    // 입력 텍스트에서 이모지만을 추출하여 배열로 저장
    var emojis = text.match(emojiRegex) || [];

    // 이모지를 유니코드 이스케이프로 변환하고, 이를 원래 위치에 대체
    emojis.forEach(function(emoji) {
        var codePoints = [];
        for (var i = 0; i < emoji.length; i++) {
            codePoints.push('\\u' + emoji.charCodeAt(i).toString(16));
        }
        text = text.replace(emoji, codePoints.join(''));
    });

    return text;
}

function emojiDecode(escapedString) {
    return escapedString.replace(/\\u[\dA-F]{4}/gi, match => String.fromCharCode(parseInt(match.replace(/\\u/g, ''), 16)));
}

function focusAtEnd(input) {
    input.focus();
    var value = input.val();
    input.val('');
    input.val(value);
}

function clCheckBrowser(browser) {
    if(typeof browser == 'undefined' || !browser) return false;

    var is_tablet = /Android|iPad/i.test(navigator.userAgent),
        is_mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
        is_pc = !is_mobile && !is_tablet,
        is_chrome = /Chrome|CriOS/i.test(navigator.userAgent),
        is_safari = /Safari/i.test(navigator.userAgent) && !/Chrome|CriOS/i.test(navigator.userAgent),
        is_firefox = /Firefox/i.test(navigator.userAgent),
        is_edge = /Edg/i.test(navigator.userAgent) || /Edge/i.test(navigator.userAgent),
        is_opera = /OPR/i.test(navigator.userAgent) || /Opera/i.test(navigator.userAgent),
        is_ie = /MSIE/i.test(navigator.userAgent) || /Trident/i.test(navigator.userAgent),
        is_kakao = /KAKAOTALK/i.test(navigator.userAgent);

    switch(browser.trim().toLowerCase()) {
        case 'tablet': return is_tablet; break;
        case 'mobile': return is_mobile; break;
        case 'pc': return is_pc; break;

        case 'chrome': return is_chrome; break;
        case 'safari': return is_safari; break;
        case 'firefox': return is_firefox; break;
        case 'edge': return is_edge; break;
        case 'opera': return is_opera; break;
        case 'ie': return is_ie; break;
        case 'kakao': return is_kakao; break;

        default: return false; break;
    }
}

function resizeVideoIframe(tag) {
    if($(tag).find('iframe').length === 0 || $(tag).find('[data-bg-type="background"]').length == 0) return;
    var iframe = $(tag).find('.container'),
        width = iframe.width(),
        p_height = iframe.height(),
        height = (width / 16) * 9;
    if(p_height > height) height = p_height;
    iframe.find('iframe').height(height);
}