function initializeDeliveryTypes() {
    $("#Keywords").attr('placeholder', $('#searchPlaceholder').val());

    $dataTable = $('#mainGrid');
    $dataTable.DataTable({
        ajax: {
            url: $dataTable.attr('data-url'),
            data: function (d) {
                d.Keywords = $("#Keywords").val();
            }
        },
        columns: [
            { data: "Active", name: "AcActive", render: $.fn.dataTable.render.toggle("T", true), className: 'dt-body-center dt-head-center' },
            { data: "Delivery", name: "AcDelivery", filtertype: "text", render: $.fn.dataTable.render.link("Delivery") },
            { data: "Name", name: "AcName", filtertype: "text", render: $.fn.dataTable.render.link("Delivery") },
            {
                data: "Transport", name: "AcTransport", filtertype: "text", render: function (data, type, full) {
                    if (type === 'display') {
                        var displayTransport;
                        switch (data) {
                            case '1': displayTransport = data + " - " + $("#maritimeTransportLoc").val(); break;
                            case '2': displayTransport = data + " - " + $("#railwayTransportLoc").val(); break;
                            case '3': displayTransport = data + " - " + $("#roadTransportLoc").val(); break;
                            case '4': displayTransport = data + " - " + $("#airTransportLoc").val(); break;
                            case '5': displayTransport = data + " - " + $("#postalTrafficLoc").val(); break;
                            case '7': displayTransport = data + " - " + $("#transportInstallationsLoc").val(); break;
                            case '8': displayTransport = data + " - " + $("#trafficOnTheWaterwaysLoc").val(); break;
                            case '9': displayTransport = data + " - " + $("#ownDriveLoc").val(); break;
                            default: displayTransport = data; break;
                        }

                        return displayTransport;
                    }

                    return data;
                }
            },
        ]
    });

    $("select").off("change.tableReload");
    $("select").on("change.tableReload", function () {
        $.fn.dataTable.reload($dataTable);
    });

    var typingTimer;
    var doneTypingInterval = 600;
    $('#Keywords').off('keyup');
    $('#Keywords').on('keyup', function () {
        clearTimeout(typingTimer);
        typingTimer = setTimeout(function () { $.fn.dataTable.reload($dataTable); }, doneTypingInterval);
    });
}

function initializeDeliveryTypeEdit() {
    $(document).ready(function () {
        $('#Delivery').focus();

        var elems = Array.prototype.slice.call(document.querySelectorAll('#deliveryTypeForm .js-switch'));
        elems.forEach(function (html) {
            var switchery = new Switchery(html, { size: 'small' });
        });
    });
}