<script type="text/javascript">
    YAHOO.util.Event.onDOMReady(function () {
        initialize('{{ Lang_translate('_UNDO', 'standard') }}');
    });

    var lb = new LightBox();
    lb.back_url = 'index.php?r=lms/{{ data.endpoint }}/show&sop=unregistercourse';

    var Config = {};
    Config.langs = {_CLOSE: "{{ Lang_translate('_UNDO', 'standard') }}"};
    lb.init(Config);

    function chooseEdition(id_course) {

        var posting = $.get(
            window.frontend.config.url.appLms + '/ajax.server.php',
            {
                r: '{{ data.endpoint }}/chooseEdition',
                id_course: id_course,
                type_course: $("#typeCourse").val(),
                id_catalogue: {{ data.id_catalogue }},
                id_category: window.catalog.selectedCategory
            }
        )
        posting.done(function (r) {
            $('body').prepend(r)
            $('#formaModal').css("margin-top", $('body').height() / 2 - $('.modal-content').height() / 2 - 300);
            $('#formaModal').modal('show')
        });
        posting.fail(function () {
            alert('call failed')
        })
    }

    function confirmDialog(dialog_title, dialog_body, op, id_course, overbooking) {

        $('<div></div>').appendTo('body')
            .html("<div style='text-align:center'><h6>" + dialog_body + "</h6></div>")
            .dialog({
                modal: true,
                title: dialog_title,
                autoOpen: true,
                resizable: false,
                buttons: {
        {{ Lang_translate('_CONFIRM','standard') }} :

        function () {
            var posting = $.get(
                window.frontend.config.url.appLms + '/ajax.server.php',
                {
                    r: op,
                    id_course: id_course,
                    overbooking: overbooking,
                    type_course: $("#typeCourse").val(),
                    id_catalogue: {{ data.id_catalogue }},
                    id_category: window.catalog.selectedCategory
                }
            )
                .done(function (responseText) {
                       if ('lms/' + op == '{{ data.endpoint }}/addToCart') {
                        $('#menu_over').load(document.URL + '  #menu_over');
                         if($('#cart_element').parent('li').hasClass('hidden')) {
                             $('#cart_element').parent('li').removeClass('hidden');   
                        }
                       }
                    $("#div_course").html(responseText);
                })
                .fail(function () {
                    alert('unsubscribe failed')
                })
            $(this).dialog("close");
        }

    ,
        {{ Lang_translate('_UNDO','standard') }} :

        function () {
            $(this).dialog("close");
        }
    },
        open: function (event, ui) {
            $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
        }
    ,
        close: function (event, ui) {
            $(this).remove();
        }
    })
        ;
    }
</script>

<div id="cbp-vm" class="" style="margin-top: 15px;">
    {% for course in data.courses %}
        <div class="col-xs-offset-1 col-xs-10 col-md-offset-0 col-md-4">
            {% include 'partials/catalog-course-box.html.twig' with { 'course': course, 'catalogueType': data.catalogueType, 'endpoint' : data.endpoint, 'logged_in': data.logged_in } %}
        </div>
    {% endfor %}
</div>