var timeout;
var delay = 5000;

$(document).ready(function() {
	$('#tabs').tabs({
		fx: { opacity: 'toggle' }
	});
	
	$('#tabs li a').click(function() {
		clearTimeout(timeout);
	});
	
	$('#project div.images').delay(250).fadeIn('slow');
	$('#subNavigation a').wrapInner('<span></span>');
	
	startRotation();
});

$(window).load(function() {
	$('ul.designers').each(function() {
		var ul = $(this);
		
		var maxHeight = 0;
		ul.children('li').each(function() {
			var height = $(this).height();
			if (height > maxHeight) {
				maxHeight = height;
			}
		}).height(maxHeight);
	});
});

function startRotation() {
	timeout = setTimeout(
		function() {
			var selected = $('#tabs').tabs('option', 'selected');
			if (selected == 0) {
				selected = 1;
			}
			else {
				selected = 0;
			}
			
			$('#tabs').tabs('option', 'selected', selected);
			startRotation();
		},
		delay
	);
}