$(function() {
  initDatepickerRange();
  initAvailabilityCalendar();
  $('[data-toggle="tooltip"]').tooltip({
    placement: 'bottom'
  });
});


function initDatepickerRange() {
  // Doku: https://uxsolutions.github.io/bootstrap-datepicker/
  
  $('input[data-type="date"]').datepicker({
    format: "dd.mm.yyyy",
    language: "de",
    daysOfWeekHighlighted: "0,6",
    todayHighlight: true,
    orientation: "top auto"
  });
}

function initAvailabilityCalendar() {  
  $('.calendar').each(function() {
    var $cal = $(this);
    var unavailableDates = JSON.parse($cal.parent().find('input:first').val());

    $cal.availabilityCalendar(unavailableDates);
  });
}