// JavaScript Document
var slideshow = false;

function autoslides() {
	if(!slideshow) {
		slideshow = $('#slideshow').cycle({
			fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
			timeout: 3000,  // milliseconds between slide transitions (0 to disable auto advance) 
			speed: 1000,
			delay: -4000, // prima animazione 
			requeueOnImageNotLoaded: true
		});
	};

};
 
var state = 1;
function chiudi() {
	/* slides */
	if(slideshow) {
		slideshow.cycle('resume');
	} else {
		slideshow = $('#slideshow').cycle({
			fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
			timeout: 3000,  // milliseconds between slide transitions (0 to disable auto advance) 
			speed: 1000,
			delay: -4000, // prima animazione 
			requeueOnImageNotLoaded: false
		});
	}
	if($('#texts-orizz').length > 0) {

		 $('#texts-orizz').animate({
			 height: 35
			 }, 400, function() {
				 $('a', '#close').css("background-image", "url('/img/leggi.png')");
				 $('a', '#close').attr("title", "Leggi il testo");
		 });
		 $('#submenu').fadeOut('slow');
		 
		} else {
		
		 $('#texts-vert').animate({
			 width: 35
			 }, 400, function() {
				 $('a', '#close').css("background-image", "url('/img/leggiv.png')");
				 $('a', '#close').attr("title", "Leggi il testo");
		 });
			
	};
	 /* animate close */
	 $('#textsection').fadeOut('fast');
	 /* animate textsection */	
}
function apri() {
	slideshow.cycle('pause');

	if($('#texts-orizz').length > 0) {

		 $('#texts-orizz').animate({
			 height: 136
			 }, 400, function() {
				 $('a', '#close').css("background-image", "url('/img/guarda.png')");
				 $('a', '#close').attr("title", "Guarda le foto");
		 });
		 $('#submenu').fadeIn('slow');
		 
		} else {
		
		 $('#texts-vert').animate({
			 width: 164
			 }, 400, function() {
				 $('a', '#close').css("background-image", "url('/img/guardav.png')");
				 $('a', '#close').attr("title", "Guarda le foto");
		 });
			
	};
	  $('#textsection').fadeIn('slow');
	 /* animate textsection */
}


$(document).ready(function() {
	$("#close").click(function() {
		if(state == '0') {
			apri();
			state = 1;
		} else {
			chiudi();
			state = 0;
		}
	});
});

