var Comments = {
    reload : function(url, type, data) {
        $.ajax({
            url : url,
            dataType: 'html',
            data : data,
            type: type,
            success: function(data) {
                var d = $(data);
                $('#comment-container').replaceWith(d);
            }

        });
    }
}


$(document).ready(function(){

    $('#add-comment-form').livequery(function(){
        $(this).submit(function(){
            $(this).stop();
            Comments.reload($(this).attr('action'), 'POST', {
                'content': $(this).find('[name=content]').val()
                });
            return false;
        });
    });

    $('#comment-container .pages a').livequery(function(){
        $(this).click(function(){
            $(this).stop();
            Comments.reload($(this).attr('href'), 'GET', null);
            return false;
        });
    });

});
