(function ($) {
  $.fn.notificationBar = function (options) {
    var opts = $.extend({}, $.fn.notificationBar.defaults, options);
    return this.each(function () {
      $this = $(this);
      var o = $.meta ? $.extend({}, opts, $this.data()) : opts;

      if (!$(".ntfbr").length) {
        timeout = setTimeout("$.fn.notificationBar.removeBar()", o.time);

        $this.addClass("ntfbr").addClass(o.css).addClass(o.css + "-" + o.position);

        if (o.closeButton) {
          var _close_button = $(document.createElement("a")).addClass(o.closeButtonCss);
          _close_button.click(function (e) { $.fn.notificationBar.removeBar(); })
          $this.append(_close_button);
        }
        else {
          $this.click(function (e) { $.fn.notificationBar.removeBar(); });
        }
        $this.hide().fadeIn("fast");
      }
    });
  };
  var timeout;
  $.fn.notificationBar.removeBar = function () {
    if ($(".ntfbr").length) {
      clearTimeout(timeout);
      $(".ntfbr").fadeOut("fast", function () {
        $(this).remove();
      });
    }
  }
  $.fn.notificationBar.defaults = {
    css: "notification-bar",
    position: "top",
    closeButton: true,
    closeButtonCss: "iepngfix notification-bar-close-button",
    time: 10000
  };
})(jQuery);
