$(document).ready(function () {
	$('#fotosld').cycle({'fx':'fade', 'before': nascondi, 'after':mostra, pause:true, timeout: 7500, pager : '#pager'});
	$('#descrizioni').hover(function() {
		$('#fotosld').cycle('pause');
	}, function() {
		$('#fotosld').cycle('resume');
	});

	$('a#showgalr').click(function() {
		$('#blkgalleryhm').toggle('slow');
        $('#blkgalleryhm').append(function() {
		  var iframe = '<iframe src="./galleryhome.php" id="ifrgal"></iframe>';
		  return iframe;
		});
		$("body").one("click", function() {
		  $('#blkgalleryhm iframe').remove();
		  $('#blkgalleryhm').hide('slow');
		  return false;
		});
		return false;
    });

	$('a#blkglrcls').click(function() {
		$('#blkgalleryhm iframe').remove();
 	    $('#blkgalleryhm').hide('slow');
		return false;
    });

});

function nascondi() {
	if(!isNaN(parseInt($('.activeSlide').html()))) {
		$('.rowslider').hide('fast');
	} else {
		$('.rowslider:eq(0)').show();
	}
}

function mostra() {
	if(!isNaN(parseInt($('.activeSlide').html()))) {
		fotoattiva = parseInt($('.activeSlide').html());
		$('.rowslider:eq('+(fotoattiva-1)+')').show('fast');
	}
}
