
	$('ul.sf-vertical').superfish({
		delay:       1000,                            // one second delay on mouseout 
        animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
        speed:       'fast',                          // faster animation speed 
        autoArrows:  false,                           // disable generation of arrow mark-up 
        dropShadows: false
    });
	$('#menu_thumb li a').live('click',function(eve) {
		eve.preventDefault();
		var el = '#'+this.id+' img';
		var href= $(el).attr('src');
		$('#gallery_detail').empty();
		$('#gallery_detail').css('opacity',0);
		$('#gallery_detail').append("<img alt='gianluigi di maio' id='big_"+this.id+"' src='"+href+"' />");
		$('#gallery_detail').animate({"opacity": "1"},"slow");
		$('#corrente').empty();
		var id_corrente = this.id.replace("thumb_","");
		id_corrente = parseInt(id_corrente)+1;
		$('#corrente').append(id_corrente);
		$('#testo_immagine').css('opacity',0);
	})
	
	$(document).ready(function() {
	$('#testo_immagine').css('opacity',0);
	
	$('#imgrot').cycle({
		fx: 'fade',
		pause: 1,
		timeout: 50,
		speed:  3000 
	});
	
	var thumb = new Array();
	thumb.push('');
	var longdesc = new Array();
	longdesc.push('');
	var altezza = 0;
	$('#menu_thumb li a img').each(function(index){
		thumb.push(this.src);
		altezza += $(this).attr('height');
		longdesc.push($(this).attr('longdesc'));
	});


	
	$('ul.menu li').live('mouseover',function() {
		var n_elementi = 0;
		var idel = '#'+this.id+' ul';
		$(idel).find("li").each(function(i) {
    	n_elementi ++;
		});
		$('ul.menu li ul').css('top','9998px');
		$(idel).css('top',-(n_elementi*25));
		
	});
	
	
	$('#gallery_detail img').live('click',function() {
		var id = this.id.replace("big_thumb_","");
		$('#testo_immagine').empty();
		$('#testo_immagine').append(longdesc[id]);
		$('#testo_immagine').animate ({
			opacity:'0.8'
		});
		$('.thumb_scroller').animate({
    		left: '660'
  		});
  		var nascondi = setInterval(hide,10000);
  	});
	
	
	$('#slideshow').html('<a href="#" id="stop_auto_thumb" style="display:none"><img src="/assets/theme/images/stop.jpg" alt="stop"/></a><a href="#" id="auto_thumb">slideshow</a><a href="#" id="indietro_thumb"><img src="/assets/theme/images/indietro.jpg" alt="back"/></a><a id="corrente">1</a>/<a href="#" id="totale">'+(thumb.length-1)+'</a><a href="#" id="avanti_thumb"><img src="/assets/theme/images/avanti.jpg" alt="forward"/></a>');
	
	$('#avanti_thumb').live('click',function() {
		var el_corrente = $('#content img').attr('id');
		var id_corrente = el_corrente.replace("big_thumb_",""); 
		var id_successivo = parseInt(id_corrente)+1;
		if (id_successivo == thumb.length) {id_successivo = 1;}
		$('#gallery_detail').empty();
		$('#corrente').empty();
		$('#corrente').append(id_successivo);
		$('#gallery_detail').css('opacity',0);
		$('#gallery_detail').append("<img id='big_thumb_"+id_successivo+"' alt='avanti' src='"+thumb[id_successivo]+"'/>");
		$('#gallery_detail').animate({"opacity": "1"},"slow");
		clearInterval(showcase);
		$('#auto_thumb').empty();
		$('#auto_thumb').append('slideshow');
		$('#stop_auto_thumb').css('display','none');
		$('.thumb_scroller').animate({
    		left: '660'
  		});
  		$('#testo_immagine').css('opacity',0);
	})
	$('#indietro_thumb').live('click',function() {
		var el_corrente = $('#content img').attr('id');
		var id_corrente = el_corrente.replace("big_thumb_",""); 
		var id_precedente = parseInt(id_corrente)-1;
		if (id_precedente == 0) {id_precedente = (thumb.length-1);}
		$('#gallery_detail').empty();
		$('#corrente').empty();
		$('#corrente').append(id_precedente);
		$('#gallery_detail').css('opacity',0);
		$('#gallery_detail').append("<img id='big_thumb_"+id_precedente+"' alt='precedente' src='"+thumb[id_precedente]+"'/>");
		$('#gallery_detail').animate({"opacity": "1"},"slow");
		clearInterval(showcase);
		$('#auto_thumb').empty();
		$('#auto_thumb').append('slideshow');
		$('#stop_auto_thumb').css('display','none');
		$('.thumb_scroller').animate({
    		left: '660'
  		});
  		$('#testo_immagine').css('opacity',0);
	})
	function automatic () {
		var el_corrente = $('#gallery_detail img').attr('id');
		var id_corrente = el_corrente.replace("big_thumb_",""); 
		var id_successivo = parseInt(id_corrente)+1;
		if (id_successivo == thumb.length) {id_successivo = 1;}
		$('#gallery_detail').empty();
		$('#gallery_detail').css('opacity',0);
		$('#corrente').empty();
		$('#corrente').append(id_successivo);
		$('#gallery_detail').append("<img id='big_thumb_"+id_successivo+"' src='"+thumb[id_successivo]+"'/>");
		$('#gallery_detail').animate({"opacity": "1"},"slow");
		$('#testo_immagine').css('opacity',0);
	}
	function blink () {
 		//$(".thumb_open").animate( { backgroundColor: '#5a0426' }, 3000).animate( { backgroundColor: '#000000' }, 3000);
		$(".thumb_open img").animate( { opacity: 0}, 1000).animate( { opacity: 0.8 }, 1000);

	}
	function hide() {
		$('#testo_immagine').animate({opacity:'0'},3000);
		
	}
	var lampeggio = setInterval(blink,2000);
	var showcase;
	$('#auto_thumb').live('click',function() {
		if ($('#auto_thumb').html() =='slideshow') {
			$('#auto_thumb').empty();
			$('#auto_thumb').append('automatic');
			$('#auto_thumb').append('<img class="timer" alt="timer" src="/assets/theme/images/timer.gif"/>');
			$('#stop_auto_thumb').css('display','inline');
			showcase = setInterval(automatic,4000);
		}
	})
	$('#stop_auto_thumb').live('click',function() {
		$('#auto_thumb').empty();
		$('#auto_thumb').append('slideshow');
		$('#stop_auto_thumb').css('display','none');
		clearInterval(showcase);
	});	
	
	//var altezza_totale = parseInt($('#menu_thumb').css('height'));
	var altezza_totale = parseInt($('#menu_thumb').height());
	var altezza_blocco = 500;
	var diff = altezza_totale;
	$('#thumb_scroller_up').live('mouseover',function() {
		if (diff < altezza_totale) {
			diff = diff + altezza_blocco;
			$('#menu_thumb').animate({top:'+=500'},3000);
		}
	})
	
	$('#thumb_scroller_down').live('mouseover',function() {
		
		if (diff > 500) {
			diff = diff - altezza_blocco;
			$('#menu_thumb').animate({top:'-=500'},3000);
		}
	})


	})
	
	$('.thumb_open').live('mouseover',function() {
		posnow = $('.thumb_scroller').position().left;
		if (posnow == 660) {
			$('.thumb_scroller').animate({
    			left: '520'
  			});
  		} else if (posnow == 520) {
			$('.thumb_scroller').animate({
    			left: '660'
  			});
  		}
	})

