$().ready(function(){
    for (x = 0; x <= 5; x++) {
    
        $('.arrdate' + x + ' , .carreturn, .depdate' + x).datepicker({
            numberOfMonths: 1,
            showButtonPanel: false,
            beforeShow: customRange,
            dateFormat: 'dd-mm-yy',
            //showOn: 'both',
            buttonImage: 'http://www.hotels24seven.com/images/calendar-icon.gif',
            buttonImageOnly: false,
            buttonText: 'Show Date Pickers'
        });
        
    }
    
});
function customRange(a){

    var b = new Date();
    var c = new Date(b.getFullYear(), b.getMonth(), b.getDate());
    var getsubstring = a.id.substring(10);
    var changeinfo = 'departdate' + getsubstring;
    if (a.id == changeinfo) {
        if ($('.arrdate' + getsubstring).datepicker('getDate') != null) {
            c = $('.arrdate' + getsubstring).datepicker('getDate');
            c = new Date(c.getFullYear(), c.getMonth(), c.getDate() + 1);
        }
    }
    return {
        minDate: c
    }
}


