function askConfirmation(event, message) { // Dummy function that later should be replaced by something fancy
    if (event.control) {
        return true;
    } else {
        return confirm(message);
    }
}


window.addEvent('domready', function() {
    $$('a.delete-attachment').addEvent('click', function(e) {
        e.preventDefault();
        if (askConfirmation(e, 'Are you sure to delete the attachment?')) {
            e.target.addClass('busy');
            new Request.JSON({
                url: e.target.getParent().get('href'),
                onSuccess: function(data) {
                    e.target.getParent().destroy();
                }
            }).post();
        }
    });

    $$('a.delete-page').addEvent('click', function(e) {
        e.preventDefault();
        if (askConfirmation(e, 'Are you sure to delete this page?')) {
            new Request.JSON({
                url: e.target.getParent().get('href'),
                onSuccess: function(data) {
                    window.location = data.location;
                }
            }).post();
        }
    });
});

