function load_comments(post_id, toggle) {
    $(post_id+'_comments').update("<img src='/images/loading.gif' align='center' />");
    if (toggle) {
        Effect.toggle(post_id+'_comments', 'blind', { duration: 0.2 })
    }
    new Ajax.Request('/ajax/show_microblog_comments/'+post_id, 
        { 
            method: "post",
            asynchronous: false,
            onSuccess: function(transport)
            {
                $(post_id+'_comments').update(transport.responseText);
            }
        }
    );
}
function post_microblog_comment(post_id) {
    var comment = $('post_'+post_id+'_microblog_comment').getValue();
    new Ajax.Request('/ajax/post_microblog_comment/'+post_id, 
        { 
            method: "post",
            asynchronous: false,
            parameters: {'comment' : comment},
            onSuccess: function(transport)
            {
                if ($(post_id+'_comments'))
                {
                    if (transport.responseText == 'ok')
                    {
                        load_comments(post_id, false);
                    }
                    else
                    {
                        $(post_id+'_microblog_comment_result').update(transport.responseText);
                    }
                }
                else
                {
                    if (transport.responseText == 'ok')
                    {
                        $('post_'+post_id+'_microblog_comment').setValue('');
                        location.reload();
                    }
                    else
                    {
                        $(post_id+'_microblog_comment_result').update(transport.responseText);
                    }
                }
            },
            onFailure: function() {
                $(post_id+'_microblog_comment_result').update('Для того чтобы оставить запись необходимо зарегистрироваться.');
            }
        }
    );
}

