function previouspage(page,pid){
    if (page>1){
        topage(page-1,pid);
    }
}
function nextpage(page,pid){
    topage(page+1,pid);
}
function topage(page,pid){
    var loadUrl = "//"+window.location.host+"/query_subscr_page.action?pid="+pid+"&page="+page+"&temp="+Math.random();
    $.ajax({url: loadUrl, dataType: "json", scriptCharset: "utf-8", success: function (a) {
        var pageCount= a.pageCount;
        var html="";
        $.each(a.list,function(index,obj){
            html=html+"<li><span class='fl mr15 picPr'><img width='56' height='56' src='"+obj.smaImageUrl+"'><em class='picPrem2'></em></span><span class='fl'><p class='font18 support-wrap'>"+obj.pin+"</p><p>支持项目￥"+obj.supportAmout+"元</p><p><span class='f_black'>发起：</span>";
            html=html+"<strong class='f_red'>"+obj.publishs+"</strong>&nbsp;&nbsp;&nbsp;&nbsp;<span class='f_black'>支持：</span><strong class='f_red'>"+obj.suppets+"</strong></p></span></li>";
        });
        $(".sup_ul").html(html);
        if (page<=a.pageCount){
            html="<ul class='fr mr20'>";
            if(page>1){
                html=html+"<li class='up_page'><a href='javascript:previouspage("+page+","+pid+");'>上一页</a></li>";
            }else{
                html=html+"<li class='up_page'><a href='javascript:void(0);'>上一页</a></li>";
            }
            var beginPage = parseInt(page) - 3;
            var endPage =parseInt(page) + 3;
            for(index=beginPage;index<=endPage;index++){
                if(index<=a.pageCount && index >= 1){
                    if (index==page){
                        html=html+"<li class='page_cur'><a href='javascript:void(0);'>"+index+"</a></li>";
                    }else{
                        html=html+"<li class='page_default'><a href='javascript:topage("+index+","+pid+");'>"+index+"</a></li>";
                    }
                }
            }
            if (page>=a.pageCount){
                html=html+"<li class=''><a href='javascript:void(0);'>下一页</a></li>";
            }else{
                html=html+"<li class=''><a clstag='jr|keycount|zc_detail|zc_zczxyy' href='javascript:nextpage("+page+","+pid+");'>下一页</a></li>";
            }
            html=html+"</ul>";
            $(".zhoucou_page").html(html);
        }
    }});
}

function doHref(topicStatus){
    var i = 0;
    setTimeout(function(){
        if (!checkTopicStatus(topicStatus) && i <20){
            i = i + 1;
            setTimeout(arguments.callee, 1000);
        }else {
            locationDetail(topicStatus);
        }
    },500)
}

function doHrefWithGoto(topicStatus){
    gotoTopic();
    var i = 0;
    setTimeout(function(){
        if (!checkTopicStatus(topicStatus) && i <20){
            i = i + 1;
            setTimeout(arguments.callee, 1000);
        }else {
            locationDetail(topicStatus);
        }
    },500)
}

function checkTopicStatus(topicStatus){
    if ($("#topicAnchor"+topicStatus+"").length > 0) {
        return true;
    } else {
        return false;
    }
}

function locationDetail(topicStatus){
    $("html,body").animate({scrollTop: $("#topicAnchor"+topicStatus).offset().top}, 1000);
    setTimeout(function(){
        $("#replyBtn"+topicStatus).click();
    },1000)
}


function refresh(obj) {
    obj.src = "/verifycode.action?"+Math.random();
}

/**
 * 最新话题转换表情  add by lwj
 */
function convert_emo(){
    var topic_emo = new EmojiTransform();
    $(".convert_emo").each(function(){
        var emo_text= $(this).text();
        $(this).html(topic_emo.change(emo_text));
    });

}
/**
 * 锚点到关注列表
 */
$("[name='support_div']").click(function(event){
    gotoSupporter();
    event.stopPropagation();
});

//去支持
function supportProject(obj){
    var pId =$(obj).attr("projectId");
    var rId = $(obj).attr("redoundId");
    var org = $(obj).attr("ordFrom");
    var scramble = $(obj).attr("scramble");
    var platformType=$(obj).attr("platformType");
    if(platformType==1 || platformType==3){
        $('#m-private-erweima-'+rId).css('display','block')
        $('#xx-'+rId).click(function(){
            $('#m-private-erweima-'+rId).css('display','none')
        })
        $('#xx-'+rId).hover(function(){
            $(this).addClass('xx-h')
        },function(){
            $(this).removeClass('xx-h')
        })
    }
    else if(platformType == 5){
        getCurrentUserSale(pId, rId);
    }else{
        var url = "//"+window.location.host+"/funding/support_project.action?projectId="+pId+"&redoundId="+rId+"&org=pc";
        window.location.href = url;
    }
}
function getCurrentUserSale(pId, rId) {
    jQuery.ajax({
        url: "//"+window.location.host+"/get_loginuser.action?temp=" + Math.random()+new Date().getTime(),
        dataType: "text",
        scriptCharset: "utf-8",
        success: function (msg) {
            $("#user_pin").val(msg);
            if(msg==null||msg==undefined||msg==''){
                isShowLogon( function(){
                    getSaleRoundList(pId, rId);
                });
            }
            else{
                getSaleRoundList(pId, rId);
            }


        }, error: function (e) {
            $("#user_pin").val("");
        }
    });
}
function getCurrentUserIntegral(){
    jQuery.ajax({
        url: "//"+window.location.host+"/get_loginuser.action?temp=" + Math.random()+new Date().getTime(),
        dataType: "text",
        scriptCharset: "utf-8",
        success: function (msg) {
            $("#user_pin").val(msg);
            if(msg==null||msg==undefined||msg==''){
                isShowLogon( function(){
                    addIntegral();
                });
            }
            else{
                addIntegral();
            }
        }, error: function (e) {
            $("#user_pin").val("");
        }
    });
}

