//jQuery(document).ready(function () { })
$jdp = jQuery.noConflict();

function pageLoad() {
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_endRequest(function() {
        // This Function Will Called When Page Is Refreshed
        $jdp('#txtStartDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            maxDate: '0',
            hideIfNoPrevNext: true/*,
            onSelect: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
                $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
            }*/
        });
        $jdp('#txtEndDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            maxDate: '0',
            //            minDate: new Date($jdp('input[id$=txtStartDate]').datepicker('getDate')),
            hideIfNoPrevNext: true,
            beforeShow: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
                $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
            }
        });
        $jdp('#txtWrntyStrtdt').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            maxDate: '0',
            hideIfNoPrevNext: true/*,
            onSelect: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
                $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
            }*/
        });
        $jdp('#txtWrntyEndDt').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
           
            //            minDate: new Date($jdp('input[id$=txtStartDate]').datepicker('getDate')),
            hideIfNoPrevNext: true,
            beforeShow: function (dateText, inst) {
                var the_date = $jdp('input[id$=txtWrntyStrtdt]').datepicker('getDate');
                $jdp("input[id$=txtWrntyEndDt]").datepicker('option', 'minDate', the_date);
            }
        });
        $jdp('#txtDashStartDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            maxDate: '0',
            hideIfNoPrevNext: true/*,
            onSelect: function(dateText, inst) {
                var the_date = $('input[id$=txtStartDate]').datepicker('getDate');
                $("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
            }*/
        });
        $jdp('#txtDashEndDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            maxDate: '0',
            //            minDate: new Date($('input[id$=txtStartDate]').datepicker('getDate')),
            hideIfNoPrevNext: true,
            beforeShow: function (dateText, inst) {
                var the_date = $('input[id$=txtDashStartDate]').datepicker('getDate');
                $("input[id$=txtDashEndDate]").datepicker('option', 'minDate', the_date);
            }
        });
        $jdp('#txtStartDateStu').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            maxDate: '0',
            hideIfNoPrevNext: true/*,
            onSelect: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
                $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
            }*/
        });
        $jdp('#txtEndDateStu').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            maxDate: '0',
            //            minDate: new Date($jdp('input[id$=txtStartDate]').datepicker('getDate')),
            hideIfNoPrevNext: true,
            beforeShow: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtStartDateStu]').datepicker('getDate');
                $jdp("input[id$=txtEndDateStu]").datepicker('option', 'minDate', the_date);
            }
        });
        $jdp('#txtFrom').datepicker({
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true
        });
        $jdp('#txtTo').datepicker({
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true
        });
        $jdp('#tcManageMDT_tpMDTHistory_txtStartDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            maxDate: '0',
            hideIfNoPrevNext: true/*,
            onSelect: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
                $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
            }*/
        });
        $jdp('#tcManageMDT_tpMDTHistory_txtEndDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            maxDate: '0',
            //            minDate: new Date($jdp('input[id$=txtStartDate]').datepicker('getDate')),
            hideIfNoPrevNext: true
            //            beforeShow: function(dateText, inst) {
            //                var the_date = $jdp('input[id$=tcManageMDT_tpMDTHistory_txtStartDate]').datepicker('getDate');
            //                $jdp("input[id$=tcManageMDT_tpMDTHistory_txtStartDate]").datepicker('option', 'minDate', the_date);
            //            }
        });
        $jdp('#tcGarminContainer_tpHistory_txtStartDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            maxDate: '0',
            hideIfNoPrevNext: true/*,
            onSelect: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
                $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
            }*/
        });
        $jdp('#tcGarminContainer_tpHistory_txtEndDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            maxDate: '0',
            //            minDate: new Date($jdp('input[id$=txtStartDate]').datepicker('getDate')),
            hideIfNoPrevNext: true
            //            beforeShow: function(dateText, inst) {
            //                var the_date = $jdp('input[id$=tcManageMDT_tpMDTHistory_txtStartDate]').datepicker('getDate');
            //                $jdp("input[id$=tcManageMDT_tpMDTHistory_txtStartDate]").datepicker('option', 'minDate', the_date);
            //            }
        });

        $jdp('#txtHistoryStartDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            maxDate: '0',
            hideIfNoPrevNext: true
        });

        $jdp('#txtHistoryEndDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            maxDate: '0',
            hideIfNoPrevNext: true,
            beforeShow: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtHistoryStartDate]').datepicker('getDate');
                $jdp("input[id$=txtHistoryEndDate]").datepicker('option', 'minDate', the_date);
            }
        });

        if (document.getElementById('txtEffectiveFrom') != null) {
            $jdp('#txtEffectiveFrom').datepicker({
                numberOfMonths: 1,
                showButtonPanel: true,
                dateFormat: 'dd-M-yy',
                changeYear: true,
                changeMonth: true,
                hideIfNoPrevNext: true,
                onSelect: RestrictDate,
                beforeShow: RestrictDate
            });
        }
       
        if (document.getElementById('txtEffectiveTo') != null) {
            $jdp('#txtEffectiveTo').datepicker({
                numberOfMonths: 1,
                showButtonPanel: true,
                dateFormat: 'dd-M-yy',
                changeYear: true,
                changeMonth: true,
                hideIfNoPrevNext: true,
                onSelect:RestrictDate,
                beforeShow: RestrictDate
            });
        }
        if (document.getElementById('txtScheduleFrom') != null) {
            $jdp('#txtScheduleFrom').datepicker({
                numberOfMonths: 1,
                showButtonPanel: true,
                dateFormat: 'dd-M-yy',
                changeYear: true,
                changeMonth: true,
                hideIfNoPrevNext: true,
                onSelect: RestrictDateSchedule,
                beforeShow: RestrictDateSchedule
            });
        }
        if (document.getElementById('txtScheduleTo') != null) {
            $jdp('#txtScheduleTo').datepicker({
                numberOfMonths: 1,
                showButtonPanel: true,
                dateFormat: 'dd-M-yy',
                changeYear: true,
                changeMonth: true,
                hideIfNoPrevNext: true,
                beforeShow: RestrictDateSchedule
            });
        }

        $jdp("[id$='_txtTimeBasedInitializationValue']").datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });

        if (document.getElementById('txtExecutedOn') != null) {
            $jdp('#txtExecutedOn').datepicker({
                numberOfMonths: 1,
                showButtonPanel: true,
                dateFormat: 'dd-M-yy',
                changeYear: true,
                changeMonth: true,
                hideIfNoPrevNext: true,
                onSelect: RestrictTimeBasedSI,
                beforeShow: RestrictTimeBasedSI
            });
        }

        $jdp("[id$='_gtxtServicedOn']").datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });

        if (document.getElementById('txtDueOnDate') != null) {
            $jdp('#txtDueOnDate').datepicker({
                numberOfMonths: 1,
                showButtonPanel: true,
                dateFormat: 'dd-M-yy',
                changeYear: true,
                changeMonth: true,
                hideIfNoPrevNext: true,
                onSelect: RestrictTimeBasedSI,
                beforeShow: RestrictTimeBasedSI
            });
        }
    });

    //End request ends here
    $jdp('#txtStartDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        minDate: new Date(new Date().getFullYear(), new Date().getMonth() - 2, new Date().getDate()),
        maxDate: '0',
        hideIfNoPrevNext: true/*,
        onSelect: function(dateText, inst) {
            var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
            $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
        }*/
    });
    $jdp('#txtDashStartDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        minDate: new Date(new Date().getFullYear() - 2, new Date().getMonth(), new Date().getDate()),
        maxDate: '0',
        hideIfNoPrevNext: true/*,
        onSelect: function(dateText, inst) {
            var the_date = $('input[id$=txtStartDate]').datepicker('getDate');
            $("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
        }*/
    });
    $jdp('#txtStartDateStu').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        minDate: new Date(new Date().getFullYear(), new Date().getMonth() - 12, new Date().getDate()),
        maxDate: '0',
        hideIfNoPrevNext: true/*,
        onSelect: function(dateText, inst) {
            var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
            $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
        }*/
    });
    //fare Mgmt
    $jdp('#txtVStartDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        minDate: new Date(new Date().getFullYear(), new Date().getMonth() - 2, new Date().getDate()),
        maxDate: '0',
        hideIfNoPrevNext: true/*,
        onSelect: function(dateText, inst) {
            var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
            $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
        }*/
    });
    $jdp('#txtEndDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        minDate: new Date(new Date().getFullYear(), new Date().getMonth() - 2, new Date().getDate()),
        maxDate: '0',
        hideIfNoPrevNext: true/*,
        beforeShow: function(dateText, inst) {
            var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
            $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
        }*/
    });
    $jdp('#txtDashEndDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        minDate: new Date(new Date().getFullYear() - 2, new Date().getMonth(), new Date().getDate()),
        maxDate: '0',
        hideIfNoPrevNext: true/*,
        beforeShow: function(dateText, inst) {
            var the_date = $('input[id$=txtStartDate]').datepicker('getDate');
            $("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
        }*/
    });
    $jdp('#txtEndDateStu').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        minDate: new Date(new Date().getFullYear(), new Date().getMonth() - 12, new Date().getDate()),
        maxDate: '0',
        hideIfNoPrevNext: true/*,
        beforeShow: function(dateText, inst) {
            var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
            $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
        }*/
    });
    //Fare Mgmt
    $jdp('#txtVEndDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        minDate: new Date(new Date().getFullYear(), new Date().getMonth() - 2, new Date().getDate()),
        maxDate: '0',
        hideIfNoPrevNext: true/*,
        beforeShow: function(dateText, inst) {
            var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
            $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
        }*/
    });
    $jdp('#txtFrom').datepicker({
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true
    });
    $jdp('#txtTo').datepicker({
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true
    });
    $jdp('#tcManageMDT_tpMDTHistory_txtStartDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        hideIfNoPrevNext: true/*,
            onSelect: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
                $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
            }*/
    });
    $jdp('#tcManageMDT_tpMDTHistory_txtEndDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        //            minDate: new Date($jdp('input[id$=txtStartDate]').datepicker('getDate')),
        hideIfNoPrevNext: true
        //            beforeShow: function(dateText, inst) {
        //                var the_date = $jdp('input[id$=tcManageMDT_tpMDTHistory_txtStartDate]').datepicker('getDate');
        //                $jdp("input[id$=tcManageMDT_tpMDTHistory_txtStartDate]").datepicker('option', 'minDate', the_date);
        //            }
    });
    $jdp('#tcGarminContainer_tpHistory_txtStartDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        hideIfNoPrevNext: true/*,
            onSelect: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
                $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
            }*/
    });
    $jdp('#tcGarminContainer_tpHistory_txtEndDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        //            minDate: new Date($jdp('input[id$=txtStartDate]').datepicker('getDate')),
        hideIfNoPrevNext: true
        //            beforeShow: function(dateText, inst) {
        //                var the_date = $jdp('input[id$=tcManageMDT_tpMDTHistory_txtStartDate]').datepicker('getDate');
        //                $jdp("input[id$=tcManageMDT_tpMDTHistory_txtStartDate]").datepicker('option', 'minDate', the_date);
        //            }
    });
    $jdp('#txtHistoryStartDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        hideIfNoPrevNext: true
    });

    $jdp('#txtHistoryEndDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        hideIfNoPrevNext: true,
        beforeShow: function(dateText, inst) {
            var the_date = $jdp('input[id$=txtHistoryStartDate]').datepicker('getDate');
            $jdp("input[id$=txtHistoryEndDate]").datepicker('option', 'minDate', the_date);
        }
    });

    if (document.getElementById('txtEffectiveFrom') != null) {
        //End request ends here
        $jdp('#txtEffectiveFrom').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictDate,
            beforeShow: RestrictDate
        });
    }

    if (document.getElementById('txtEffectiveTo') != null) {
        $jdp('#txtEffectiveTo').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictDate,
            beforeShow: RestrictDate
        });
    }

    if (document.getElementById('txtScheduleFrom') != null) {
        $jdp('#txtScheduleFrom').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictDateSchedule,
            beforeShow: RestrictDateSchedule
        });
    }
    if (document.getElementById('txtScheduleTo') != null) {
        $jdp('#txtScheduleTo').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            beforeShow: RestrictDateSchedule
        });
    }

    $jdp("[id$='_txtTimeBasedInitializationValue']").datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        hideIfNoPrevNext: true,
        onSelect: RestrictTimeBasedSI,
        beforeShow: RestrictTimeBasedSI
    });

    if (document.getElementById('txtExecutedOn') != null) {
        $jdp('#txtExecutedOn').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            maxDate: '0',
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    }

    $jdp("[id$='_gtxtServicedOn']").datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        hideIfNoPrevNext: true,
        onSelect: RestrictTimeBasedSI,
        beforeShow: RestrictTimeBasedSI
    });

    if (document.getElementById('txtDueOnDate') != null) {
        $jdp('#txtDueOnDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    }
    if (document.getElementById('txtInsuranceDate') != null) {
        $jdp('#txtInsuranceDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    }
    if (document.getElementById('txtcontractfrom') != null) {
        $jdp('#txtcontractfrom').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            minDate: new Date(new Date().getFullYear() - 1, new Date().getMonth(), new Date().getDate()),
            hideIfNoPrevNext: true,
            beforeShow: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtContractTo]').datepicker('getDate');
                $jdp("input[id$=txtcontractfrom]").datepicker('option', 'maxDate', the_date);
            }
            //onSelect: RestrictTimeBasedSI,
            // beforeShow: RestrictTimeBasedSI
        });
    }
    if (document.getElementById('txtContractTo') != null) {
        $jdp('#txtContractTo').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            // minDate: $jdp('input[id$=txtcontractfrom]').datepicker('getDate'),
            hideIfNoPrevNext: true,
            beforeShow: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtcontractfrom]').datepicker('getDate');
                $jdp("input[id$=txtContractTo]").datepicker('option', 'minDate', the_date);
            }
            //  onSelect: RestrictTimeBasedSI,
            // beforeShow: RestrictTimeBasedSI
        });
    }
    if (document.getElementById('txtPermitExpired') != null) {
        $jdp('#txtPermitExpired').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    }
    if (document.getElementById('txtFcExpired') != null) {
        $jdp('#txtFcExpired').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    }
    if (document.getElementById('txtPurchasedDate') != null) {
        $jdp('#txtPurchasedDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    }
    if (document.getElementById('txtFromDate') != null) {
        $jdp('#txtFromDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI,
            minDate: new Date(new Date().getFullYear(), new Date().getMonth() - 1, new Date().getDate())
            //maxDate: '0'
        });
    }
    if (document.getElementById('txtToDate') != null) {
        $jdp('#txtToDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI,
            minDate: new Date(new Date().getFullYear(), new Date().getMonth() - 1, new Date().getDate())
            //maxDate: '0'
        });
    }
    if (document.getElementById('txtInstalledDate') != null) {
        $jdp('#txtInstalledDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    }
    if (document.getElementById('txtInsuranceExpiryDate') != null) {
        $jdp('#txtInsuranceExpiryDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    } if (document.getElementById('txtWarrantyExpiryDate') != null) {
        $jdp('#txtWarrantyExpiryDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    } if (document.getElementById('txtLeaseExpiryDate') != null) {
        $jdp('#txtLeaseExpiryDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    }
    if (document.getElementById('txtWrntyStrtdt') != null) {
        $jdp('#txtWrntyStrtdt').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: function (dateText, inst) {
                var the_date = $jdp('input[id$=txtWrntyEndDt]').datepicker('getDate');
                $jdp("input[id$=txtWrntyStrtdt]").datepicker('option', 'maxDate', the_date);
            }
        });
    }
    if (document.getElementById('txtWrntyEndDt') != null) {
        $jdp('#txtWrntyEndDt').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: function (dateText, inst) {
                var the_date = $jdp('input[id$=txtWrntyStrtdt]').datepicker('getDate');
                $jdp("input[id$=txtWrntyEndDt]").datepicker('option', 'minDate', the_date);
            }
        });
    }

    //});

    //Driver Master
    $jdp('#txtDateOfJoining').datepicker({
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true
    });
    $jdp('#txtDOB').datepicker({
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true
    });
    $jdp('#txtLicenseIssued').datepicker({
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true
    });
    $jdp('#txtLicenseValidity').datepicker({
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true
    });
        $jdp('#txtInsuranceRenewDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    //Salik Fare ValidFrom
    $jdp('#txtFareValidFrom').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        minDate: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()),

        hideIfNoPrevNext: true/*,
        onSelect: function(dateText, inst) {
            var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
            $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
        }*/
    });
    if (document.getElementById('txtPurchasedDate1') != null) {
        $jdp('#txtPurchasedDate1').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            maxDate: '0'
        });
    }
    if (document.getElementById('txtAssessedDate') != null) {
        $jdp('#txtAssessedDate').datepicker({
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            maxDate: '0',
            hideIfNoPrevNext: true

        });
    }
    $jdp('#txtInvcDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        hideIfNoPrevNext: true/*,
            onSelect: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
                $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
            }*/
    });
    $jdp('#txtDueDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        hideIfNoPrevNext: true/*,
            onSelect: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
                $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
            }*/
    });
    $jdp('.PrevDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        hideIfNoPrevNext: true/*,
            onSelect: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
                $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
            }*/
    });
    $jdp('.FutureDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        minDate: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()),
        hideIfNoPrevNext: true/*,
            onSelect: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
                $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
            }*/
    });
    //Route Vehicle Listing
    if (document.getElementById('txtStartDateRouteList') != null) {
        $jdp('#txtStartDateRouteList').datepicker({
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    }
    if (document.getElementById('txtEndDateRouteList') != null) {
        $jdp('#txtEndDateRouteList').datepicker({
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    }
    if (document.getElementById('txtPurchasedOn') != null) {
        $jdp('#txtPurchasedOn').datepicker({
            showButtonPanel: true,
            dateFormat: 'dd/mm/yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    }
    if (document.getElementById('txtExpiresOn') != null) {
        $jdp('#txtExpiresOn').datepicker({
            showButtonPanel: true,
            dateFormat: 'dd/mm/yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    }
    //if (document.getElementById('txtFromDate') != null) {
    //    $jdp('#txtFromDate').datepicker({
    //        showButtonPanel: true,
    //        dateFormat: 'dd/mm/yy',
    //        changeYear: true,
    //        changeMonth: true,
    //        hideIfNoPrevNext: true,
    //        onSelect: RestrictTimeBasedSI,
    //        beforeShow: RestrictTimeBasedSI
    //    });
    //}
    //if (document.getElementById('txtToDate') != null) {
    //    $jdp('#txtToDate').datepicker({
    //        showButtonPanel: true,
    //        dateFormat: 'dd/mm/yy',
    //        changeYear: true,
    //        changeMonth: true,
    //        hideIfNoPrevNext: true,
    //        onSelect: RestrictTimeBasedSI,
    //        beforeShow: RestrictTimeBasedSI
    //    });
    //}
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
function pageLoads() {
    //End request ends here
    /*$jdp('#txtStartDate').datepicker({
    numberOfMonths: 1,
    showButtonPanel: true,
    dateFormat: 'dd-M-yy',
    changeYear: true,
    changeMonth: true,
    maxDate: '0',
    hideIfNoPrevNext: true/*,
    onSelect: function(dateText, inst) {
    var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
    $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
    }
    });*/
    $jdp('.PrevDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        hideIfNoPrevNext: true/*,
            onSelect: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
                $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
            }*/
    });
    $jdp('.FutureDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        minDate: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()),
        hideIfNoPrevNext: true/*,
            onSelect: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
                $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
            }*/
    });
    $jdp('#txtInvcDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        hideIfNoPrevNext: true/*,
            onSelect: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
                $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
            }*/
    });
    $jdp('#txtDueDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        hideIfNoPrevNext: true/*,
            onSelect: function(dateText, inst) {
                var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
                $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
            }*/
    });
    $jdp('#txtEndDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        hideIfNoPrevNext: true,
        beforeShow: function(dateText, inst) {
            var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
            $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
        }
    });
    //$jdp('#txtWrntyStrtdt').datepicker({
    //    numberOfMonths: 1,
    //    showButtonPanel: true,
    //    dateFormat: 'dd-M-yy',
    //    changeYear: true,
    //    changeMonth: true,
    //    maxDate: '0',
    //    hideIfNoPrevNext: true/*,
    //        onSelect: function(dateText, inst) {
    //            var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
    //            $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
    //        }*/
    //});
    //$jdp('#txtWrntyEndDt').datepicker({
    //    numberOfMonths: 1,
    //    showButtonPanel: true,
    //    dateFormat: 'dd-M-yy',
    //    changeYear: true,
    //    changeMonth: true,
       
    //    //            minDate: new Date($jdp('input[id$=txtStartDate]').datepicker('getDate')),
    //    hideIfNoPrevNext: true,
    //    beforeShow: function (dateText, inst) {
    //        var the_date = $jdp('input[id$=txtWrntyStrtdt]').datepicker('getDate');
    //        $jdp("input[id$=txtWrntyEndDt]").datepicker('option', 'minDate', the_date);
    //    }
    //});
    $jdp('#txtDashEndDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        hideIfNoPrevNext: true,
        beforeShow: function (dateText, inst) {
            var the_date = $('input[id$=txtDashStartDate]').datepicker('getDate');
            $("input[id$=txtDashEndDate]").datepicker('option', 'minDate', the_date);
        }
    });
    $jdp('#txtEndDateStu').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        hideIfNoPrevNext: true,
        beforeShow: function(dateText, inst) {
            var the_date = $jdp('input[id$=txtStartDateStu]').datepicker('getDate');
            $jdp("input[id$=txtEndDateStu]").datepicker('option', 'minDate', the_date);
        }
    });

    $jdp('#tcManageMDT_tpMDTHistory_txtEndDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        //            minDate: new Date($jdp('input[id$=txtStartDate]').datepicker('getDate')),
        hideIfNoPrevNext: true
        //            beforeShow: function(dateText, inst) {
        //                var the_date = $jdp('input[id$=tcManageMDT_tpMDTHistory_txtStartDate]').datepicker('getDate');
        //                $jdp("input[id$=tcManageMDT_tpMDTHistory_txtStartDate]").datepicker('option', 'minDate', the_date);
        //            }
    });
    $jdp('#txtFrom').datepicker({
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true
    });
    $jdp('#txtTo').datepicker({
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true
    });
    $jdp('#tcGarminContainer_tpHistory_txtEndDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        //            minDate: new Date($jdp('input[id$=txtStartDate]').datepicker('getDate')),
        hideIfNoPrevNext: true
        //            beforeShow: function(dateText, inst) {
        //                var the_date = $jdp('input[id$=tcManageMDT_tpMDTHistory_txtStartDate]').datepicker('getDate');
        //                $jdp("input[id$=tcManageMDT_tpMDTHistory_txtStartDate]").datepicker('option', 'minDate', the_date);
        //            }
    });

    $jdp('#txtHistoryStartDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        hideIfNoPrevNext: true
    });

    $jdp('#txtHistoryEndDate').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        hideIfNoPrevNext: true,
        beforeShow: function(dateText, inst) {
            var the_date = $jdp('input[id$=txtHistoryStartDate]').datepicker('getDate');
            $jdp("input[id$=txtHistoryEndDate]").datepicker('option', 'minDate', the_date);
        }
    });

    if (document.getElementById('txtEffectiveFrom') != null) {
        $jdp('#txtEffectiveFrom').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictDate,
            beforeShow: RestrictDate
        });
    }
    if (document.getElementById('txtEffectiveTo') != null) {
        $jdp('#txtEffectiveTo').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictDate,
            beforeShow: RestrictDate
        });
    }

    if (document.getElementById('txtScheduleFrom') != null) {
        $jdp('#txtScheduleFrom').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictDateSchedule,
            beforeShow: RestrictDateSchedule
        });
    }
    if (document.getElementById('txtScheduleTo') != null) {
        $jdp('#txtScheduleTo').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            beforeShow: RestrictDateSchedule
        });
    }

    $jdp("[id$='_txtTimeBasedInitializationValue']").datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        hideIfNoPrevNext: true,
        onSelect: RestrictTimeBasedSI,
        beforeShow: RestrictTimeBasedSI
    });

    if (document.getElementById('txtExecutedOn') != null) {
        $jdp('#txtExecutedOn').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            maxDate: '0',
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    }

    $jdp("[id$='_gtxtServicedOn']").datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        maxDate: '0',
        hideIfNoPrevNext: true,
        onSelect: RestrictTimeBasedSI,
        beforeShow: RestrictTimeBasedSI
    });

    if (document.getElementById('txtDueOnDate') != null) {
        $jdp('#txtDueOnDate').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    }
    $jdp('#txtDateOfJoining').datepicker({
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true
    });
    $jdp('#txtLicenseValidity').datepicker({
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true
    });
    //Salik Fare ValidFrom
    $jdp('#txtFareValidFrom').datepicker({
        numberOfMonths: 1,
        showButtonPanel: true,
        dateFormat: 'dd-M-yy',
        changeYear: true,
        changeMonth: true,
        minDate: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()),

        hideIfNoPrevNext: true/*,
        onSelect: function(dateText, inst) {
            var the_date = $jdp('input[id$=txtStartDate]').datepicker('getDate');
            $jdp("input[id$=txtEndDate]").datepicker('option', 'minDate', the_date);
        }*/
    });
    //    $jdp('#txtEndDate').datepicker('option', 'minDate', new Date($jdp('input[id$=txtStartDate]').datepicker('getDate')));
    if (document.getElementById('txtPurchasedDate1') != null) {
        $jdp('#txtPurchasedDate1').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            maxDate: '0'
        });
    }
    if (document.getElementById('txtAssessedDate') != null) {
        $jdp('#txtAssessedDate').datepicker({
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            maxDate: '0',
            hideIfNoPrevNext: true

        });
    }
    //Route Vehicle Listing
    if (document.getElementById('txtStartDateRouteList') != null) {
        $jdp('#txtStartDateRouteList').datepicker({
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    }
    if (document.getElementById('txtEndDateRouteList') != null) {
        $jdp('#txtEndDateRouteList').datepicker({
            showButtonPanel: true,
            dateFormat: 'dd-M-yy',
            changeYear: true,
            changeMonth: true,
            hideIfNoPrevNext: true,
            onSelect: RestrictTimeBasedSI,
            beforeShow: RestrictTimeBasedSI
        });
    }
}

function RestrictDateSchedule(dateText, inst) {
    $jdp('#txtScheduleFrom').datepicker('option', 'minDate', new Date());
    $jdp('#txtScheduleTo').datepicker('option', 'minDate', new Date());
}

function RestrictDate(dateText, inst) { 
    $jdp('#txtEffectiveFrom').datepicker('option', 'minDate', new Date());
    $jdp('#txtEffectiveTo').datepicker('option', 'minDate', new Date(fromDate));
}
function RestrictDate(dateText, inst) {
    var isWeekly = false;
    if (document.getElementById('ddlFrequency') != null) {
        var val = document.getElementById('ddlFrequency').value;
    }
    else if (document.getElementById('tdFrequencyInfor') != null) {
        var valCommands = document.getElementById('ddlFrequencyCommands').value;
    }
    else {
        var val = '1';
        isWeekly = true;
    }

    var fromDate = $jdp('input[id$=txtEffectiveFrom]').datepicker('getDate');

    if (valCommands != null) {
        $jdp('#txtEffectiveFrom').datepicker('option', 'minDate', new Date());
        $jdp('#txtEffectiveTo').datepicker('option', 'minDate', new Date());
    }
    else if (fromDate == null) {
        if (val != '') {
            if (val == '0') {
                $jdp('#txtEffectiveFrom').datepicker('option', 'minDate', new Date());
                $jdp('#txtEffectiveTo').datepicker('option', 'minDate', new Date());
            }
            else if (val == '1') {
                $jdp('#txtEffectiveFrom').datepicker('option', 'minDate', new Date());
                if (isWeekly) {
                    $jdp('#txtEffectiveTo').datepicker('option', 'minDate', '+6D');
                }
                else {
                    $jdp('#txtEffectiveTo').datepicker('option', 'minDate', '+2D');
                }
            }
            else if (val == '3') {
                $jdp('#txtEffectiveFrom').datepicker('option', 'minDate', "-13D");
                $jdp('#txtEffectiveTo').datepicker('option', 'minDate', new Date());
            }
            else if (val == '2') {
                $jdp('#txtEffectiveFrom').datepicker('option', 'minDate', new Date(new Date().getFullYear(), new Date().getMonth() - 2, new Date().getDate()));
                $jdp('#txtEffectiveTo').datepicker('option', 'minDate', '+8D');
            }
        }
    }
    else {
        if (val != '') {
            if (val == '0') {
                $jdp('#txtEffectiveFrom').datepicker('option', 'minDate', new Date());
                $jdp('#txtEffectiveTo').datepicker('option', 'minDate', new Date(fromDate));
            }
            else if (val == '1') {
                $jdp('#txtEffectiveFrom').datepicker('option', 'minDate', new Date());
                if (isWeekly) {
                    $jdp('#txtEffectiveTo').datepicker('option', 'minDate', new Date(fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate() + 7));
                }
                else {
                    $jdp('#txtEffectiveTo').datepicker('option', 'minDate', new Date(fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate() + 2));
                }
            }
            else if (val == '3') {
                $jdp('#txtEffectiveFrom').datepicker('option', 'minDate', "-13D");
                $jdp('#txtEffectiveTo').datepicker('option', 'minDate', new Date());
            }
            else if (val == '2') {
                $jdp('#txtEffectiveFrom').datepicker('option', 'minDate', new Date(new Date().getFullYear(), new Date().getMonth() - 2, new Date().getDate()));
                $jdp('#txtEffectiveTo').datepicker('option', 'minDate', new Date(fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate() + 8));
            }
        }
    }
    if (document.getElementById('ddlFrequencyCommands') != null && document.getElementById('txtEffectiveFrom').value != null && document.getElementById('txtEffectiveFrom').value != ""
     && document.getElementById('txtEffectiveTo').value != null && document.getElementById('txtEffectiveTo').value != "") {
        CheckddlFrequency();
    }
}

function RestrictTimeBasedSI(dateText, inst) {
    var isRecurring = document.getElementById("txtIsRecurring");

    if (isRecurring != null && isRecurring.value == "Y") {
        $jdp("[id$='_txtTimeBasedInitializationValue']").datepicker('option', 'maxDate', new Date());
    }
    else {
        $jdp("[id$='_txtTimeBasedInitializationValue']").datepicker('option', 'minDate', new Date());
    }

    var servicedOnDate = document.getElementById("hdnTimeBasedStartDate");

    if (servicedOnDate != null && servicedOnDate.value != "") {
        if ($jdp("[id$='_gtxtServicedOn']") != null) {
            $jdp("[id$='_gtxtServicedOn']").datepicker('option', 'minDate', new Date(servicedOnDate.value));
            $jdp("[id$='_gtxtServicedOn']").datepicker('option', 'maxDate', new Date());
        }
        if ($jdp('#txtExecutedOn') != null) {
            $jdp('#txtExecutedOn').datepicker('option', 'minDate', new Date(servicedOnDate.value));
            $jdp('#txtExecutedOn').datepicker('option', 'maxDate', new Date());
        }
    }
    else {
        if ($jdp('#txtExecutedOn') != null) {
            var currentDate = new Date();
            $jdp('#txtExecutedOn').datepicker('option', 'minDate', new Date(currentDate.getFullYear(), currentDate.getMonth() - 2, currentDate.getDate()));
            $jdp('#txtExecutedOn').datepicker('option', 'maxDate', new Date());
        }
    }

    if ($jdp('#txtDueOnDate') != null) {
        var currentDate = new Date();

        $jdp('#txtDueOnDate').datepicker('option', 'minDate', new Date());
        $jdp('#txtDueOnDate').datepicker('option', 'maxDate', new Date(currentDate.getFullYear(), currentDate.getMonth() + 6, currentDate.getDate()));
    }
}

