$(document).ready(function(){
						   
	/* Aggiungo un elemento al li del top menu per visualizzare la linea a sinistra del tab */
	$('#navbar li.category').append('<span class="top_menu_line">line</span>');
	
	// ITEM IMAGES - GALLERY ITEM
	$('#top_gallery').cycle({ 
		fx:     'fade', 
		timeout: 4000, 
		next:   '#next-image', 
		prev:   '#prev-image'
	});
	
	$('a.cat_17').attr('target', '_blank');
	
	/*Personalizzazione select booking form*/
	$('.my-dropdown').sSelect();
	$('#hotel_list .my-dropdown').sSelect();	
	
	/*Fancybox*/
	$(".group").fancybox({
		titlePosition: 'over'
	});
	
	/*Logo png trasparente*/
	$('div#logo,div#slideshow').pngFix();

	// VIEW ALL delle pagine eventi / offerte
	$('#view_all').click(function(){
		$('.featured').fadeOut(500);
		$('.all_hidden').fadeIn(500);
		$(this).css("display","none");
		return false;
	});
	
	/*Gallery nel default item*/
	jQuery(function($) {
		$('.small_gallery_demo_unstyled').addClass('small_gallery_demo'); // adds new class name to maintain degradability
		$('ul.small_gallery_demo').galleria({
			history   : true, // activates the history object for bookmarking, back-button etc.
			clickNext : true, // helper for making the image clickable
			insert    : '#main_image_small', // the containing selector for our main image
			onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes				
				// fade in the image & caption
				if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
					image.css('display','none').fadeIn(1000);
				}
				caption.css('display','none').fadeIn(1000);
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// fade out inactive thumbnail
				_li.siblings().children('img.selected').fadeTo(500,0.3);
				
				// fade in active thumbnail
				thumb.fadeTo('fast',1).addClass('selected');
				
				// add a title for the clickable image
				image.attr('title','');
			},
			onThumb : function(thumb) { // thumbnail effects goes here
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// if thumbnail is active, fade all the way.
				var _fadeTo = _li.is('.active') ? '1' : '0.3';
				
				// fade in the thumbnail when finnished loading
				thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
				
				// hover effects
				thumb.hover(
					function() { thumb.fadeTo('fast',1); },
					function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
				)				
			}			
		});
	});
	/*Fine Gallery nel default item*/
	
	
	
	// Link_exchange pager
	$('#link_exchange_links .pager').find('a').live('click', function () {
		var that = $(this);
		$('#link_exchange_links_container').height($('#link_exchange_links_container').height()).addClass('loading');
		$('#link_exchange_links').fadeOut(200, function () {
			$(this).load(that.attr('href') + ' #link_exchange_links > *', function  () {
				$(this).fadeIn(200);
				$('#link_exchange_links_container').height('auto').removeClass('loading');
			});
		});
		return false;
	});

	// Guest comments pager
	$('#guestcomments .pager').find('a').live('click', function () {
		var that = $(this);
		$('#guestcomments-container').height($('#guestcomments-container').height()).addClass('loading');
		$('#guestcomments').fadeOut(200, function () {
			$(this).load(that.attr('href') + ' #guestcomments > *', function  () {
				$(this).fadeIn(200);
				$('#guestcomments-container').height('auto').removeClass('loading');
			});
		});
		return false;
	});
	
});
