﻿$().ready(function () {
    //pickup drop off calendar date picker settings
    $('.frmcalcheckin, .frmcalcheckout').datepicker({
        numberOfMonths: 2,
        showButtonPanel: true,
        beforeShow: customRange,
        dateFormat: 'dd/mm/yy',
       /* showOn: 'both',*/
       /* buttonImage: 'images/calendar-icon.gif',*/
        buttonImageOnly: false
        /*buttonText: 'Show Date Picker'*/
       
    });

    //set the drop off date to be one day ahead of the pickup date
    $('.frmcalcheckin').change(function () {
        var nextDayDate = $('.frmcalcheckin').datepicker('getDate', '+1d');
        nextDayDate.setDate(nextDayDate.getDate() + 1);
        $('.frmcalcheckout').datepicker('setDate', nextDayDate);
    });

});





//ensure that the drop off date cannot be before the pickup date
function customRange(a) {
    var b = new Date();
    var c = new Date(b.getFullYear(), b.getMonth(), b.getDate());
    if (a.id == 'DropoffDate') {
        if ($('.frmcalcheckin').datepicker('getDate') != null) {
            c = $('.frmcalcheckin').datepicker('getDate');
        }
    }
    return {
        minDate: c
    }
}


//$().ready(function () {
//    //pickup drop off calendar date picker settings
//    $('.fillboxcheckin, .fillboxcheckout').datepicker({
//        numberOfMonths: 2,
//        showButtonPanel: true,
//        beforeShow: customRange1,
//        dateFormat: 'dd/mm/yy',
//       /* showOn: 'both',*/
//       /* buttonImage: 'images/calendar-icon.gif',*/
//        buttonImageOnly: false
//        /*buttonText: 'Show Date Picker'*/
//       
//    });

//    //set the drop off date to be one day ahead of the pickup date
//    $('.fillboxcheckin').change(function () {
//        var nextDayDate = $('.fillboxcheckin').datepicker('getDate', '+1d');
//        nextDayDate.setDate(nextDayDate.getDate() + 1);
//        $('.fillboxcheckout').datepicker('setDate', nextDayDate);
//    });

//});

////ensure that the drop off date cannot be before the pickup date
//function customRange1(a) {
//    var b = new Date();
//    var c = new Date(b.getFullYear(), b.getMonth(), b.getDate());
//    if (a.id == 'DropoffDate') {
//        if ($('.fillboxcheckin').datepicker('getDate') != null) {
//            c = $('.fillboxcheckin').datepicker('getDate');
//        }
//    }
//    return {
//        minDate: c
//    }
//}
