$(document).ready(function(){	
    count = 0;
	
	quote = $("#mainQuote");
	quote.hide();
	quot = quotes[count];
	quote.html("<a href='" + quot[3] + "' target='_blank' class='quot-details' >" + quot[2] + "</a><cite><a href='" + quot[3] + "' target='_blank'><span>" + quot[0]  + "</span></a>" + quot[1] + "</cite>").show();
	
	var ready = true;
	var nextQuote = function(){
		count = count + 1;
		if (count == quotes.length){
			count = 0;	
		}
		
		
		quot = quotes[count];
		quote.clearQueue().fadeOut(300,function(){	
				quote.html("");
				quote.html("<a href='" + quot[3] + "' target='_blank' class='quot-details'>" + quot[2] + "</a><cite><a href='" + quot[3] + "' target='_blank'><span>" + quot[0]  + "</span></a>" + quot[1] + "</cite>")
			});
			quote.fadeIn(300);
		
		
		//console.log("QUOTE LENGTH:" + (quotes.length -1) + "COUNT:" + count);

		if (ready){
		setTimeout(nextQuote,5000);
		}
		ready = true;
		//console.log(count);
	}
	
	if (quotes.length > 1){
		setTimeout(nextQuote,5000);
	}
	
	
});
