(function($){
     $.fn.refreshQuote = function(options) {
         this.each(function() {
             var link = $(this);
             link.data('seen_quotes', []).click(function(){
                 var seen_quotes = link.data('seen_quotes');
                 
                 $.getJSON(options.url, {
                     exclude: seen_quotes
                 }, function(data) {
                     if (data.error) {
                         alert(data.error);
                         return;
                     }
                     options.target.html(data.quote);
                     if (data.is_new) {
                         seen_quotes.push(data.quote_id);
                         link.data('seen_quotes', seen_quotes);
                     }
                 });
                 return false;
             });
         });
     };
})(jQuery);

