/* Js for , Version=1790087718 */
 v.objectType = "article";;v.objectID = 38;;v.showDetail = "Show all";;v.hideDetail = "Hide";;$(document).ready(function()
{
    $.setAjaxForm('#commentForm', function(response)
    {
        if(response.result == 'success')
        {
            setTimeout(function()
            {
                var link = createLink('message', 'comment', 'objecType=' + $('#objectType').val() + '&objectID=' + $('#objectID').val());
                 $('#commentForm').closest('#commentBox').load(link, location.href="#first");
            },  
            1000);   
        }
        else
        {
            if(response.reason == 'needChecking')
            {
                $('#captchaBox').html(Base64.decode(response.captcha)).show();
            }

            if(response.locate) window.location.href = response.locate;
        }
    });

    $('#pager').find('a').click(function()
    {
        $('#commentBox').load($(this).attr('href'));
        return false;
    });

    $('a[id*=reply]').modalTrigger();

    /* Process contents. */
    $('.content-detail').each(function()
    {
        var obj = $(this);
        if(obj.height() > 100)
        {
            var buttons = "<a href='javascript:void(0)' onclick='showDetail(this)' class='showDetail'> ... " + v.showDetail + "</a>";
            buttons    += "<a href='javascript:void(0)' onclick='hideDetail(this)' class='hideDetail'> " + v.hideDetail + "</a>";
            obj.parent().append(buttons);
            obj.parent().find('.hideDetail').hide();
            obj.addClass('content-abstract');
        }
    });
});

function showDetail(obj)
{
    var tdContent = $(obj).parents('.td-content');
    tdContent.find('.content-detail').removeClass('content-abstract');
    tdContent.find('.showDetail').hide();
    tdContent.find('.hideDetail').show();
}

function hideDetail(obj)
{
    var tdContent = $(obj).parents('.td-content');
    tdContent.find('.content-detail').addClass('content-abstract');
    tdContent.find('.showDetail').show();
    tdContent.find('.hideDetail').hide();
}
var lang = $.cookie('browseLang');
if (!lang) {
  lang = /^zh/i.test(navigator.language || '') ? 'zh-cn' : 'en';

  $.cookie('browseLang', lang, {
      expires: 365,
      path: '/',
      secure: true,
      sameSite: 'lax'
  });

  var url = new URL(location.href);
  var isCnPath =
      url.pathname === '/cn' ||
      url.pathname.indexOf('/cn/') === 0;

  if (lang === 'en' && isCnPath) {
      // /cn、/cn/XXX -> /、/XXX
      url.pathname = url.pathname.substring(3) || '/';
      location.replace(url.href);
  } else if (lang === 'zh-cn' && !isCnPath) {
      // /、/XXX -> /cn/、/cn/XXX
      url.pathname = '/cn' + url.pathname;
      location.replace(url.href);
  }
}
