/**
 * jQuery-Plugin "tooltipbox"
 * @version: 0.1, 01.08.2011
 *
 * @example: $('selector').tooltipBox(action [, boxselector]);
 * actions :
 * .toolTipBox('close')
 * .toolTipBox('open')
 */

(function ($) {
  $.fn.tooltipbox = function (action, boxselector) {
    var box = $(boxselector || "div[rel=tooltipbox]");
    return this.each(function (index, self) {
        var actions = {
            open : function() {
                var coords = $(self).offset();

                box.css({
                    top : coords.top - box.height() - 20,
                    left : coords.left
                })
                box.show();
                box.fadeIn();
            },
            close : function() {
                box.fadeOut();
                box.hide();
            }
        }
        actions[action].call();
    });
  };
})(jQuery);
