jQuery(document).ready(function($) {
    $.get('languages/en/quotes.txt', function(data) {
		//var timer = setInterval( showDiv, 5000);
		//var counter = 0;
		var quotes = data.split("\@");
		showDiv(quotes);
    });
	
	function showDiv(quotes) {
			var idx = rand(quotes);
			var position = "#quote_right";
			$(position).html(quotes[idx]);
			idx = rand(quotes);
			
			animate(position, quotes);
			
			position = "#quote_left";
			idx = rand(quotes);
			$(position).html(quotes[idx]);
			animate(position, quotes);
	}
		
	function rand(quotes) { 
		return Math.floor(quotes.length * Math.random());
	}
	
	function animate (position, quotes) { 
		$(position).fadeIn( 'slow', function() { 
					//fadein complete
					setTimeout(function(){
				     $(position).fadeOut( 'slow' , function() {
								//fadeout complete
								showDiv(quotes);
							} ); 
					},10000);
				}	
			
			 );
	}
	
});
