// JavaScript Document
(function($){
  $.fn.quotator = function(options){
    var container = this;
    var defaults = 
    {
      speed : 11000,
      quotes : [
                    {
                        "quote" : "No quote",
                        "author" : "?"
                    }]
    }
    
    var options = $.extend(defaults, options);
    
    
    var quotesobject = eval(options.quotes);
    var index = 0;
    
    
    setInterval(changeQuote, options.speed);
    
    container.html("<div class='quote_text'>" + quotesobject[index].quote + "</div>" +
        "<br clear='all'/><div class='quote_author'>" + quotesobject[index].author + "</div>");
        
    function changeQuote(){
      container.fadeOut(function(){
        container.html("<div class='quote_text'>" + quotesobject[index].quote + "</div>" +
            "<br clear='all'/><div class='quote_author'>" + quotesobject[index].author + "</div>").fadeIn();
      });
      
      if(index == quotesobject.length - 1){
        index = 0;
      } else{
        index++;
      }
    }
  return container;
}
})(jQuery);