function selectBookingDates(){

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

   document.forms.bookOnline.dayOfMonth.selectedIndex = currentDayOfMonth;
   document.forms.bookOnline.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' name='yearMonth'>";
  
   //ensure current month is selected
      if(currentMonth <= 9)
         monthWithZero = "0"; 
      else 
         monthWithZero = "";   
   outputCode += "<option selected='selected' value='" + currentYear + '-' + monthWithZero + currentMonth + "'>" + 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.bookOnline.yearMonth.value;
   var arrivalDay = this.document.forms.bookOnline.dayOfMonth.value;
   
   var currentDate = new Date();
   var currentMonth = currentDate.getMonth();

   location.href = 'https://www.aro.ie/aroreservebookings/sites/BallinKeeleHotel/Default.aspx?' + 'yearmonth=' + arrivalYM + '&day=' + arrivalDay;
}