var pathFiles = 'files/';

$().ready(function(){
    /*$(".ajax").live('click', function(){
        url = $(this).attr('href').split('=')[1];
        $.getJSON(pathFiles + url + '.php?ajax', function(data){
            $(".right-category .content").fadeOut('fast', function(){
                $(".right-category .content").html(data.title)
                .fadeIn('medium');
            });
            $(".right-text .content").fadeOut('fast', function(){
                $(".right-text .content").html(data.content)
                .fadeIn('medium');                
            }); 
        });
        return false;
    });*/
    $(".ajax").each(function(i, obj){
        $(this).attr('href2',$(this).attr('href').split('=')[1]);
        $(this).remote(".right-category .content", {hashPrefix: ''});
    });
    
    $.ajaxHistory.initialize();
    /* gielda */
    $("#step-zglaszajacy input[name=type]").live('change', function(){
        $("#step-zglaszajacy .gielda-form-toggle").toggle();
        
    });
    $("#step-dluznik input[name=type]").live('change', function(){
        $("#step-dluznik .gielda-form-toggle").toggle();
        
    });

    $(".gielda-form").live('submit', function(){
        var obj = $(this);
        $.ajax({
            url: $(this).attr('action') + '&key=' + key + '&edit=' + edit,
            type: 'post',
            data: $(this).serialize(),
            success: function(msg){
                if(msg=='ok'){
                    $("#komunikat").html('');    
                    // next
                    obj.parent().hide()
                    .next().show();
                }
                else if(msg.substr(0, 2)=='ok')
                {
                    msg = msg.substr(2);
                    $("#komunikat").html(msg);
                    obj.parent().hide();
                }
                else{
                    $("#komunikat").html(msg);                    
                }
            },
        })
        return false;
    })
    $(".back").live('click', function(){
        $(this).parent().parent().parent().parent().parent().parent().hide()
        .prev().show();
    })
    
    $(".lista_dluznikow td").live('click', function(){
        if(!$(this).is('input'))
        $(this).find("ul").toggle();        
    })
});

