$(document).ready(function() {

    /**
 * Usuwanie ogloszenia
 */
/*    $('a.usun_wiadomosc').click(function(){
        id_ogloszenia =$(this).attr("rel");
        if(confirm(komunikaty.usunac_ogloszenie)){
            link = $(this).attr('href');
            $.post( link,{},
            function(data) {
                msg(data);
            });
            $(this).parent().parent().parent().parent().parent().html('');
        }
        return false;
    });*/

    /**
 * Wysylanie wiadomosci
 */
    $('#wyslij_wiadomosc #submit').live('click', function(e){
        e.preventDefault();
        link = $("#wyslij_wiadomosc").attr('action');
        $.post( link,{
            odbiorca: $('#odbiorca').val(),
            tresc: $("#tresc").val(),
            temat: $("#temat").val()
        },
        function(data) {
            msg(data);
            $("#komponuj").hide();
            wyczysc_formularz_wysylania();
        });

        return false;
    });

    /**
 * Usuwanie wiadomosci przez nadawce
 */
    $('#nad a.usun_wiadomosc').click(function(){
        if(confirm(komunikaty.usunac_wiadomosc)){
            button = $(this);
            link = $(this).attr('href');
            rel = $(this).attr('rel');
            $.post(link, {
                usun_nadawca: 1,
                id: rel
            }, function(data) {
                msg(data);
                button.parent().parent().parent().parent().fadeOut(); });
        }
        return false;
    });

    /**
     * Usuwanie wiadomosci przez odbiorce
     */
    $('#odb a.usun_wiadomosc').click(function(){
        if(confirm(komunikaty.usunac_wiadomosc)){
            button = $(this);
            link = $(this).attr('href');
            rel = $(this).attr('rel');
            $.post(link,{
                usun_odbiorca: 1,
                id: rel
            }, function(data) { 
                msg(data);
                button.parent().parent().parent().parent().fadeOut(); });
        }
        return false;
    });

})

