/*Function per arrotondare select della booking form*/


$(function(){
	$("#idForm select").uniform();
	$("#formNews select").uniform();
});


$(document).ready(function() {
      jQuery('#logo a img').ifixpng();
	  jQuery('#ombra_flash').ifixpng();
	  jQuery('#ombra_footer').ifixpng();
	  jQuery('div.cornice_logo').ifixpng();
	  jQuery('#minigallery .gallery .image').ifixpng();
	  jQuery('.thumb').ifixpng();
	  jQuery('#photogallery .gallery .image').ifixpng();
		
		$('ul#menu_box').superfish();
		var submenu = $('ul#menu_box li ul');
		var position = submenu.height()+17;
		submenu.css('top','-'+(position)+'px');
		
	jQuery('#flash_home').cycle();	
    });



	/*Gestione calendario nella booking*/
	$(function() {
	jQuery(function(){	
		// initialise the "Select date" link
		var tdy = new Date();
		//$("#debug .line1").html("tdy.asString="+tdy.asString());
		var enddate= new Date(tdy.gettime+63000000);
		jQuery('.date-pick')
			.datePicker(
	
				//associate the link with a date picker
				{
					createButton:false,
					startDate:tdy.asString(),
					endDate:enddate.asString()
				}
			).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())+ ']').attr('selected', 'selected');
			jQuery('#y option[value=' + (selectedDate.getFullYear()) + ']').attr('selected', 'selected');
			
			/*
			$("#debug .line2").html("#d = "+jQuery('#d option[value=' + (selectedDate.getDate()) + ']').val()+" = "+jQuery('#d option[value=' + (selectedDate.getDate()) + ']').attr('selected'));
			$("#debug .line3").html("#m = "+jQuery('#m option[value=' + (selectedDate.getMonth()) + ']').val()+" = "+jQuery('#m option[value=' + (selectedDate.getMonth()) + ']').attr('selected'));
			$("#debug .line4").html("#y = "+jQuery('#y option[value=' + (selectedDate.getFullYear()) + ']').val()+" = "+jQuery('#y option[value=' + (selectedDate.getFullYear()) + ']').attr('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();
});

/*
// BOOK NOW LINK
$(function() {
	$("a[class*='cat_31']").click(function(){
		hhotelSearchGroup('Bollina', '', '', '', '');
		return false;
	});
}); */
