$(document).ready(function(){
    LiveForm.setOptions({
        messageParentClass: "form-group"
    });

    $('.datepicker').datetimepicker(
    {
        locale: 'en',
        format: 'DD.MM.YYYY'
    });

    $('.datetimepicker').datetimepicker(
    {
        locale: 'en',
        format: 'DD.MM.YYYY H:mm'
    });

    $('.images-viewer').viewer({
        url: 'data-viewer'
    });

    $('[data-dependentselectbox]').dependentSelectBox();

    function prependIcons(icon){
        if (!icon.id) { return icon.text; }
        var $icon = $(
            '<span><i class="fa fa-' + icon.element.value.toLowerCase() + '"></i> ' + icon.text + '</span>'
        );
        return $icon;
    }

    $('.select2').select2({width: "100%"});

    $('.select2-icons').select2({
        width: "100%",
        templateResult: prependIcons
    });

    $.nette.init();
});
