$(document).ready(function() {
        $("a.kat").click(function() {
                if ($("tr.nowaKategoria").css('display')=='none')
                    $("tr.nowaKategoria").css('display', 'table-row');
                else
                    $("tr.nowaKategoria").hide();            
                return false;
            });

        $("a.katIE").click(function() {
                if ($("tr.nowaKategoria").css('display')=='none')
                    $("tr.nowaKategoria").css('display', 'block');
                else
                    $("tr.nowaKategoria").hide();
                return false;
            });

        $("a.editThread").click(function() {
                //chowamy pozostałe:
                $("a.cancelEdit").click();
                var id = $(this).attr("title");
                var title = $(this).parent().siblings(".temat").children("a").text();
                if ($(this).parent().siblings(".editForm").length) {
                    $(this).parent().siblings(".editForm").show();
                }
                else {
                    select = $('#categorySelect');
                    //tworzymy form:
                    var td = $('<td class="editForm"><form action="/forum/threads/editThread/'+id+'" method="post"></form></td>').
                        children("form")
                        .append($('<input type="text"/>').attr("name", "title").val(title));
                    if (select.length) {
                        //he can move the thread:
                        td.append(select.clone());
                        select.show();
                    }
                    td = td.append($('<input type="submit"/>').val("Zapisz"))
                        .append($("<a></a>").addClass("cancelEdit").text("anuluj")).parent();
                    $(this).parent().after(td);
                }
                $(this).parent().siblings(".temat").hide();
                return false;
            });
        $("a.cancelEdit").live("click",function() {
                $(this).parent().parent(".editForm").hide().siblings(".temat").show();
            });
        /*$("a.moveThread").click(function() {
                //tworzymy form:
                
                bu
                $("a.moveThread").show();
                $(this).after(select);
                $(this).hide();
                select.show();
                return false;
                });*/
    });

