<!--

// Handle Hotel Booking Date Ranges //

// you may use/modify this code, but please give credit as a courtesy
// script by Arash Ramin (http://www.digitalroom.net)
function setCheckInDate() {
  
  // changes the date selector menus to the current date
  var checkInDate = new Date();

  document.resrvForm.doa_yy.selectedIndex = 0;
  document.resrvForm.doa_mm.selectedIndex = checkInDate.getMonth();

  setCIDays();  
  document.resrvForm.doa_dd.selectedIndex = checkInDate.getDate() - 1;

}


function setCheckOutDate() {
  
  // changes the date selector menus to 2 days AFTER current date
  var checkOutDate = new Date();
  
  checkOutDate.setDate(checkOutDate.getDate() + 2);

  document.resrvForm.dod_yy.selectedIndex = 0;
  document.resrvForm.dod_mm.selectedIndex = checkOutDate.getMonth();

  setCODays();  
  document.resrvForm.dod_dd.selectedIndex = checkOutDate.getDate() - 1;

}

function setCIDays() {

  var y = document.resrvForm.doa_yy.options[document.resrvForm.doa_yy.selectedIndex].value;
  var m = document.resrvForm.doa_mm.selectedIndex;
  var d;

  // find number of days in current doa_mm
  if ( (m == 3) || (m == 5) || (m == 8) || (m == 10) ) {
    days = 30;
  }
  else if (m == 1) {
    // check for leapyear - Any doa_yy divisible by 4, except those divisible by 100 (but NOT 400)
    if ( (Math.floor(y/4) == (y/4)) && ((Math.floor(y/100) != (y/100)) || (Math.floor(y/400) == (y/400))) )
      days = 29
    else
      days = 28
  }
  else {
    days = 31;
  }


  // if (days in new doa_mm > current days) then we must add the extra days
  if (days > document.resrvForm.doa_dd.length) {
    for (i = document.resrvForm.doa_dd.length; i < days; i++) {
      document.resrvForm.doa_dd.length = days;
      document.resrvForm.doa_dd.options[i].text = i + 1;
      document.resrvForm.doa_dd.options[i].value = i + 1;
    }
  }

  
  // if (days in new doa_mm < current days) then we must delete the extra days
  if (days < document.resrvForm.doa_dd.length) {
    document.resrvForm.doa_dd.length = days;
    if (document.resrvForm.doa_dd.selectedIndex == -1) 
      document.resrvForm.doa_dd.selectedIndex = days - 1;
  }

}

function setCODays() {

  var y = document.resrvForm.dod_yy.options[document.resrvForm.dod_yy.selectedIndex].value;
  var m = document.resrvForm.dod_mm.selectedIndex;
  var d;

  // find number of days in current doa_mm
  if ( (m == 3) || (m == 5) || (m == 8) || (m == 10) ) {
    days = 30;
  }
  else if (m == 1) {
    // check for leapyear - Any doa_yy divisible by 4, except those divisible by 100 (but NOT 400)
    if ( (Math.floor(y/4) == (y/4)) && ((Math.floor(y/100) != (y/100)) || (Math.floor(y/400) == (y/400))) )
      days = 29
    else
      days = 28
  }
  else {
    days = 31;
  }


  // if (days in new doa_mm > current days) then we must add the extra days
  if (days > document.resrvForm.dod_dd.length) {
    for (i = document.resrvForm.dod_dd.length; i < days; i++) {
      document.resrvForm.dod_dd.length = days;
      document.resrvForm.dod_dd.options[i].text = i + 1;
      document.resrvForm.dod_dd.options[i].value = i + 1;
    }
  }

  
  // if (days in new doa_mm < current days) then we must delete the extra days
  if (days < document.resrvForm.dod_dd.length) {
    document.resrvForm.dod_dd.length = days;
    if (document.resrvForm.dod_dd.selectedIndex == -1) 
      document.resrvForm.dod_dd.selectedIndex = days - 1;
  }

}


///////////////////////////////////

//-->