$(document).ready(function(){
		start();
});
$(function(){
	$("#bf select").uniform();

	/* */
	$('#single_item a#btn_view_spa').click (function() {
		$('#single_item #list').show(100);
		return false;
	});
	
	
	/* MORE_INFO */
	/*all_hidden: per aprire items senza aver schiacciato view all*/
	$('.all_hidden #list a.more_info').click (function() {		
		var hidden_id = parseInt($(this).attr('id').replace('h_', ''), 10); 									 	
//		alert(hidden_id);
		
		$(this).closest(".all_hidden #list .item").addClass('height_ie6'); 
		//alert(parent_item);
		$('.all_hidden #list .info #body_' + hidden_id).show(100);
		$('.all_hidden #list .info #h_' + hidden_id).hide(100);
		$('.all_hidden #list .info #book_now_'+ hidden_id).removeClass('hidden');
		$('.all_hidden #list .info #close_'+ hidden_id).removeClass('hidden');
		return false;
	});
	
	/*featured: per aprire items una volta selezionato view all*/
	$('.featured #list a.more_info').click (function() {
		var hidden_id = parseInt($(this).attr('id').replace('h_', ''), 10); 									 	
//		alert(hidden_id);
		
		$(this).closest(".featured #list .item").addClass('height_ie6'); 
		//alert(parent_item);
		$('.featured #list .info #body_' + hidden_id).show(100);
		$('.featured #list .info #h_' + hidden_id).hide(100);
		$('.featured #list .info #book_now_'+ hidden_id).removeClass('hidden');
		$('.featured #list .info #close_'+ hidden_id).removeClass('hidden');
		return false;
	});
	
	
	
	$('.all_hidden #list .close a').click (function() {
		//alert("qui");
		var hidd_id = parseInt($(this).parent('.close').attr('id').replace('close_', ''), 10); 									 	
		//alert(hidd_id);
		$('.all_hidden #list .info #body_' + hidd_id).fadeOut(100);
		$('.all_hidden #list .info #h_' + hidd_id).show(100);
		$('.all_hidden #list .info #book_now_'+ hidd_id).addClass('hidden');
		$('.all_hidden #list .info #close_'+ hidd_id).addClass('hidden');
		return false;
	});
	
	$('.featured #list .close a').click (function() {
		//alert("qui");
		var hidd_id = parseInt($(this).parent('.close').attr('id').replace('close_', ''), 10); 									 	
		//alert(hidd_id);
		$('.featured #list .info #body_' + hidd_id).fadeOut(100);
		$('.featured #list .info #h_' + hidd_id).show(100);
		$('.featured #list .info #book_now_'+ hidd_id).addClass('hidden');
		$('.featured #list .info #close_'+ hidd_id).addClass('hidden');
		return false;
	});
	
	
	
	
	
	/* VIEW ALL PRESS KIT */
	$('#view_ist').click (function() {
		$('.hidden-box-ist').fadeIn(500);
		$('#view_ist').css("display","none");
		$('#close_ist').css("display","block");
		return false;
	});
	$('#close_ist').click (function() {
		$('.hidden-box-ist').fadeOut(500);
		$('#view_ist').css("display","block");
		$('#close_ist').css("display","none");
		return false;
	});
	
	$('#view_par').click (function() {
		$('.hidden-box-par').fadeIn(500);
		$('#view_par').css("display","none");
		$('#close_par').css("display","block");
		return false;
	});
	$('#close_par').click (function() {
		$('.hidden-box-par').fadeOut(500);
		$('#view_par').css("display","block");
		$('#close_par').css("display","none");
		return false;
	});
	
});


