function comment (after, post_id)
{
    $('#comment_form').insertAfter($('#' + after));
    if (post_id.indexOf("-") != -1) {
        var parts = post_id.split("-");
        post_id = parts[1];
    }
    
    $('#reply_post_id').val(post_id);
    $('#preview_post').html("");
    setTimeout("focus('comment_form_textarea');", 200);
}
function preview ()
{
    $('#comment_form_action').val('preview');
    show_load_img('loading_preview');
    $('#btn_send').attr('disabled',true);
    $('#btn_preview').attr('disabled',true);
    $('#comment_form_id').ajaxSubmit(function(data) {
        hide_load_img('loading_preview');
        $('#btn_send').attr('disabled',false);
        $('#btn_preview').attr('disabled',false);
        $('#preview_post').html(data);
    });
}
function reply ()
{
    $('#comment_form_action').val('reply');
    show_load_img('loading_preview');
    $('#btn_send').attr('disabled',true);
    $('#btn_preview').attr('disabled',true);
    $('#comment_form_id').ajaxSubmit(function(data) {
        hide_load_img('loading_preview');
        $('#btn_send').attr('disabled',false);
        $('#btn_preview').attr('disabled',false);

        var post_id = $('#reply_post_id').val();
        if (parseInt(post_id) == post_id) {
            $('#post' + $('#reply_topic_id').val() + '-' + post_id).after(data);
        } else {
            $('#comment_anchor').before(data);
        }
        $('#reply_post_id').val("");
        $('#comment_form').insertAfter($('#comment_anchor'));
        $('#comment_form_textarea').val("");
        $('#preview_post').html("");
    });
    
}