var currentDate = new Date(2009, 10, 22, 12, 0, 0); // from http://www.quirksmode.org function takeYear(theDate) { x = theDate.getYear(); var y = x % 100; y += (y < 38) ? 2000 : 1900; return y; } function formatDate(date) { var day = date.getDate(); var month = date.getMonth() + 1; var year = takeYear(date); return year + '-' + month + '-' + day; } function calendar_select_date(year, month, day) { currentDate = new Date(year, (month-1), day, 12, 0, 0); var currentSelected = $$('.calendar .selectedday'); currentSelected.each(function(td) { $(td).removeClassName('selectedday'); }); var nights = $('num_nights').value; for (var i = 0; i < nights; i++) { var tempDate = new Date(takeYear(currentDate), currentDate.getMonth(), (currentDate.getDate() + i), 12, 0, 0); var cellId = 'date-' + formatDate(tempDate); var cell = $($(cellId)); if (cell) { cell.addClassName('selectedday'); } } return false; } function begin_late_search() { if($('sel_country').value == '0') { alert('Please select a country'); } else { var loc = '/late-availability/' + $('sel_country').value + '/' + takeYear(currentDate) + '-' + (currentDate.getMonth() + 1) + '-' + currentDate.getDate() + '?nights=' + $('num_nights').value + '&adults=' + $('num_adults').value; location.href = loc; } return false; }