
$(document).ready(function(){

	$('.thumb').delegate('li','mouseover mouseleave', function(e){

		var item = $('.thumb').index($(this).parent()) + 1;
		var index = $('.thumb-' + item + ' li').index(this); 
		var klasa = $(this).attr("class");
		var dziel = klasa.split('-');	
	
		if (e.type == 'mouseover') {
			show_image(item, dziel[1]);
			changeOpacity($('.thumb-' + item + ' li img:eq(' + index + ')'), 0.5);
		} else {
			changeOpacity($('.thumb-' + item + ' li img:eq(' + index + ')'), 1);
		}
		
	});
  
	function reopactity(i, item){
		$('.thumb-' + item + ' li ').each(function(index) { 
			if(i != index) $('.thumb-' + item + ' li img:eq(' + index + ')').css('opacity', 1);
		  });	
	}
	
	function changeOpacity(item, value){
		$(item).animate({opacity: value}, 400);
	}
	
	function show_image(last, index){
		$('.big-image-' + last + ' img ').css('display', 'none');
		//$('.img-' + index).fadeIn('fast', function() {});
		$('.img-' + index).css('display', 'block');
	}
	
});
