/* site side jquery actions */
(function() {
    $(function() {
        var remove = function() {
            $(this).fadeOut('slow', function() {
                $(this).remove();
                if ($('#flash-messages').children().length == 0)
                    $('#flash-messages').remove();
            });
        }

        // bind a remove event to each flash message
        $('p.flash').bind('REMOVE',remove);

        // remove a flash message when the user clicks the close.
        $('a.flash-close').click(function() {
            $(this).trigger('REMOVE'); // will bubble up
        });
    });
})();
