$(function() {
	
	
	var domain = location.href;
	var ancora = domain.indexOf("#");
	if (ancora == -1) {
		
	} else {
		$('#items-page .list-items-page #hidden').fadeIn(500);
		$('.view').fadeOut(100);
		$('.list-items-featured').fadeOut(100);
	}	
	
//	var element_id = parseInt($('.anteprima .more-detail').parent('.moreinfo').attr('id').replace('h_', ''), 10); 
	
//	var str = $('.anteprima .more-detail').attr('href');
	
	//var ancora = str.indexOf("#");
	/*
	if (ancora == -1) {
		// non è un ancora
		
	} else {
		//alert(view);
		var view = true;
	}
	*/	
		
		
	
	//   B O O K I N G   F O R M
	$("#bf select").uniform();	
	start();  
	//$('#service_box, #shadow-top').pngFix(); 
	$('#shadow-top, #logo, .btn-pacchetto .book').ifixpng(); 
	
	
	
	//   L I S T  - P A G E

	$('.anteprima .more-detail').click(function(){
		
		
		/*
		var element_id = parseInt($(this).parent('.moreinfo').attr('id').replace('h_', ''), 10); 
		linked_page = $(this).attr('href') + ' .detail-list-page';
		
		$(".image").each(function() {	
			$(this).css("background","#D5CEC4");
		});
		
		$('.detail-list-page').load(linked_page, function() {	
			$('#image_'+element_id).css('background','#654F44');
		});
		return false; 
		*/
	});
	
	
	
	
	// 	F A Q
	$(".faq_box .answer").each(function() {	
		$(this).css("display","none");
	});	
	// VISUALIZZO LA RISPOSTA DELLA FAQ
	$(".link_faq").click(function(){
		var hidden_id = parseInt($(this).parent('.moreinfo').attr('id').replace('h_', ''), 10); 
		
		var status = $(".full_box #risp_" + hidden_id).css('display');
		if (status=="none") {
			$(".full_box #risp_" + hidden_id).show(500);
		} else {
			$(".full_box #risp_" + hidden_id).hide(200);
		}
		
		return false;
	});

	
	/*  V I E W   A L L  */
	$('.view a').click(function(){
		$('#items-page .list-items-page #hidden').fadeIn(500);
		$('.view').fadeOut(100);
		$('.list-items-featured').fadeOut(100);
		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);
}
	

