// initialize array for use with multiple selections
// leave this value empty, it's only used for keeping track of active selections
var MA = [];

var today = new Date();

// calculate the date in seven days
var todayPlusSeven = new Date();
todayPlusSeven.setDate(todayPlusSeven.getDate() + 7);

// calculate the date in the future amount of months
var monthsFuture = new Date();
monthsFuture.setDate(monthsFuture.getDate() + (30 * monthsAhead));

function ourDateStatusFunc(date, y, m, d) {

  // disable past dates
  if (date < today) {
    return true;
  }
  
  // disable if in the next 7 days
  if (date < todayPlusSeven) {
    return true;
  }
  
  // disable if more than a certain months in the future
  if (date > monthsFuture) {
    return true;
  }

}

function updateDateList(cal) {

  // here we'll write the output; this is only for example.  You
  // will normally fill an input field or something with the dates.
  var el = document.getElementById("date-list");
  var note = document.getElementById("date-note");
  // var wrap = document.getElementById("date-wrap");
  var input = document.getElementById("ReservationReservationDates");  // LBW added 01/16/09 to add selected dates to the hidden input
  var input_string = document.getElementById("ReservationReservationDatesString");  // LBW added 01/16/09 to add selected dates to the hidden input

  // show selected dates area
  // wrap.setAttribute("style", "display: block;");
  note.setAttribute("style", "display: none;");

  // reset initial content.
  el.innerHTML = "";
  input.value = "";  // LBW added 01/16/09 to add selected dates to the hidden input
  input_string.value = "";  // LBW added 01/16/09 to add selected dates to the hidden input

  // Reset the "MA", in case one triggers the calendar again.
  // CAREFUL!  You don't want to do "MA = [];".  We need to modify
  // the value of the current array, instead of creating a new one.
  // Calendar.setup is called only once! :-)  So be careful.
  MA.length = 0;

  // walk the calendar's multiple dates selection hash
  for (var i in cal.multiple) {
    var d = cal.multiple[i];
    // sometimes the date is not actually selected, that's why we need to check.
    if (d) {
      // OK, selected.  Fill an input field.  Or something.  Just for example,
      // we will display all selected dates in the element having the id "output".
      el.innerHTML += '<li>' + d.print("%A, %B %d, %Y") + '</li>';
      input.value += d.print("%Y-%m-%d") + ","; // LBW added 01/16/09 to add selected dates to the hidden input
      input_string.value += d.print("%A, %B %d, %Y") + ";"; // LBW added 01/16/09 to add selected dates to the hidden input

      // and push it in the "MA", in case one triggers the calendar again.
      MA[MA.length] = d;
    }
  }
  return true;
}