/* Js for , Version=1775193950 */
 v.objectType = "rrpl";;v.objectID = 384;;v.showDetail = "\u663e\u793a\u5168\u90e8";;v.hideDetail = "\u6536\u8d77";;v.loginUrl = "L3JycGwvcm9pLTEyLmh0bWw=";;$(document).ready(function()
{
    $.setAjaxForm('#commentForm', function(response)
    {
        if(response.result == 'success')
        {
            sessionStorage.removeItem('comment');
            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();
                return;
            }
            if(response.result == 'fail' && (response.locate != undefined && response.locate != ''))
            {
                setTimeout(function(){location.href = response.locate}, 1000);
            }
        }
    });

    $(document).on('click', '#pager a', 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');
        }
    });

    $('.reply-comment').click(function()
    {
        if($('.username').length < 1)
        {
            location.href = '/user-login-' + v.loginUrl;
        }
    });
});

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();
}
$(function(){
    $(".siteNav a[href*='register']").remove();
    $(".siteNav a[href*='login']").text('登录/注册');
    
    $('.all-bottom').prependTo('#footer');

    var windowHeight = $(window).innerHeight();
    var minHeight = windowHeight - $('#header').height() - $('#footer').height() + 30;
    if($('html').hasClass('m-user-settings')) minHeight = minHeight - 30;
    if($('.page-wrapper').height() < minHeight) {
        $('.page-wrapper').css('minHeight', minHeight)
    }
    
    if($(window).innerWidth() < 768) {
        if($('html').hasClass('m-ask')) {
            $('.tree > li').removeClass('open');
        }
        
        if($('html').hasClass('m-claim')) {
            $('.clickable-claim').click(function() {
                $('.popover').remove();
            });
        }
    }
    
    if(location.href.includes('rrpl-search')) {
        $('a[href="/rrpl.html"]').parent().addClass('active');
    }
    
    if($('html').hasClass('m-ask-view')) {
        $('a[href="/ask.html"]').parent().addClass('active');
    }
    
    if(location.pathname == '/') $('a[href="/index.html"]').parent().addClass('active');
    
    $('.m-claim-browse .status-list a:last-child').addClass('hide');
    $('.m-claim-browse .type-wrap').css('display', 'none');
    $('.m-claim-browse #keyword').attr('placeholder', '请输入您要搜索的实践');
    if($('.related-zentao').length > 0) $('.details .origin').after($('.details .related-zentao'));
});
