﻿function slideBox(){	
	$('#header-slider').cycle({
		fx: 'fade',
		speed: 2000,
		timeout: 4500
	});
			
	$('#offerte-wrapper').cycle({
		fx: 'scrollLeft',
		speed: 2500,
		timeout: 6500
	}).mouseenter(function(){
		$(this).cycle('pause');
	}).mouseleave(function(){
		$(this).cycle('resume');
	});
}

function animateSez(){	
	$('#sezioni').find('li').each(function(event){
		var $this = $(this);
		$this.mouseenter(function(){
			$this.animate({'top':'0'}, 'slow');
		}).mouseleave(function(){
			$this.animate({'top':'-150'}, 'slow');
		});
	});
}

function gallery(){
	$('#gallery').find('img').each(function(event){
		var $this = $(this);
		var src = $this.attr('src').replace('.jpg','_zoom.jpg');
		$this.parent().html('<a href="'+ src +'" rel="shadowbox[aaa]">'+ $this.parent().html() +'</a>');
	});
}

function hotelclosed(){
	$('#overlay').fadeIn(function(){
		$('#box-chiuso').append('<div id="chiudi">chiudi &raquo;</div>');
		$('#box-chiuso').fadeIn();
	});
	
	$('#overlay, #box-chiuso').click(function(event){
		$('#box-chiuso').fadeOut(function(){
			$('body').css('height','auto');
			$('#overlay').fadeOut();
		});
	});
}


/*****************************************************************************************/


jQuery(document).ready(function(){ 
	slideBox();
	animateSez();
	$('#address').containedStickyScroll({ duration: 300, unstick: false });
	Shadowbox.init();
	gallery();
	if(!$('#footer-container').children().is('details')){
		$('#footer-container').append('<details>powered by <a href="http://about.me/tom.pz" target="_blanc">tom.pz</a></details>');
	}
});

jQuery(window).load(function(){
	$('#colonna-sx').height($('section').height() + parseInt($('section').css('paddingTop')) + parseInt($('section').css('paddingBottom')));
	if($('#chiuso').length){hotelclosed();}
});

/*****************************************************************************************/
