/* Js for , Version=1776605863 */
 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.formLayout = "global";;v.location = "\u7f8e\u56fd,\u7f8e\u56fd,,";;
$(document).ready(function()
{
    $(".chosen").chosen({no_results_text: 'No match found!}', placeholder_text:' ', disable_search_threshold: 10, width: '100%', search_contains: true});
    $('select.chosen-icons').chosenIcons({lang: 'en'});
});
;
$(function()
{

    $.fn.fixedDate = function()
    {
        return $(this).each(function()
        {
            var $this = $(this);
            if($this.offset().top + 200 > $(window).height())
            {
                $this.attr('data-picker-position', 'top-right');
            }

            if($this.val() == '0000-00-00')
            {
                $this.focus(function(){ if($this.val() == '0000-00-00') $this.val('').datetimepicker('update');}).blur(function(){ if($this.val() == '') $this.val('0000-00-00')});
            }
        });
    };


    var options =
    {
        language: 'en',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1,
        format: 'yyyy-mm-dd hh:ii'
    };


    var dateOptions = $.extend({}, options, {minView: 2, format: 'yyyy-mm-dd'});
    var timeOptions = $.extend({}, options, {startView: 1, minView: 0, maxView: 1, format: 'hh:ii'});

    $('.form-datetime').fixedDate().datetimepicker(options);
    $('.form-date').fixedDate().datetimepicker(dateOptions);
    $('.form-time').fixedDate().datetimepicker(timeOptions);

    $('.datepicker-wrapper').click(function()
    {
        $(this).find('.form-date, .form-datetime, .form-time').datetimepicker('show').focus();
    });

    $('.input-append.date').on('click', function(){
        $(this).find('input').datetimepicker('show').focus();
    }).find('input').datetimepicker($.extend({}, options, {pickerPosition: 'top-right'}));

});
;v.confirm = "Are you sure to submit?";;v.fullScreen = 0;;v.type = "form";;v.formID = 1;;v.conditions = [];;v.itemTotal = 0;;v.pageTotal = 0;;v.page = 1;;$(function()
{
    //if(v.fullScreen == 0 && $('.col-side').length > 0)
    //{
    //    var screenHeight = $(window).height();
    //    var mainTop      = $('.col-main').offset().top;
    //    var mainHeight   = $('.col-main').height();
    //    var sideHeight   = $('.col-side').height();
    //    if(mainTop + mainHeight < screenHeight)
    //    {
    //        if($('#pageFooter').length > 0)  $('#pageFooter').css('margin-top', sideHeight - mainHeight);
    //        if($('#pageFooter').length == 0) $('div[id^=form]').css('padding-bottom', sideHeight - mainHeight);
    //    }
    //}
    //else
    //{
    //    var documentHeight = $(document).height();
    //    var bodyHeight     = $('body').height();
    //    var screenHeight   = $(window).height();
    //    if(bodyHeight < screenHeight)
    //    {
    //        if($('#pageFooter').length > 0)  $('#pageFooter').css('margin-top', documentHeight - bodyHeight);
    //        if($('#pageFooter').length == 0) $('div[id^=form]').css('padding-bottom', documentHeight - bodyHeight);
    //    }
    //}

    citySelector();
    $('input, select, textarea').change(function()
    {
        processProgress();
    });

    /* Add class clicked to avoid click twice. */
    $('.file-name label, .file-name input[type=checkbox]').click(function()
    {
        $(this).parents('.file-name').find('input[type=checkbox]').addClass('clicked');
    });

    /* Check the radio button or checkbox when click the image or div.*/
    $('.file-icon-image, .file-name').click(function()
    {
        $(this).parents('.file-wrapper').find('input[type=radio]').prop('checked', true).change();

        var checkbox = $(this).parents('.file-wrapper').find('input[type=checkbox]');
        if(!checkbox.hasClass('clicked'))
        {
            if(checkbox.prop('checked'))
            {
                checkbox.prop('checked', false).change();
            }
            else
            {
                checkbox.prop('checked', true).change();
            }
        }
        $('.clicked').removeClass('clicked');
    });

    $.setAjaxForm('[id^=form]', function(response)
    {
        if(v.page < v.pageTotal && $('[id^=form]').find('.submit').is(':hidden')) $('[id^=form]').find('.submit').popover('destroy');

        if(response.result == 'success' && response.locate)
        {
            return setTimeout(function(){location.href = response.locate;}, 1200);
        }

        if(response.result == 'fail' && $.type(response.message) == 'object')
        {
            var index = 1;
            var page  = 0;
            var e     = $(window);
            $('.items > .item').each(function()
            {
                var $item = $(this);
                var id    = $(this).find('.item-content').attr('id');
                if($(this).find('span#' + id + 'Label').length > 0)
                {
                    $item.css('border', '1px solid #953B39');
                    if(index == 1)
                    {
                        page = $(this).parents('[id^=pageContent]').attr('data-id');
                        e    = $(this);
                    }
                    index++;
                }

                $(this).find('.item-content').find('input,select,textarea').change(function()
                {
                    $item.css('border', 'none');
                });
            });

            if(page > 0) changePage('goto', page, e);
        }
    });

    /* Submit form data. */
    $('#submit').click(function()
    {
        bootbox.confirm(v.confirm, function(result)
        {
            if(result) $('#submit').closest('form').submit();
            return true;
        });
        return false;
    });

    changePage();
});

