$(document).ready(function() {
	/*Rotation image*/						   	
	$('#image1').rotate({angle:3});	
	$('.container').show();
	/*Loading della foto in alto mentre carica la pagina*/
	$('#flash').removeClass('hidden');
	$('#flash').addClass('show');
	$('#loading').removeClass('show');
	$('#loading').addClass('hidden');
	/*Nascondo tutti i dettagli degli eventi, in modo che non si vedano quando carica la pagina*/
	$('.event_detail').addClass('show');

});

/*Function per arrotondare select della booking form*/
$(function(){
	$("#idForm select").uniform();
	$("#formNews select").uniform();
});

/*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,
				verticalPosition	: $.dpConst.POS_TOP,
				horizontalPosition	: $.dpConst.POS_RIGHT,
				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');
		
		$('.fromday span').text(selectedDate.getDate());
		switch (selectedDate.getMonth()+1) {
			case 1 : var month = "Jan"; break;	
			case 2 : var month = "Feb"; break;	
			case 3 : var month = "Mar"; break;	
			case 4 : var month = "Apr"; break;	
			case 5 : var month = "May"; break;	
			case 6 : var month = "Jun"; break;	
			case 7 : var month = "Jul"; break;	
			case 8 : var month = "Aug"; break;	
			case 9 : var month = "Sept"; break;	
			case 10 : var month = "Oct"; break;	
			case 11 : var month = "Nov"; break;	
			case 12 : var month = "Dec"; break;	
		}
		$('.frommonth span').text(month);
    	$('.fromyear span').text(selectedDate.getFullYear());
		
	}
	// 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() {
	$(document).pngFix(); 
});

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

// BOOK NOW LINK Main menu
$("[class*='cat_17']").attr('href', 'javascript:;');
$("[class*='cat_17']").click(function(){
	hhotelSearch('CAMONHTLCelebrities', '', '', '', '', '', '');
	return false;
});


// PRIVACY DELLA SITEMAP
$("[class*='cat-id-13']").attr('href', 'javascript:;');
$("[class*='cat-id-13']").click(function(){
	window.open("/themes/hotel_lovely_celebrities/static/privacy.html","popup","scrollbars=no,width=724,height=453,top=50,left=23").focus
	return false;
});


// NASCONDO TUTTE LE RISPOSTE DELLE FAQ E GLI EVENTI IN HOMEPAGE
$(".story .full_box .body").each(function() {
	$(this).css("display","none");	
});

// VISUALIZZO LA RISPOSTA DELLA FAQ E L'EVENTO IN HOMEPAGE
$(".story .full_box .title a").click(function(){
	var hidden_id = parseInt($(this).parent('.title').attr('id').replace('h_', ''), 10);
	// nascodo tutte le risposte aperte
	$(".story .full_box .body").each(function() {	
		$(this).hide(1000);	
		//console.log(hidden_id);
		$(".full_box .title").removeClass("link_open");
		$(".full_box .title").addClass("link_close");
	});	
	
	$(".story .full_box #risp_" + hidden_id).show(1000);	
	$(".full_box #h_" + hidden_id).removeClass("link_close");
	$(".full_box #h_" + hidden_id).addClass("link_open");
	/*$(".story .full_box #freccia_" + hidden_id).hide(1000);*/	
	return false;	
});


// NASCONDO TUTTI GLI EVENTI
$(".event_detail").each(function() {
	$(this).css("display","none");	
});

// VISUALIZZO L'EVENTO SELEZIONATO
$(".evento_preview .titolo a").click(function(){
	var hidden_id = parseInt($(this).parent('.titolo').attr('id').replace('h_', ''), 10);
	// nascodo tutte le risposte aperte
	$(".event_detail").each(function() {	
		$(this).hide(1000);	
	});
	
	$("#body_" + hidden_id).show(1000);		
	return false;	
});


$(function() {

	start(); 
});