$(function(){

    // Datepicker
    $('#datepicker').datepicker({
        inline: true,
        dateFormat: 'yy/mm/dd',
        beforeShowDay: function(day){

            for(d in eventDates) {

                //only enable dates with events on them
                if (day.getTime() == new Date(eventDates[d]).getTime()) {

                    //highlight this date with a class
                    return [true,'yepclan-event', 'Events available.'];
                }
            }

            //no events here
            return [true];
        },
        onSelect: function(dateText, inst) {

            //redirect to the events page with the selected date
            window.location.href = '/events/' + dateText.split('/').join('-');
        }
    });

});
