/* Js for , Version=1775274214 */
 v.lang = {"confirmDelete":"Do you want to delete it?","deleteing":"Deleting","doing":"Doing","loading":"Loading","updating":"Updating","timeout":"Timeout. Please try it again.","errorThrown":"Error : ","continueShopping":"Continue shopping","required":"Required","back":"Back","continue":"Continue","bindWechatTip":"Posting sets the limit for binding WeChat. Please bind WeChat user first.","importTip":"Old layout data will be replaced","fullImportTip":"Old article, product, layout data will be replaced and import test data"};; (function(c,l,a,r,i,t,y){
        c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
        t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
        y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "ob6lnnhebh");;v.jsRoot = "\/js\/";;v.webRoot = "\/";;v.editors = {"id":["content"],"tools":"simple"};;v.errorUnwritable = "Uploaded directory is not writable. Uploading failed.";;v.editorLang = "en";;v.uid = "69d088e69464e";;
var simple =
[ 'formatblock', 'fontsize', '|', 'bold', 'italic','underline', '|',
'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', '|',
'emoticons', 'image', 'link', '|', 'removeformat','undo', 'redo', 'source' ];

var full =
[ 'formatblock', 'fontsize', 'lineheight', '|', 'forecolor', 'hilitecolor', '|', 'bold', 'italic','underline', 'strikethrough', '|',
'justifyleft', 'justifycenter', 'justifyright', '|',
'emoticons', 'image', '|', 'link', 'unlink', 'anchor', 'media', 'baidumap', '/',
'undo', 'redo', '|', 'cut', 'copy', '|', 'plainpaste', 'wordpaste', '|', 'removeformat', 'clearhtml','quickformat', '|',
'indent', 'outdent', 'subscript', 'superscript', 'insertorderedlist', 'insertunorderedlist', '|', 'table', 'code', 'hr', '|',
'fullscreen', 'source', 'about'];

var editorTool  = v.editors.tools === 'full' ? full : simple;
var isIEBrowser = $.zui.browser.isIE();

$.extend(KindEditor, {getOptions: function(K, editorID)
{
    return {
        width: '100%',
        items: editorTool,
        cssPath: [v.webRoot + 'zui/css/admin.min.css'],
        cssData: (isIEBrowser ? 'body{overflow:hidden}' : '') + 'html,body {background: none;}.article-content, .article-content table td, .article-content table th {line-height: 1.3846153846; font-size: 13px;} .article-content table.table-kindeditor th, .article-content table.table-kindeditor td {padding: 5px 8px;} .article-content table.ke-zeroborder.table-kindeditor td {border: 1px dotted #AAA;} .article-content .table-auto {width: auto!important; max-width: 100%;}',
        bodyClass: 'article-content',
        urlType: 'absolute',
        uploadJson: createLink('file', 'ajaxUpload', 'uid=' + v.uid),
                imageTabIndex:1,
        filterMode: v.editors.filterMode,
        allowFileManager: true,
        langType: v.editorLang,
        htmlTags: {
        'p,span,h1,h2,h3,h4,h5,em,u,strong,br,ol,ul,li,img,a,b,font,hr,pre,embed,video,audio,':["class","id","style"],
        object: ["type", "data", "width", "height"], param: ["name", "value"],
        audio: ['id', 'class', 'width', 'src', 'height', 'loop', 'preload', 'autoplay', 'controls', 'crossorigin', 'currentTime', 'duration', 'muted'],
        video: ['id', 'class', 'width', 'src', 'height', 'loop', 'preload', 'autoplay', 'controls', 'crossorigin', 'currentTime', 'duration', 'muted', 'buffered', 'playsinline', 'played', 'poster'],
        source: ['src', 'type'],
        font:["id","class","color","size","face",".background-color"],span:["id","class",".color",".background-color",".font-size",".font-family",".background",".font-weight",".font-style",".text-decoration",".vertical-align",".line-height"],div:["id","class","align",".border",".margin",".padding",".text-align",".color",".background-color",".font-size",".font-family",
        ".font-weight",".background",".font-style",".text-decoration",".vertical-align",".margin-left"],table:["id","class","border","cellspacing","cellpadding","width","height","align","bordercolor",".padding",".margin",".border","bgcolor",".text-align",".color",".background-color",".font-size",".font-family",".font-weight",".font-style",".text-decoration",".background",".width",".height",".border-collapse"],"td,th":["id","class","align","valign","width","height","colspan","rowspan","bgcolor",".text-align",
        ".color",".background-color",".font-size",".font-family",".font-weight",".font-style",".text-decoration",".vertical-align",".background",".border"],a:["id","class","href","target","name"],embed:["id","class","src","width","height","type","loop","autostart","quality",".width",".height","align","allowscriptaccess","allowfullscreen"],img:["id","class","src","width","height","border","alt","title","align",".width",".height",".border"],"p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6":["id","class","align",".text-align",".color",
        ".background-color",".font-size",".font-family",".background",".font-weight",".font-style",".text-decoration",".vertical-align",".text-indent",".margin-left"],pre:["id","class"],hr:["id","class",".page-break-after"],"br,tbody,thead,tr,strong,b,sub,sup,em,i,u,strike,s,del":["id","class"],iframe:["id","class","src","frameborder","width","height",".width",".height"],style:[]},
        syncAfterBlur: true,
        spellcheck: false,
        placeholderStyle: {fontSize: '14px', color: '#999'},
        pasteImage: {postUrl: createLink('file', 'ajaxPasteImage', 'uid=' + v.uid), placeholder: true}
                ,afterCreate: isIEBrowser && function()
        {
            var $doc = $(this.edit.doc);
            $doc.one('scroll', function() {
                $doc.find('body').css('overflow', 'auto');
            });
        }
    }
}});

$(document).ready(initKindeditor);
function initKindeditor(afterInit)
{
    $(':input[type=submit]').after("<input type='hidden' id='uid' name='uid' value=" + v.uid + ">");
    var nextFormControl = 'input:not([type="hidden"]), textarea:not(.ke-edit-textarea), button[type="submit"], select';

    var editorsID;
    var $editorsID = $('.editors-id');
    if($editorsID.length) editorsID = ($editorsID.data('editors') || '').split(',');
    $.each(editorsID || v.editors.id, function(key, editorID)
    {
        if(typeof(v.editors.filterMode) == 'undefined') v.editors.filterMode = false;

        var K = KindEditor, $editor = $('#' + editorID);
        var keEditor = K.create('#' + editorID, K.getOptions(K, editorID));

        try
        {
            if(!window.editor) window.editor = {};
            window.editor['#'] = window.editor[editorID] = keEditor;
            $editor.data('keditor', keEditor);
        }
        catch(e){}
    });

    if($.isFunction(afterInit)) afterInit();
}
;v.viewReplies = "View your reply";;v.stayCurrent = "Stay on the current page";;v.quoteTitle = "<div class='quote-title'>Post by %s on %s<\/div>";;v.discussion = 1;;v.isCurrentPage = true;;
$(function()
{
    var videoContainer = "<video id=\"VIDEO_ID\" class=\"video-js vjs-default-skin vjs-big-play-centered\" controls preload=\"auto\" loop=\"loop\" data-setup='{\"autoplay\": VIDEO_AUTOSTART, \"width\": VIDEO_WIDTH, \"height\": VIDEO_HEIGHT, \"controlBar\": {\"fullscreenToggle\": VIDEO_FULLSCREEN}}'><source src=\"VIDEO_SRC\" type=\"video\/VIDEO_TYPE\" \/> <\/video>";
    $('embed').each(function(index)
    {
        if($(this).hasClass('videojs'))
        {
            var $embed      = $(this),
                src         = $embed.attr('src'),
                w           = $embed.width(),
                h           = $embed.height(),
                type        = src.match(/t=\w+/g),
                autostart   = $embed.attr('autostart'),
                fullscreen  = $embed.attr('allowfullscreen'),
                containerID = 'video_' + index;

            $container = videoContainer.replace(/VIDEO_SRC/g, src);
            $container = $container.replace(/VIDEO_WIDTH/, w);
            $container = $container.replace(/VIDEO_HEIGHT/, h);
            $container = $container.replace(/VIDEO_ID/, containerID);
            $container = $container.replace(/VIDEO_AUTOSTART/, autostart);
            $container = $container.replace(/VIDEO_FULLSCREEN/, fullscreen);
            $container = $container.replace(/VIDEO_TYPE/, type[0].replace('t=', ''));
            $(this).replaceWith($container);
        }
    })
});
;$(document).ready(function()
{
    $('#isLink').change(function()
    {
        if($(this).prop('checked'))
        {
            $('.threadInfo').hide();
            $('.link').show();
        }
        else
        {
            $('.threadInfo').show();
            $('.link').hide();
        }
    });

    $('.color').each(function()
    {
        var $this = $(this);
        var c = $this.attr('data');
        if(!c) return;
        var cc = new $.zui.Color(c).contrast().hexStr();

        ($this.hasClass('input-group') ? $this.find('.input-group-btn .dropdown-toggle') : $this).css({'background': c, 'color': cc}).find('.caret').css('border-top-color', cc);
    }).click(function()
    {
        var $this = $(this);
        if($this.hasClass('input-group')) return;
        var $plate = $this.closest('.colorplate');
        $plate.find('.color.active').removeClass('active');
        if($this.hasClass('color-tile')) $plate.find('.input-color').val($this.attr('data')).change();
        $this.addClass('active');
    });

    $('.input-color').on('keyup change', function()
    {
        var $this = $(this);
        var val = $this.val();

        $this.closest('.colorplate').find('.color.active').removeClass('active');

        if($.zui.Color.isColor(val))
        {
            var ic = (new $.zui.Color(val)).contrast().hexStr();
            $this.attr('placeholder', val).closest('.color').removeClass('error').find('.input-group-btn .dropdown-toggle').css({'background': val, 'color': ic}).find('.caret').css('border-top-color', ic);;
        }
        else
        {
            $this.closest('.color').addClass('error');
        }
    });
});
$(document).ready(function()
{
    $.setAjaxForm('#replyForm', function(response)
    {
        if(response.result == 'success')
        {
            if(!v.isCurrentPage && (v.discussion == '0' || (v.discussion == '1' && response.replyID == 0)))
            {
                bootbox.dialog(
                {  
                    message: response.replySuccess,  
                    buttons:
                    {  
                        lastPage:
                        {  
                            label:     v.viewReplies,
                            className: 'btn-primary',  
                            callback:  function(){location.href = response.locate;}  
                        },
                        back:
                        {  
                            label:     v.stayCurrent,  
                            className: 'btn-primary',  
                            callback:  function(){location.href = removeAnchor(location.href);}  
                        }  
                    }  
                });
            }
            else
            {
                $('#submit').popover({container: 'body', trigger:'manual', content:response.replySuccess, placement: 'right', tipClass: 'popover-success  popover-ajaxform'}).popover('show');
                setTimeout(function(){$('#submit').popover('destroy');}, 2000);
                setTimeout(function(){location.href = response.locate;}, 1200);
            }
        }
        else
        {
            if(response.reason == 'needChecking')
            {
                $('#captchaBox').html(Base64.decode(response.captcha)).show();
            }
            getCaptcha($('#captchaBox .img-wrapper'));
            $('#captchaBox .captcha-input input').val('');
        }
    });

    $.setAjaxForm('#addScoreForm');

    $.setAjaxJSONER('.switcher', function(response){ bootbox.alert(response.message, function(){location.href = response.locate; return false;});});
    $('.nav-system-forum').addClass('active');
    $('#navbar li.active').parents('li').addClass('active');

    /* remove empty element */
    $('.speaker > ul > li > span:empty').closest('li').remove();

    $('.thread-reply-btn').click(function()
    {
        if($(this).data('reply')) $('input[name=reply]').val($(this).data('reply'));
    })

    $(document).on('click', '.quote', function()
    {
        if($(this).parents('.alert-replies').length)
        {
            var $quote = $(this).parents('.thread-content');
            var date   = $quote.find('.reply-date').html();
            var user   = $quote.find('.reply-author').html().replace('\：', '');
            var quoteTitle = v.quoteTitle.replace('\%\s', user).replace('\%\s', date);

            var quoteContent = '[quote]';
            quoteContent += quoteTitle;
            quoteContent += $quote.find('.reply-content').html();
            quoteContent += '[/quote]';
        }
        else
        {
            var $quote     = $(this).parents('.panel.reply');
            var date       = $quote.find('.panel-heading span.muted').html().replace(/<[^>]+>/g,'');
            var user       = $quote.find('.table .speaker .thread-author').html().replace(/<[^>]+>/g, '');
            var quoteTitle = v.quoteTitle.replace('\%\s', user).replace('%s', date);
            
            var quoteContent = '[quote]';
            quoteContent += quoteTitle;
            quoteContent += $quote.find('.table .thread-wrapper .thread-content').html();
            quoteContent += '[/quote]';
        }

        KindEditor.html('#content', quoteContent);
    })
    
    $('.alert-primary').parent('.reply-content').css('display', 'block');
});
$(document).ready(function()
{
    if($("#headNav nav > a:first-child").text() == 'Login'){
        $("#headNav nav > a:first-child").text('Log in'); 
    }
    if($("#headNav nav > a:last-child").text() == 'Register'){
        $("#headNav nav > a:last-child").text('Sign up'); 
    }

    $('#siteNav a[href="/user-register.html"]').remove();
    setTimeout(function() {$('#language').after($('#siteNav'));}, 200);
    
    if(typeof headerList != 'undefined') return false;
    headerList = true;
    searchICON = '<a class="search-but">' + '<i' + ' class="icon icon-search"></i></a>';
    $("#navbar li.nav-item-searchbar").prepend(searchICON);
    
    $("#words").attr('placeholder','Search');
    
    $(".search-but").click(function(){
        $("#searchbar").fadeToggle();
    });
    
    $("#reg #panel-pure #heading-title").text('Register');
    $("#login #login-region .panel-heading span").text('Login'); 
    $(".m-user-login .page-wrapper").before('<div class="banner-wrap"><div class="banner"><h3>Welcome to login</h3></div></div>');
    $(".m-user-register .page-wrapper").before('<div class="banner-wrap"><div class="banner"><h3>Welcome to register</h3></div></div>');
    $(".m-extension .page-wrapper").before('<div class="banner-wrap"><div class="banner"><h3>Extension</h3></div></div>');

    $('#language').insertAfter('#navbarWrapper');
    $('#language').next().remove();
    
    if(location.pathname.includes('download')) 
    {
        $('.article table a').click(function(e)
        {
            e.preventDefault();
            if($(this).attr('href').includes('dl'))
            {
                location.href = "/page/downloadComplete.html";
                sessionStorage.setItem('downloadUrl', $(this).attr('href'));
            }
        })
    }
    
    if(!location.href.includes('/page')) $('.navbar-nav li').removeClass('active');
});

// $(function(){
//     window.Intercom('boot', {
//       app_id: "buxeg11n",
//       bottom: 80,
//       right: 26,
//     });
// });

if(screen.width > 767){
    $("#navbar .dropdown").mouseover(function(e){
        $(this).addClass('open');
    });
    $("#navbar .dropdown").mouseout(function(e) {
        $(this).removeClass('open');
    });
};

function getCaptcha($ele)
{
    $.get(createLink('guarder', 'getCaptcha'), function(response)
    {
        if(response.result == 'success')
        {
            $ele.html(response.captchaContent);
        }
    })
}

$('#captchaBox').on('click', '.img-wrapper', function()
{
    getCaptcha($(this));
});$(".page-wrapper").before('<div class="banner-wrap"><div class="banner"><h3>ZenTao Forum</span></h3></div>');
;
$(document).ready(function()
{
    $('a[data-download=1]').each(function()
    {
        link = window.btoa(window.encodeURIComponent($(this).attr('href')));
        fileName = window.btoa(window.encodeURIComponent($(this).text()));
        $(this).attr('data-toggle', 'modal').attr('href', createLink('misc', 'download', 'link=' + link + '&fileName=' + fileName));
    });
})
;
    (function(d, w, c) {
        w.ChatraID = 'Cbq6Mh2awJjcBxaKu';
        var s = d.createElement('script');
        w[c] = w[c] || function() {
            (w[c].q = w[c].q || []).push(arguments);
        };
        s.async = true;
        s.src = 'https://call.chatra.io/chatra.js';
        if (d.head) d.head.appendChild(s);
    })(document, window, 'Chatra');
;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-99909387-1');
;
  !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', '2886924191530102');
  fbq('track', 'PageView');
;(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-W92V6QZ');;$('body').prepend(`<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-W92V6QZ"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->`);;
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?324d367575487a3d09ff39ad67df7486";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
;
function loadCartInfo(twinkle)
{
    $('#siteNav').load(createLink('misc', 'printTopBar'),
        function()
        {
            if(twinkle)
            {
                bootbox.dialog(
                {
                    message: v.addToCartSuccess,
                    buttons:
                    {
                        back:
                        {
                            label:     v.lang.continueShopping,
                            className: 'btn-primary',
                            callback:  function(){location.reload();}
                        },
                        cart:
                        {
                            label:     v.gotoCart,
                            className: 'btn-primary',
                            callback:  function(){location.href = createLink('cart', 'browse');}
                        }
                    }
                });
            }
        }
    );
}
;
var hash = window.location.hash.substring(1);
var browserLanguage = navigator.language || navigator.userLanguage;
var resolution      = screen.availWidth + ' X ' + screen.availHeight;
$.get(createLink('log', 'record', "hash=" + hash), {browserLanguage:browserLanguage, resolution:resolution});