function check_form_work() {
	$("#txtname").css('border','1px solid #999');
	$("#txtsurname").css('border','1px solid #999');
	$("#txtphone").css('border','1px solid #999');
	$("#txtemail").css('border','1px solid #999');
	
	var txtname = document.work_form.txtname.value;
	var txtsurname = document.work_form.txtsurname.value;
	var txtphone = document.work_form.txtphone.value;
	var txtemail = document.work_form.txtemail.value;
	var varcheck = "true";
	
	if (txtname=="") {
		$("#txtname").css('border','1px solid red');
		var varcheck = "false";
	}
	if (txtsurname=="") {
		$("#txtsurname").css('border','1px solid red');
		var varcheck = "false";
	}
	
	if (txtphone=="") {
		$("#txtphone").css('border','1px solid red');	
		var varcheck = "false";
	}
	
	if (txtemail=="") {
		$("#txtemail").css('border','1px solid red');	
		var varcheck = "false";
	}
	
	/* INVIO */
	if (varcheck=="true") {
		//alert("invio email effettuato correttamente!");
		return true;
	} else {
		return false;
	}
}



/*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]);
			}
		);
		
	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() {
	$(document).pngFix(); 
});




	// NASCONDO TUUTE LE RISPOSTE DELLE FAQ
	$(".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); 
		$(".full_box #risp_" + hidden_id).show(500);
		
		
		
		// nascodo tutte le risposte aperte
		//console.log("qui");
		/*
		$(".faq_box .answer").each(function() {	
			$(this).hide(1000);
		});
		*/		
		
		return false;
	});





// BOOK NOW LINK
$("[class*='cat-id-19']").attr('href', 'javascript:;');
$("[class*='cat-id-19']").click(function(){
	hhotelSearch('ITCORCristallo', '', '', '', '', '', '');
	return false;
});


// GESTIONE DEGLI ITEM DELLE LIST PAGE
$(document).ready(function() {
	$('#listpage_col_dx .list_box').each(function() {
		var linked_page;
		 $(this).find('.titolo').children('a').click(function() {
			linked_page = $(this).attr('href') + ' #offer_content';
			$('#listpage_col_dx .list_box').find('.sfondo_item_preview').removeClass('selected');			
			$(this).parents('.sfondo_item_preview').addClass('selected');
			$('#offer_content').fadeOut(300, function() {				
				$('#offer_content').load(linked_page, function() {					
					$('#offer_content').fadeIn(300);
				});
			});
			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;
	});
	
});


$(function() {
		   
	$('#hidden_box').click (function() {
		//alert("qui");
		$('#content #offer_content .txt .btn_more').css("display","none");
/*		$('#content #offer_content .txt .body').css("display","block");*/
		$('#content #offer_content .txt .body').show(200);
		return false;
	});
		   
	//start();
	
	
	// VISUALIZZO LA RISPOSTA DELLA FAQ
	$("#faq .story .full_box .moreinfo a").click(function(){
		
		var hidden_id = parseInt($(this).parent('.moreinfo').attr('id').replace('h_', ''), 10); 
		
		$("#faq .story .full_box .moreinfo").each(function() {
			$('.faq_body').hide(800);
			$('#faq .story .full_box .moreinfo a').removeClass('current');
		});
		
		$(this).addClass('current');
		
		$('#risp_'+hidden_id).show(500);
		return false;
	});
	
	
	
	/* POP-UP METEO */
	$('#meteo').click(function() {
		$('#meteo_hidden').fadeIn(500);
		return false;
	});
	$('#meteo_hidden #close').click(function() {
		$('#meteo_hidden').fadeOut(200);
		return false;
	});
	
	
	$('#view_seedling').click(function() {
		//$('#meteo_hidden').fadeIn(500);
		alert("qui");
		return false;
	});
	
	
	
	// PHOTOGALLERY SOTTOMENU
	$('ul.level_0 a.cat_54').click(function() {
		var box_hidden = $('ul.level_1').css("display");
		//alert("qui");
		if (box_hidden=="none") {
			$('ul.level_1').show(400);
		} else {
			$('ul.level_1').hide(400);
			return false;
		}
		
	});
	
});