;(function($) {
  $.extend($.fn,{
    bubble:function(options) {
      if (options.target) {
        var $target = $(options.target);
        var target_position = $target.offset() ;
        var position = [
                          target_position.left,
                          target_position.top + $target.height() + 10
                        ];
      }
      else {
        var $target = $("body")
        var target_position = $target.offset();
        var position = [
                          "center",
                          $target.offset().top + $target.width() + 10,
                        ];
      }
      if ($target) {
        if (options.message.length) {
          var $bubble = $('<div id="bubble">'+options.message+'</div>');
          $("body").append($bubble);
          $bubble.dialog({
              title: false,
              position: position,
              show: "fade",
              hide: "fade",
              resizable: false,
              open: function () {
                $(".ui-dialog-titlebar").hide();
                setTimeout(function () {
                  $bubble.dialog("close");
                }, 2000);
              }
            }
          );
        }
      }
    }
  });
})(jQuery);
