DatePicker Default Date

DatePicker Default Date

Hi all

I have two datepicker objects on my page to represent arrival and departure dates.  The Arrival Date picker is set to be a default date which comes from the database (its a dynamic event date that changes depending on which event we are looking at).

Everything works fine however I have discovered that if the event date lands on the 1st of the month, the user cannot select a previous date.  How can I get round this issue as I believe I have to use MINDATE parameter in order to set the default month to be the event date.

Here is my code and any help is greatly appreciated:

  1.    var SelectedDates = {};
    SelectedDates[new Date('<?php echo $dates[1]; ?>/<?php echo $dates[2]; ?>/<?php echo $dates[0]; ?>')] = new Date('<?php echo $dates[1]; ?>/<?php echo $dates[2]; ?>/<?php echo $dates[0]; ?>');

    var SeletedText = {};
    SeletedText[new Date('<?php echo $dates[1]; ?>/<?php echo $dates[2]; ?>/<?php echo $dates[0]; ?>')] = '<?php echo addslashes($_SESSION['W_EVENT_TITLE']); ?> Event Date';

    var dates = $('#datepicker1, #datepicker2').datepicker({
        minDate: new Date(<?php echo $dates[0]; ?>, <?php echo $dates[1]; ?> - 1, 1),
        buttonImageOnly: true,
        buttonImage: "/images/icons/calendar.gif",                   
        showOn: "both",
        duration: "slow",
        onSelect: function(selectedDate) {
            var option = == "datepicker1" ? "minDate" : "maxDate";
            var instance = $(this).data("datepicker");
            var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
            dates.not(this).datepicker("option", option, date);
        beforeShowDay: function(newdate) {
            var Highlight = SelectedDates[newdate];
            var HighlighText = SeletedText[newdate];
            if (Highlight) {
                return [true, "Highlighted", HighlighText];
            else {
                return [true, '', ''];