// JavaScript Document
$(document).ready(function(){
	
	var quotes_json = "scripts/quotator_quotes.js";
	var quotes;
	
	$.getJSON(quotes_json, function(data){
		var quotesobject = eval(data.quotes);
		var index = Math.floor(Math.random() * quotesobject.length);
		
		
		setInterval(changeQuote, 5000);
		
		$('#quote h2').html(quotesobject[index].quote);
		
		
		function changeQuote(){
			$('#quote h2').fadeOut(function(){
				$('#quote h2').html(quotesobject[index].quote).fadeIn();
			});
			
			if(index == quotesobject.length - 1){
				index = 0;
			} else{
				index++;
			}
		}
			
	});
	

});
