title: Using a js object or a plugin
body: <p>I have some code below, which works fairly well. But I am debating if it should be an object like it is, or a plugin.</p>
  
  <p>Right now it's an object in the global namespace, which is "bad" but if I did it as a plugin I am not sure what to bind it to since it doesn't really have a main element.....</p>
  
  <p>It works, but it doesn't feel right.
  I guess using a plugin or something in the objects functions I wouldn't have to use flashMessage. but could use this. ?</p>
  
  <pre><code>$( document ).ready(function() {
  
      flashMessage = {
          success: function(message, element) {
              flashMessage.showMessage('success', message, element);
          },
          error: function(message, element) {
              flashMessage.showMessage('error', message, element);
          },
          showMessage: function(type, message, element) {
              $('div.alert').remove();
              element = element ? element : '.main-content';
              var template = flashMessage.getTemplate(type);
              if(template) {
                  $(element).prepend(template).find('.message').first().text(message);
              }
          },
          getTemplate: function(type) {
              return $('#' + type + '-flash-template').html();
          }
      }
  });
  </code></pre>