var mensaje = {
   close_callback: null,

   close: function(hash) {
      if(mensaje.close_callback) {
         log('about to call out own callback')
         mensaje.close_callback()
      }
      mensaje.close_callback=null
      log('about to fade out the overlay')
      hash.w.addClass('offleft')
      hash.o.remove() 
   },

   open: function(hash) {
      hash.w.removeClass('offleft')
   },

   load: function(id) {
      return $(id).clone().show()
   },

   show: function(x,fun) {
      mensaje.close_callback=fun
      $('#error-message .inside').children().remove()
      $('#error-message .inside').append($(x))
      $('#error-message').jqmShow()
   },
   
   by_id: function(id,fun) {
      mensaje.show(mensaje.load(id),fun)
   },

   simple: function(html,fun) {
      mensaje.show(mensaje.load('#simpleerror').html(html),fun)
   },
   init: function() {
      $('#error-message').jqm({
         overlay: 60,
         trigger: false,
         onShow: mensaje.open,

         onHide: mensaje.close
      })
   }
};

$(function(){ mensaje.init() })
