function showFormAddComment(parent_id)
{
    if(parent_id > 0)
    {
        $('#parent_id').val(parent_id);
    }
    
    $('#reply_form'+parent_id).show();
}

function setParent(id)
{
    $('#reply').html('Цитируем: ' + $('#text_' + id).html() ).show();    
    $('[name="parent_id"]').val(id);
    window.location = '#comment_form';
}

function addReply(id,news_id)
{
    $.php('/comments/save/id/'+news_id, $('form#reply_form'+id).serialize());        
    
    return false;
}

function addComment(news_id)
{
    $.php('/comments/save/id/'+news_id, $('form#comment_form').serialize());
    return false;
}

function loadComments(news_id, type)
{
    $("#comments_block").load('/comments/list/id/' + news_id + '/type/' + type + ' #comments_block', {}, function()
    {
    });
    
    return false;   
}

function delete_comment(id, au_id, news_id, type, element)
{
    $.post("/comments/deletecomment/id/" + id + "/au_id/" + au_id + "/type/" + type, {}, function(data)
    {
        if(type == 'auto')
        {
            alert("Ваша жалоба будет обработан в ближайшее время"); 
            $(element).remove();
            
            return false;
        }
        
        return loadComments(news_id, type);
    });   
}

function insertSmile(obj)
{
    $('[name="text"]').attr('value', $('[name="text"]').attr('value') + ":"+ $(obj).attr('id').replace('/design/images/smile/','').replace('.gif','') +":");
}
