function usun_zdjecie(id){
    if (confirm("Na pewno usunąć wskazane zdjęcie?")){                                                                    
        $.ajax({
           type: "GET",
           url: "/galeria/file/usun/" + id + "/",
           success: function(msg){
              $('#f_' + id).css({height:$('#f_' + id).height(), overflow: "hidden"});                    
              $('#f_' + id).animate({"width": 0, "opacity": 0, "marginRight": 0}, 500, function() {$('#f_' + id).remove(); PaginatorSetPage(current_page)});;
           }
        });
    }
}

function edytuj_zdjecie(id){
    $.ajax({
           type: "GET",
           url: "/galeria/file/edytuj/" + id + "/",
           success: function(msg){                    
              $('#edit_box').html(msg);
           }
        });
} 

function edytuj_opcje(option, id, el) {                                   
    $.ajax({
           type: "POST",
           data: "checked=" + $(el).attr('checked'),
           url: "/galeria/file/option/" + option + "/" + id + "/"
        });
    if ((option == 'main')&&($(el).attr('checked') == true)){
        $('.checks').filter(function(){var re = new RegExp("ot_[0-9]+"); return this.id.match(re);}).each(function(){
            if (this.id != 'ot_'+id){
                $(this).attr('checked', false);
            }
        });
    }
}

function swapFile(id, inc, min_page, max_page){
    file_list = $('.file_list');
    for (i=0; i< file_list.length; i++){
        if (file_list[i].id == 'f_' + id){
            file1 = file_list[i];
            file2 = file_list[i - inc];
            if (!file2){
                return false;
            }
            break;
        }
    }
    
    if (inc > 0){
        $(file2).before(file1);
    } else {
        $(file2).after(file1);    
    }
    
    PaginatorSetPage(current_page);
    f1 = file1.id.split('_')[1];
    f2 = file2.id.split('_')[1];

    $.ajax({
           type: "GET",
           url: "/galeria/file/swap/" + f1 + "/" + f2 + "/"
        });    
}
