function toggleCalendarVisibility() {
  var reservationCalendarContainer = document.getElementById('reservationCalendarContainer');
  if (reservationCalendarContainer.style.display == 'none') {
    reservationCalendarContainer.style.display = 'block';
  }
  else {
    reservationCalendarContainer.style.display = 'none';
  }
}
function setSelect(id, value) {
  var select = document.getElementById(id);
  for (i = 0; i < select.options.length; ++i) {
    if (select.options[i].value == value) {
      select.options[i].selected = true;
      return;
    }
  }
  alert('failed to set ' + id + " to " + value);
}
function dateClicked(year, month, day) {
  toggleCalendarVisibility();
  setSelect('reservationDay', day);
  setSelect('reservationMonth', month);
  setSelect('reservationYear', year);
}
function showOtherMonth(year, month) {
  var cal = document.getElementById('reservationCalendarContainer');
  YAHOO.util.Connect.asyncRequest('GET', 'ajaxPublicCalendar.php?year=' + year + '&month=' + month, {
    success: function(o) {
      cal.innerHTML = o.responseText;
    },
    failure: function(o) {
      cal.innerHTML = "Failed to retrieve calendar for " + month + "/" + year;
    }
  });
}

