function selectBookingDates(){

   var currentDate = new Date();
   var currentDayOfMonth = currentDate.getDate() - 1;
   var currentMonth = currentDate.getMonth();

   document.forms.checkincheckout_ym.day.selectedIndex = currentDayOfMonth;
   //document.forms.checkincheckout_ym.yearmonth.selectedIndex = 0;
}

function writeBookOnlineMonthSelect(){
    
   var currentDate = new Date();
   var currentMonth = currentDate.getMonth();
   var currentYear = currentDate.getFullYear(); 
   
   var nextYear = currentYear + 1;

   var monthsOfYr = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];

   var outputCode = "";
   
   var monthWithZero = ""; 
   
   //first line - open select
   outputCode += "<select class='browntext' id='yearmonth'>";
  
   //ensure current month is selected
      if((currentMonth + 1) <= 9)
         monthWithZero = "0"; 
      else 
         monthWithZero = "";   
   outputCode += "<option selected='selected' value='" + currentYear + "-" + monthWithZero + (currentMonth + 1) + "'>" + currentYear + "-" + monthsOfYr[currentMonth] + "</option>";
   
   //write remaining months of current year   
   for(var i = currentMonth + 1; i<=11; i++){
      if(i <= 9)
         monthWithZero = "0";   
      else 
         monthWithZero = "";  
      outputCode += "<option value=" + currentYear + "-" + monthWithZero + "" + (i + 1) + ">" + currentYear + "-" + (monthsOfYr[i]) + "</option>";
   } 
   
   //write months of next year, ensuring that 12 consecutive months are always written
   for(var j = 0; j<=((currentMonth + 10) - 11); j++){ 
      if(j <= 9)
         monthWithZero = "0";
      else 
         monthWithZero = ""; 
      outputCode += "<option value=" + nextYear + "-" + monthWithZero + "" + (j + 1) + ">" + nextYear + "-" + (monthsOfYr[j]) + "</option>";
   }  
   
   outputCode += "</select>";
   
   document.write(outputCode);
}

function goToBE(){

   var arrivalYM = this.document.forms.checkincheckout_ym.yearmonth.value;
   var arrivalDay = this.document.forms.checkincheckout_ym.day.value;
   
   var currentDate = new Date();
   var currentMonth = currentDate.getMonth();
   
   //var activeYear = currentDate.getFullYear();

    location.href='https://www.aro.ie/aroreserve/sites/InchydoneyIsland?' + 'yearmonth=' + arrivalYM + '&day=' + arrivalDay;
}