function initPdfViewerModalElements() {
    setPdfModalButtons();
    setPdfModals();
    setResizeEvent();
}

function setPdfModalButtons() {

    let counter = 0;

    $('.LimitlessPdfViewerModalButton').each(function() {

        counter++;
        let element = $(this);

        element.attr('id', 'LimitlessPdfViewerModalButton' + counter);
        element.attr('data-target', '#LimitlessPdfModal' + counter);
    });

}

function setPdfModals() {

    let counter = 0;

    $('.LimitlessPdfModal').each(function() {

        counter++;
        let element = $(this);

        element.attr('id', 'LimitlessPdfModal' + counter);
    });

}

function setResizeEvent() {

    // Resize the modal to the right size.
    $(window).on('touchstart click resize', function () {
        setTimeout(function(){
            $('.pdfIframe').each(function () {
                var ModalDialog = $(this).parents('.modal');
                $(this).height((ModalDialog.height() - 250) + 'px');
            });
        },300);
    });

}

$(document).ready(function() {
    initPdfViewerModalElements();
});