(function($) {
  $.flash = new Object();

  $.flash.data = function(key) {
    if (!this._data) {
      this._data = $.toJSON(unescape($.cookie("flash"))) || {};
      $.cookie("flash", null, {expires: -1, path: '/'});
    };
    return this._data[key] != undefined ? this._data[key].replace(/\+/g, ' ') :
                                          undefined;
  }
})(jQuery);

jQuery(function($) {
  var notice, error;

  if (notice = $.flash.data('notice')) {
    $('div.notice').show().html(notice);
  };
  
  if (error = $.flash.data('error')) {
    $('div.error').show().html(error);
  };
});
