$(document).ready(function() {
    // potwierdzenie usunięcia elementu
    if ($("a.confirm-delete")[0]) {
        $("<div>", {
            'class': "modal",
            id: "yesno",
            html: "<h2>Usunięcie elementu</h2><p>Czy jesteś pewien, że chcesz usunąć ten element?</p><p><button class='close button'>Tak</button> <button class='close button'>Nie</button></p>"
        }).appendTo('body');
        
        $("a.confirm-delete").attr('rel', '#yesno');
        
        var trigger;
        var triggers = $("a.confirm-delete").overlay({ 
            expose: { 
                color: '#fff', 
                loadSpeed: 200, 
                opacity: 0.9 
            }, 
            onLoad: function(){
                trigger = this.getTrigger();
            },
            closeOnClick: false 
        });
        
        var buttons = $("#yesno button").click(function(e) { 
            var yes = buttons.index(this) === 0; 
            if (yes) {
                window.location = trigger.attr("href"); 
            }
        });
    }
    
    // komunikaty
    if ($(".info, .success, .warning, .error, .validation, .notice")[0]) {
        $("<span>", {
            'class' : 'close',
            text: "x",
            click: function(){
                $(this).parent().slideUp('slow', function(){
                    $(this).remove();
                });
            }
        }).appendTo(".info, .success, .warning, .error, .validation, .notice");
        
        setTimeout(function() {
            $('.info, .success, .warning, .error, .validation, .notice').slideUp('slow', function(){
                $(this).remove();
            });
        }, 10000); 
    }
});

