//commentsファイル
//var displayCnt = 20;
$(document).ready( function(){
    $("#moreBtn").click(function(){
        var commentCnt = $("div[class='commentCell']").size();
        var replyCnt = $("span.reply").size();
        var moreAjaxURL = "/comments/getComments"+location.pathname+"/"+commentCnt;
        $.ajax({
            url : moreAjaxURL ,
            type : "get",
            success: function(request) {
                if (request == ''){
                    $("#moreBtn").hide();
                } else {
                    //$("div.commentBox").append(request);
                    $("div.commentBox div.commentCell:last").after(request);
                    $("form.replyForm").hide();
                }
            },
			complete : function(XMLHttpRequest, status){
                    $("span.reply:gt("+(replyCnt-1)+")").toggle(function() {
                        var index = $("span.reply").index(this);
                        $("form.replyForm:eq("+index+")").show("slow");
                    },function() {
                        var index = $("span.reply").index(this);
                        $("form.replyForm:eq("+index+")").hide("slow");
                    });
			}
        });
    });
});
