$(document).ready(function() {
	var current = 0;
	var total = $('.sweater').size();
	
	$('#arrow_right').click(function() {
		if(current == (total - 1))
			current = 0;
		else
			current++;
		showSweater(current, total);														 
	});
	
	$('#arrow_left').click(function() {
		if(current != 0)
			current--;
			
		showSweater(current, total);
	});

	showSweater(current, total);
});

function showSweater(current, total)
{
	$('.sweater').hide();
	$('.caption').hide();
	$('.sweater:eq(' + current + ')').fadeIn(500);
	$('.sweater:eq(' + current +')').hover(
		function()
		{
			$('.sweater:eq(' + current + ') .caption').fadeIn(500);
		},
		function()
		{
			$('.sweater:eq(' + current + ') .caption').hide();
		}
	);
	$('div#control span').html((current + 1) + '/' + total);
	
	if(current > 0) 
		$('img#arrow_left').show();
	else
		$('img#arrow_left').hide();
		
	if((current + 1) == total)
		$('img#arrow_right').hide();
	else
		$('img#arrow_right').show();
}