$(document).ready(function(){

	var dates = $('#checkinHotel, #checkoutHotel').datepicker({
		dateFormat : "dd/mm/yy",
		changeMonth: false,
		minDate: 0,
		defaultDate: 0,
		numberOfMonths: 1,
		onSelect: function(selectedDate) {

			var option = this.id == "checkinHotel" ? "minDate" : "maxDate";
			var instance = $(this).data("datepicker");
			var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
		
			if(option == "minDate") date.setDate(date.getDate()+1);

			dates.not(this).datepicker("option", option, date);
			
			$('#checkinHotelDay').val($.datepicker.formatDate('dd', $("#checkinHotel").datepicker( "getDate" ) ));
			$('#checkinHotelYearMonth').val($.datepicker.formatDate('yy-mm', $("#checkinHotel").datepicker( "getDate" ) ));
			$('#checkoutHotelDay').val($.datepicker.formatDate('dd', $("#checkoutHotel").datepicker( "getDate" ) ));
			$('#checkoutHotelYearMonth').val($.datepicker.formatDate('yy-mm', $("#checkoutHotel").datepicker( "getDate" ) ));

		}
	});
	
	var today = new Date();
	var tomorrow = new Date(today.getFullYear(), today.getMonth(),today.getDate()+1);
	$('#checkinHotel').val( $.datepicker.formatDate('dd/mm/yy', today ) );
	$('#checkoutHotel').val( $.datepicker.formatDate('dd/mm/yy', tomorrow ) );
	$('#checkinHotelDay').val( $.datepicker.formatDate('dd', today ) );
	$('#checkinHotelYearMonth').val( $.datepicker.formatDate('yy-mm', today ) );
	$('#checkoutHotelDay').val( $.datepicker.formatDate('dd', tomorrow ) );
	$('#checkoutHotelYearMonth').val( $.datepicker.formatDate('yy-mm', tomorrow ) );
	
});
