var js_forum = {
    add_post: function() {
        
        $('#new_post [type=submit]').show_ajax_loader();
        $.postJSON(AJAX_URL + '?act=add_forum_post', $('#new_post form').serialize(), function(result) {        
            if(result.success == true) {
                $('#new_post').show_report('Mesajul a fost adaudgat.', 'success');
                window.location.reload();
            } else {
                $('#new_post [type=submit]').hide_ajax_loader();
                $('#new_post').show_report(result.error, 'error');
            }
        });        
        return false;
    },
    add_topic: function() {
        $('#new_topic [type=submit]').show_ajax_loader();
        
        $.postJSON(AJAX_URL + '?act=add_forum_topic', $('#new_topic form').serialize(), function(result) {        
            if(result.success == true) {
                $('#new_topic').show_report('Subiectul de discutii a fost adaudgat.', 'success');
                window.location.reload();
            } else {
                $('#new_topic [type=submit]').hide_ajax_loader();
                $('#new_topic').show_report(result.error, 'error');
            }
        });
        return false;
    },
    cancel_add_topic: function() {
        $('#new_topic').slideUp();
        $('#new_topic_button').css('borderBottom', '1px solid #CA7A01;');
        $('#new_topic_button2').css('borderBottom', '1px solid #CA7A01;');
    },
    show_new_topic_form: function(js_move) {    
    
        if(js_move) {
            $('#new_topic_button').after($('#new_topic'));        
            $('#new_topic_button').css('borderBottom', '0');            
        } else {
            $('#new_topic_button2').after($('#new_topic'));    
            $('#new_topic_button2').css('borderBottom', '0');            
        }
        $('#new_topic').slideDown();
        $('#new_topic_title').focus();
    },
    
    quote_and_reply: function(js_post_hash) {
        js_quote = $('#reply_text').html() + '[quote]<span>' + $('#pu' + js_post_hash).html() + ' a scris: </span>' + $('#pt' + js_post_hash).html() + '[/quote]';
        js_quote = js_quote.replace(/</g, '&lt;');
        js_quote = js_quote.replace(/>/g, '&gt;');
        
        $('#reply_text').html(js_quote + "\n");
    }
}
