var slideShowTimeout = 2500;

$(function() {
	
	$('img.hover').mouseover(function() {
		$(this).attr('src', $(this).attr('src').replace(/^(.*[^_][^h])(\.\w{3,4})$/, '$1_h$2'));
	});
	$('img.hover').mouseout(function() {
		$(this).attr('src', $(this).attr('src').replace(/^(.*)_h(\.\w{3,4})$/, '$1$2'));
	});
	
	$('#collection .patterns ul:not(.links):not(.nav) li:not(.group) a').mouseover(function() {
		$('#collection .patterns ul li .roll').removeClass('show');
		$(this).siblings('.roll').addClass('show');
	});
	$('#collection .info .colors li[link]').click(function() {
		$('#collection .image img').attr('src', $(this).attr('link'));
	});
	
	
	if ($('#intro').length) {
		setTimeout(showNextImage, slideShowTimeout);
	}
});

var currentImage = 0;
function showNextImage() {
	var shownImage = $('#intro #slideshow img:eq('+currentImage+')');
	currentImage++;
	var nextImage = $('#intro #slideshow img:eq('+currentImage+')');
	
	
	if (nextImage.length) {
		shownImage.fadeOut(1000);
		nextImage.fadeIn(1000);
		setTimeout(showNextImage, slideShowTimeout);
	}
	else {
		$('#intro #slideshow').fadeTo(1000, 0.5);
		$('#intro #links').fadeIn(1000);
	}
	
}