/* Process progress style. */
function processProgress()
{
    var finished = 0;
    $('.item-content').each(function()
    {
        if($(this).find('input[type=text], select, textarea').length > 0)
        {
            if($(this).find('input[type=text], select, textarea').val() != '') finished++;
        }
        if($(this).find('input[type=radio], input[type=checkbox]').length > 0)
        {
            $(this).find('input[type=radio], input[type=checkbox]').each(function()
            {
                if($(this).prop('checked'))
                {
                    finished++;
                    return false;
                }
            });
        }
    });

    if(v.itemTotal > 0)
    {
        var percent = Math.round(finished / v.itemTotal * 10000) / 100;
        $('.progress-bar').attr('aria-valuenow', percent).css('width', percent + '%');
        $('.percent').html(percent + '%');
        $('.progressbar').addClass('show');
    }
}

function changePage(type, page, e)
{
    $('[id^=pageContent]').hide();
    $('#pageFooter .pager li').hide();

    if(type == 'prev') v.page--;
    if(type == 'next') v.page++;
    if(type == 'goto') v.page = page;

    if(v.page <= 1) $('#pageFooter .pager .previous.disabled').show();
    if(v.page >  1) $('#pageFooter .pager .previous').not('.disabled').show();
    if(v.page <  v.pageTotal) $('#pageFooter .pager .next').not('.disabled').show();
    if(v.page >= v.pageTotal) $('#pageFooter .pager .next.disabled').show();
    if(v.page >= v.pageTotal) $('#pageFooter .pager .submit').addClass('lastPageShowed').show();

    $('#pageFooter .pager .submit.lastPageShowed').show();

    $('#pageContent' + v.page).show();

    if(e === undefined)
    {
        $(window).scrollTop($('div[id^=form]').offset().top);
    }
    else
    {
        $(window).scrollTop(e.offset().top);
    }
}

$(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));
});
;
$(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));
    });
})
;
  var formId = '#form' + 'c4ca4238a0b923820dcc509a6f75849b';
  var fingerprint = getFingerprint();
  $(formId).append("<input type='hidden' id='fingerprint' name='fingerprint' value='" + fingerprint + "'>");

  $.post(createLink('misc', 'ping'), {id: 'c4ca4238a0b923820dcc509a6f75849b', fingerprint: fingerprint});

  if(v.type == 'exam')
  {
      $.get(createLink('form', 'ajaxGetTimeLeft', 'formID=' + v.formID), function(timeLeft)
      {
          if(!timeLeft) return false;

          interval = setInterval(function()
          {
              var hour   = Math.floor(timeLeft / 3600);
              var minute = Math.floor(timeLeft % 3600 / 60);
              var second = timeLeft % 60;

              if(hour   < 10) hour   = '0' + hour;
              if(minute < 10) minute = '0' + minute;
              if(second < 10) second = '0' + second;

              if(timeLeft >  0) $('.timeLeft').html('<i class="icon icon-time"> </i>' + hour + ':' + minute + ':' + second);
              if(timeLeft <= 0)
              {
                  $('#submit').closest('form').submit();
                  clearInterval(interval);
              }

              timeLeft--;
          }, 1000);
      });
  }
  ;
    (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});
;
  var formId = '#form' + 'c4ca4238a0b923820dcc509a6f75849b';
  getFingerprint().then(result =>
  {
      $(formId).append("<input type='hidden' id='fingerprint' name='fingerprint' value='" + result + "'>");
      $.post(createLink('misc', 'ping'), {id: 1, fingerprint: result});
  });

  if(v.type == 'exam')
  {
      $.get(createLink('form', 'ajaxGetTimeLeft', 'formID=' + v.formID), function(timeLeft)
      {
          if(!timeLeft) return false;

          interval = setInterval(function()
          {
              var hour   = Math.floor(timeLeft / 3600);
              var minute = Math.floor(timeLeft % 3600 / 60);
              var second = timeLeft % 60;

              if(hour   < 10) hour   = '0' + hour;
              if(minute < 10) minute = '0' + minute;
              if(second < 10) second = '0' + second;

              if(timeLeft >  0) $('.timeLeft').html('<i class="icon icon-time"> </i>' + hour + ':' + minute + ':' + second);
              if(timeLeft <= 0)
              {
                  $('#submit').closest('form').submit();
                  clearInterval(interval);
              }

              timeLeft--;
          }, 1000);
      });
  }
  