// JavaScript Document
(function($){
	$.fn.quotator = function(options){
		var container = this;
		var defaults = 
		{
		speed : 5000,
		json : "wp-content/themes/leadershipinc/assets/scripts/quotator_quotes.js"
		}
		
		var options = $.extend(defaults, options);
    
		var quotes_json = options.json;
		var quotes;
		
		
		$.getJSON(quotes_json, function(data){
			var quotesobject = eval(data.quotes);
			var index = 0;
			
			setInterval(changeQuote, options.speed);
		
			$(container).html(quotesobject[index].quote);
		
			function changeQuote(){
				$(container).hide('slide', { direction: 'down', easing: 'easeInOutBack' }, 1200)
				.animate({ opacity: 1.0 }, 500, function() {
					$(container).html(quotesobject[index].quote).show('slide', { direction: 'down', easing: 'easeInOutQuad', duration: 700 });
				});
				
				if(index == quotesobject.length - 1)
				{
					index = 0;
				} 
				else
				{
					index++;
				}
			}
      
		});
	return container;
}
})(jQuery);