$(function () {
    var $datePicker = $('.datePicker');

    if ($datePicker.length > 0) {
        $datePicker.datetimepicker({
            timepicker:false,
            format:'d-m-Y',
            closeOnDateSelect:true,
            scrollInput: false
        });
    }

    var $select2 = $('.choosenSelect');

    if ($select2.length > 0) {
        $select2.select2();
    }

    var $perPageForm = $('select[name="per_page"]');

    if ($perPageForm.length > 0) {
        $perPageForm.change(function (e) {
            $(this).parent().submit();
        });
    }

    var $deleteForm = $('#delete_delete');

    if ($deleteForm.length > 0) {
        $deleteForm.change(function (e) {
            if (this.checked) {
                $('#AdminDeleteInput').removeAttr('disabled');
            } else {
                $('#AdminDeleteInput').attr('disabled', 'disabled');
            }
        });
    }
});
