$(document).ready(function() {
	rotateNow = true;
	
	function rotatePhoto(li, speed) {
		if (rotateNow) {
			label = $(li).children('.label');
			photo = $(label).siblings('img');
			caption = $(label).siblings('.caption');
			$('.feature-list li').removeClass('active');
			$(li).addClass('active');
			$('.feature-list img').not(photo).fadeOut(speed);
			$('.feature-list .caption').not(caption).fadeOut(speed);
			$(photo).fadeIn(speed);
			$(caption).fadeIn(speed);
		}
	}
	
	doRotate = function () {
		if($('.feature-list .active').is(':last-child')) {
			rotatePhoto($('.feature-list li').eq(0), 500);
		} else {
			rotatePhoto($('.feature-list .active').next().eq(0), 500);
		}
	}
	
	$('.feature-list li').hover(function () {
		rotatePhoto(this, 1);
		rotateNow = false;
	}, function () {
		rotateNow = true;
	});
	
	rotatePhoto($('.feature-list li').eq(0), 1);
	
	rotateInterval = setInterval(doRotate, 7000);
	
	$('.site-nav li a').hover(function () {
		$(this).addClass('hover');
	}, function () {
		$(this).removeClass('hover');
	});

});
