  $(document).ready(function(){
    $("#flags li:visible").addClass('selectedFlag');
                $("#flags ul").click(function () {
                  $("#flags li").toggle();
    });
  });
  $(function() {
                $("#ArrivingField").datepicker();
                $("#calendarIcon div").click(function () {
                  $("#ArrivingField").focus();
    });
});
function closeCal() {
                document.getElementById('ui-datepicker-div').style.display = "none";
}

  
 
  function checkGroup(menu) {
    if(menu.options[menu.selectedIndex].value == 'GROUP') {
      menu.form.submit();
    }
  }
  
  function checkGroupSize(menu) {
    if(menu.options[menu.selectedIndex].value == 'NOGROUP') {
      menu.form.submit();
    }
  }


function checkFAB() {
   var now = new Date();
   todaydate = ( now.getDate() < 10 )?'0' + now.getDate():now.getDate();
   todaymonth = ( now.getMonth()+1 < 10 )?'0' + (now.getMonth()+1):(now.getMonth()+1);
   chosendate = document.theForm.StartSelDay.value; //document.theForm.StartSelDay.options[document.theForm.StartSelDay.selectedIndex].value;
   chosendate = (chosendate.length < 2)?'0' + chosendate:chosendate;
   chosenmonth = document.theForm.StartSelMonth.value; //document.theForm.StartSelMonth.options[document.theForm.StartSelMonth.selectedIndex].value;
   chosenmonth = (chosenmonth.length < 2)?'0' + chosenmonth:chosenmonth;
   chosenDate = document.theForm.StartSelYear.value + '' + chosenmonth + '' + '' + chosendate;
   today = now.getFullYear() + '' + todaymonth + '' + '' + todaydate;
   if ( chosenDate < today ) {
      //alert("!!DATESINPAST!!");
      alert("Please enter dates ahead of today's date. Thank you.");
      return false;
   } else {
      return true;
   }
}

  function OpenWindow( url, width, height ) {
  SmallWin = window.open(url,'HostelPicture','scrollbars,resizable,height='+height+',width='+width);
  if (window.focus) {
    SmallWin.focus();
  }
  if (SmallWin.opener == null) {
    SmallWin.opener = window;
  }
}

function unCheckAll(hostel, campsite, guesthouse, hotel, apartment) {
  if ( document.theForm.ShowAll.checked == false) {
    if ( hostel > 0 ) { document.theForm.SelPropTypes_HOSTEL.checked = false; }
    if ( hotel > 0 ) { document.theForm.SelPropTypes_HOTEL.checked = false; }
    if ( guesthouse > 0 ) { document.theForm.SelPropTypes_GUESTHOUSE.checked = false; }
    if ( apartment > 0 ) { document.theForm.SelPropTypes_APARTMENT.checked = false; }
    if ( campsite > 0 ) { document.theForm.SelPropTypes_CAMPSITE.checked = false; }
  }
}
 function checkAll(hostel, campsite, guesthouse, hotel, apartment) {
  if ( document.theForm.ShowAll.checked ) {
    if ( hostel > 0 ) { document.theForm.SelPropTypes_HOSTEL.checked = true; }
    if ( hotel > 0 ) { document.theForm.SelPropTypes_HOTEL.checked = true; }
    if ( guesthouse > 0 ) { document.theForm.SelPropTypes_GUESTHOUSE.checked = true; }
    if ( apartment > 0 ) { document.theForm.SelPropTypes_APARTMENT.checked = true; }
    if ( campsite > 0 ) { document.theForm.SelPropTypes_CAMPSITE.checked = true; }
  } else {
    unCheckAll(hostel, campsite, guesthouse, hotel, apartment);
  }
 }
 function showAllTypes(hostel, campsite, guesthouse, hotel, apartment) {
   document.theForm.ShowAll.checked=true;
   checkAll(hostel, campsite, guesthouse, hotel, apartment);
   document.theForm.submit();
 }

function checkFABLeft() {
  var SWord = document.theForm.SearchWord.value; 
  if (SWord.length==0 || SWord == null) { 
    alert("Please enter your destination in the search box");
    return false;
  }
  var now = new Date();
  var todaydate = ( now.getDate() < 10 )?'0' + now.getDate():now.getDate();
  var todaymonth = ( now.getMonth()+1 < 10 )?'0' + (now.getMonth()+1):(now.getMonth()+1);
  var dateElement = document.getElementById("StartSelDay");
  var chosendate = document.theForm.StartSelDay.value; //dateElement.options[dateElement.selectedIndex].value;
  var chosendate = (chosendate.length < 2)?'0' + chosendate:chosendate;
  var monthElement = document.getElementById("StartSelMonth");
  var chosenmonth = document.theForm.StartSelMonth.value; //monthElement.options[monthElement.selectedIndex].value;
  var chosenmonth = (chosenmonth.length < 2)?'0' + chosenmonth:chosenmonth;
  var yearElement = document.getElementById("StartSelYear");
  var chosenDate = document.theForm.StartSelYear.value + '' + chosenmonth + '' + '' + chosendate;
  var today = now.getFullYear() + '' + todaymonth + '' + '' + todaydate;
  if ( chosenDate < today ) {
     alert("Please enter dates ahead of today's date.  Thank you.");
     return false;
  } else {
      return true;
  }
}


