jQuery(document).ready(function($) {
	var nav = $('.navigation');
	var form = $('.navigation .reservations_box');
	nav.find('> li:not(:first)').append($('<div class="light"></div>')).fadeOut(0);
	
	nav.find('> li:not(:first)').each(function(i) {
		fadeIn($(this), i);	
	});
	
	nav.find('li:not(:first) div').each(function(i) {
		fadeOut($(this), i);
	});
	
	nav.find('> li:not(:first)').mouseenter(function() {
		$(this).find('img').fadeIn(100);
		$(this).find('ul').slideDown(200);
	}).mouseleave(function() {
		$(this).find('img').fadeOut(100);
		$(this).find('ul').slideUp(200);
	});
	
	nav.find('> li:first > a').click(function(e) {
		if (form.is(':visible')) {
			$(this).removeClass('open');
			form.slideUp(200);
		} else {
			$(this).addClass('open');					
			form.slideDown(200);
		}
		return false;
	});
	
	function fadeIn(target, delay) {
		setTimeout(function() {
			target.fadeIn(400);
		}, delay * 300);				
	}
	
	function fadeOut(target, delay) {
		setTimeout(function() {
			target.show();
			target.fadeOut(800, function() {
				$(this).remove();	
			});
		}, delay * 300);
	}
	
	var c = 30;
	var option;
	for (var i=1; i<c; i++) {
		option = $('<option></option>').attr('value', i).html(i);
		$('#nights').append(option);
	}
			
	$('.submit_reservation').click(function() {
		submitForm(Date.abbrMonthNames[$('#m').val()-1] + ',' + $('#d').val() + ',' + $('#y').val() + ',' + $('#nights').val() + ',' + $('#adults').val() + ',' + $('#children').val());	
	});	
});  	
		
		
		
		
jQuery(document).ready(function($) {
var range_start = new Date();
var range_end = (new Date()).addYears(1);
// initialise the "Select date" link
$('#select_date')
	.datePicker(
		// associate the link with a date picker
		{
			createButton: false,
			startDate: range_start.asString(),
			endDate: range_end.asString()
		}
	).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);
	$('#d option[value=' + selectedDate.getDate() + ']').attr('selected', 'selected');
	$('#m option[value=' + (selectedDate.getMonth()+1) + ']').attr('selected', 'selected');
	$('#y option[value=' + (selectedDate.getFullYear()) + ']').attr('selected', 'selected');
}
// listen for when the selects are changed and update the picker
$('#d, #m, #y').bind(
		'change',
		function() {
			var d = new Date(
						$('#y').val(),
						$('#m').val()-1,
						$('#d').val()
					);
			$('#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...
$('#d').trigger('change');
});		
