// Funzione per mettere in homepage il 1° elemento della gallery 

$(function(){
	//$(document).pngFix(); 
	/* IE PNG FIX */
	$('.json_image_rotator .caption').ifixpng();
	
	//start(); 
	$('.hp-left .visible').css('display','block');
	$('.hp-left .loading').css('display','none');
	
	$('.hp-right .visible').css('display','block');
	$('.hp-right .loading').css('display','none');

	jQuery(document).ready(function() {
		// Initialise the first and second carousel by class selector.
		// Note that they use both the same configuration options (none in this case).
		jQuery('.first-and-second-carousel').jcarousel();
	});


	// VISUALIZZO LA RISPOSTA DELLA FAQ
	$(".link_faq").click(function(){
								  
		// ID elemento selezionato								  
		var hidden_id = parseInt($(this).parent('.moreinfo').attr('id').replace('h_', ''), 10); 
		
		// NASCONDO TUUTE LE RISPOSTE DELLE FAQ
		$(".faq_body .answer").each(function() {
			$(this).css("display","none");
			$(".link_faq").removeClass("yellow");
			$(".moreinfo span").removeClass("yellow");
		});						  
		
		$(this).addClass("yellow");
		$("#h_" + hidden_id + " span").addClass("yellow");
		$(".risp_" + hidden_id).show(500);
		return false;
	});
	
	
	// VIEW ALL delle pagine eventi / offerte
	$('#view_all').click(function(){
		$('.featured').fadeOut(500);
		$('.all_hidden').fadeIn(500);
		$(this).css("display","none");
		return false;
	});
	
	
});




	
/*******************************************************************************
********************* 		C A L E N D A R 		****************************
********************************************************************************/
/*Gestione calendario nella booking*/
$(function() {
jQuery(function(){
	
	// initialise the "Select date" link
	jQuery('.date-pick')
		.datePicker(

			//associate the link with a date picker
			{
				createButton:false,
				startDate:'<?php echo date("d/m/Y"); ?>',
				endDate:'<?php echo date("d/m/Y",time() + 63000000); ?>'
			}
		).bind(
			// when the link is clicked display the date picker
			'click',
			function()
			{
				updateSelects(jQuery(this).dpGetSelected()[0]);
				jQuery(this).dpDisplay();
				return false;
			}
		).bind(
			// when a date is selected update the SELECTs
			'dateSelected',
			function(e, selectedDate, $td, state)
			{
				updateSelects(selectedDate);
			}
		).bind(
			'dpClosed',
			function(e, selected)
			{
				updateSelects(selected[0]);
			}
		);
		
//		$('.selector').datepicker({ showOptions: {direction: 'up' });
		
	var updateSelects = function (selectedDate)
	{
		var selectedDate = new Date(selectedDate);
		jQuery('#d option[value=' + selectedDate.getDate() + ']').attr('selected', 'selected');
		jQuery('#m option[value=' + (selectedDate.getMonth()+1) + ']').attr('selected', 'selected');
		jQuery('#y option[value=' + (selectedDate.getFullYear()) + ']').attr('selected', 'selected');
	}
	// listen for when the selects are changed and update the picker
	jQuery('#d, #m, #y')
		.bind(
			'change',
			function()
			{
				var d = new Date(
							jQuery('#y').val(),
							jQuery('#m').val()-1,
							jQuery('#d').val()
						);
				jQuery('#date-pick').dpSetSelected(d.asString());
			}
		);
	
	// default the position of the selects to today
	var today = new Date();
	updateSelects(today.getTime());
	
	// and update the datePicker to reflect it...
	jQuery('#d').trigger('change');
	});
});


function check_date() {
	//var date_input = document.input_date.value;
	
	var date_input = document.idForm.input_date.value
	var dd = date_input.substring(0,2);
	var mm = date_input.substring(3,5);
	var yy = date_input.substring(6,10);
	document.idForm.fromday.value = dd;
	document.idForm.frommonth.value = mm;
	document.idForm.fromyear.value = yy;
	
	//alert(dd + "/" + mm + "/" + yy);
}


$(function() {
	start(); 
	
	
	// NASCONDO IL MENU A TENDINA DELLE NOTTI DELLA BF QUANDO SI APRE IL CALENDARIO, ALTRIMENTI IN IE6 VA SOTTO
	// EXAMPLE con CSS [da provare] -> http://www.cssplay.co.uk/menus/pro_drop8.html
	$('#date-pick').click (function(){
		$('#nbdays').css('visibility','hidden');
		$('.adulteresa-hotel').css('visibility','hidden');
		$('.enfantresa-hotel').css('visibility','hidden');
	});
	
	$('#date-pick').change (function(){
		$('#nbdays').css('visibility','visible');
		$('.adulteresa-hotel').css('visibility','visible');
		$('.enfantresa-hotel').css('visibility','visible');
	});
	// se clicco su una parte dello schermo senza selezionare una data...
	$('#wrapper').click (function(){
		$('#nbdays').css('visibility','visible');
		$('.adulteresa-hotel').css('visibility','visible');
		$('.enfantresa-hotel').css('visibility','visible');
	});
});




