var timer;
var currentImageIndex = 0;

function nextImage( item ){
	nextImageIndex = (currentImageIndex + 1) % $("img.logo",item).length;
	$("img.logo",item).eq(currentImageIndex).animate(
		{ opacity: 0.0 },
		{
			queue: false,
			duration: "normal"
		}
	);
	$("img.logo",item).eq(nextImageIndex).animate(
		{ opacity: 0.8 },
		{
			queue: false,
			duration: "normal"
		}
	);
	
	currentImageIndex = nextImageIndex;
}

$(function(){
	$(".body .right .product-lines .menu a.item .hover").css(
		{ opacity: 0.0 }
	);
	$(".body .right .product-lines .menu a.item").hover( 
		function(){
			var item = $( this );
			$("img.logo",item).eq( currentImageIndex ).animate(
				{ opacity: 0.8 },
				{
					queue: false,
					duration: "fast"
				}
			);
			$("img.caption.hover",item).animate(
				{ opacity: 1.0 },
				{
					queue: false,
					duration: "fast"
				}
			);
			timer = setInterval(
				function(){ 
					nextImage( item )
				}
				,
				1000
			);
		}
		,
		function(){
			clearInterval( timer );

			$("img.logo",this).stop().animate(
				{ opacity: 0.0 },
				{
					queue: false,
					duration: "fast"
				}
			);
			
			$("img.caption.hover",this).animate(
				{ opacity: 0.0 },
				{
					queue: false,
					duration: "fast"
				}
			);
			currentImageIndex = 0;
		}
	);
});
