	$(document).ready(function (){
		$('.tabContent:gt(0)').hide();
		$('.tabHeader > li:eq(0)').addClass('active');
		$('.tabHeader > li').click(showHideTabs);
		rotatePics(1);
	});

	function showHideTabs(){
		var allLi = $('.tabHeader > li').removeClass('active')
		$(this).addClass('active');
					
		var index = allLi.index(this);
		$('.tabContent:visible').hide();
		$('.tabContent:eq('+index+')').show();
	}


	function rotatePics(currentPhoto) {
		var numberOfPhotos = $('#photos img').length;
		currentPhoto = currentPhoto % numberOfPhotos;
		$('#photos img').eq(currentPhoto).fadeOut(function() {
			// re-order the z-index
			$('#photos img').each(function(i) {
				$(this).css(
					'zIndex', ((numberOfPhotos - i) + currentPhoto) % numberOfPhotos
				);
			});
			$(this).show();
			setTimeout(function() {rotatePics(++currentPhoto);}, 6000);
		});
	}
	
