$(document).ready(function(){
	var $moreInfoDiv = $('#more-about-the-restaurant');
	$moreInfoDiv.hide();
	
	$('#more-info-link').toggle(
		function(){
			$moreInfoDiv.fadeIn('fast');
			$(this).text('Read less about the restaurant -')
		},
		function(){
			$moreInfoDiv.fadeOut('fast');
			$(this).text('Read more about the restaurant +')
		}
	);
	
	slideSwitch();
	
});


function slideSwitch() {
	
	var container 	= $('#slideshow'),
		children	= container.find('li'),
		length 		= children.length,
		randomStart	= Math.floor(Math.random() * length);
		
	children.eq(randomStart)
		.addClass('active')
		.parent()
			.data('active-index',randomStart);
			
	container.animate({opacity:1},100);
	
	setInterval(function(){
		var currentIndex = container.data('active-index'),
			current = children.eq(currentIndex),
			random = function(){
				var tmpRandom = currentIndex;
				while(tmpRandom == currentIndex) {
					tmpRandom = Math.floor(Math.random() * length);
				}
				return tmpRandom;
			},
			uniqueRandom = random(),
			next = children.eq(uniqueRandom);
			
			current.addClass('last-active');
			
			next.css({opacity:0}).addClass('active').animate({opacity:1.0}, 1000, function(){
				container.data('active-index', uniqueRandom);
				current.removeClass('active last-active');
			});
			
	}, 3000);


}
