/*	function change_tabs(id) {
		for (i=1;i<=3;i++) {
			var buton = 'Tab'+i;
			if (i == id) {
				$("#"+buton).attr('class','tabOn');
				$("#hotel_description"+i).attr('class', 'description_on');
			}
			else {
				$("#"+buton).attr('class','tabOff');
				$("#hotel_description"+i).attr('class', 'description_off');
			}
		}
	}
	*/
	
	
	$(function()
	{
		
		// initialise the "Select date" link
		$('#calendar2')
			.datePicker(
				// associate the link with a date picker
				{
					createButton: false,
					startDate:'01/01/2010',
					endDate:'31/12/2011'
				}
			).bind(
				// when the link is clicked display the date picker
				'click',
				function()
				{
					updateSelects($(this).dpGetSelected()[0]);
					$(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);
			$('#day option[value=' + selectedDate.getDate() + ']').attr('selected', 'selected');
			$('#month option[value=' + (selectedDate.getMonth()+1) + ']').attr('selected', 'selected');
			$('#year option[value=' + (selectedDate.getFullYear()) + ']').attr('selected', 'selected');
			$('#arrive').attr('value', (selectedDate.getMonth()+1) + '/' + selectedDate.getDate() + '/' + selectedDate.getFullYear());
		}
		// listen for when the selects are changed and update the picker
		$('#day, #month, #year')
			.bind(
				'change',
				function()
				{
					var d = new Date(
								$('#year').val(),
								$('#month').val()-1,
								$('#day').val()
							);
					$('#calendar2').dpSetSelected(d.asString());
					$('#arrive').attr('value', (d.getMonth()+1) + '/' + d.getDate() + '/' + d.getFullYear());
				}
			);
		
		// default the position of the selects to today
		var today = new Date();
		//updateSelects(today.getTime());
		
		// and update the datePicker to reflect it...
		$('#day').trigger('change');
	});
	
	
	
