[Datepicker] beforeShowDay with many function

[Datepicker] beforeShowDay with many function

Hi all.

First, sorry for my english, i'm french.

I'm new with jquery and I use datepicker to show a calendar.

I use this code (below) to diable some day. but there is 2 kind of day (reserved an blocked) so i'have got 2 array with the date et 2 function to display this day with a different css class.

  1. var closedDays = [];
    closedDays[0] = "2010-8-4";
    closedDays[1] = "2010-8-5";
    closedDays[2] = "2010-8-6";
               
    var bookedDays = [];
    bookedDays[0] = "2010-8-16";
    bookedDays[1] = "2010-8-17";
    bookedDays[2] = "2010-8-18";          










  2. function assignCalendar(id) {
                    $('<div class="calendar" />')
                    .insertAfter( $(id) )
                    .datepicker({
                    dateFormat: 'YYYY-mm-dd',
                    minDate: new Date(),
                    maxDate: '+1y',
                    altField: id,
                    beforeShowDay: isBlocked})
                    .prev().hide();
    }
               











  3. function isBlocked(date) {
    var dateAsString = date.getFullYear().toString() + "-" + (date.getMonth()+1).toString() + "-" + date.getDate();
    var result = $.inArray( dateAsString, closedDays ) ==-1 ? [true] : [false, 'blocked'];
    return result
    }






  4. function isReserved(date){
    var dateAsString = date.getFullYear().toString() + "-" + (date.getMonth()+1).toString() + "-" + date.getDate();
    var result = $.inArray( dateAsString, bookedDays ) ==-1 ? [true] : [false, 'reserved'];
    return result
    }



It works fin when i put one or the other method in the "beforeShowDay: isBlocked". but I want to put 2 both method in the "beforeShowDay" option. Then it will show me all dates of my 2 array with the 2 different classes (reserved and blocked).

I don't know how to do this? If someone could help me it will be very kind.

Thanks a lot