function showImgBox3(box,img){
        var h;
        switch(img.index()){
            case 1:
                h=15;
                break;
            case 3:
                h=90;
                break;
            case 5:
                h=160;
                break;
        }
	if($(img).hasClass('sopra'))
		return;
	$(box).find('img').each(function(){
		if($(this)!=$(img) && $(this).attr('id')!='freccettina'){
			$(this).fadeOut(300);
			$(this).removeClass('sopra');
                        $(this).css('cursor','pointer')
                        //Aggiungo il collegamento anche all'immagine
                        $(this).click(function(){
                            var ind=$(this).prev().find('a').attr("href");
                            window.location=ind;
                        })
		}
	});
	$(img).stop(true,true).fadeIn(300);
	$(img).addClass('sopra');
        $('#freccettina').stop().animate({'top':(h)+'px'},250);
}
function nextBoxSlide3(){
   var i=$('.gallery1 img').index($('.gallery1 img:visible'))+1
   i=i>=3?0:i;
   showImgBox3($('.gallery1'),$('.gallery1 img').eq(i));
}
var TIME_SLIDE3,SPEED_SLIDE3=3500;
$(document).ready(function(){
	$('.gallery1 div').each(function(){
		$(this).hover(function(){
                        clearInterval(TIME_SLIDE3)
			showImgBox3($(this).parent(),$(this).next())
		},function(){
                  TIME_SLIDE3=setInterval(nextBoxSlide3,SPEED_SLIDE3)
                })
	})
        $('.gallery1').append('<img id="freccettina" src="images/freccettinabox3.png" alt="" title="" />')
        showImgBox3($('.gallery1'),$('.gallery1 img:eq(0)'));
        TIME_SLIDE3=setInterval(nextBoxSlide3,SPEED_SLIDE3)
        //alert($('.gallery1').html())
});
