<?php defined('_JEXEC') or die; ?>

<!-- Modal -->
<div class="modal" id="newsLetterSubscribeModal" tabindex="-1" role="dialog" aria-labelledby="termsModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title"><?= JText::_('MOD_AL_NEWSLETTER_SUBSCRIBE_HEADER') ?></h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <p><?= JText::_('MOD_AL_NEWSLETTER_SUBSCRIBE_TEXT') ?></p>
                <hr>

                <form action="" method="post">
                    <div class="form-group">
                        <label for="name"><b><?= JText::_('MOD_AL_NEWSLETTER_NAME') ?>:</b></label>
                        <input type="text" class="form-control" id="name" placeholder="<?= JText::_('MOD_AL_NEWSLETTER_NAME_PLACEHOLDER') ?>" name="name" required>
                    </div>

                    <div class="form-group">
                        <label for="email"><b><?= JText::_('MOD_AL_NEWSLETTER_EMAIL') ?>:</b></label>
                        <input type="email" class="form-control" id="email" placeholder="<?= JText::_('MOD_AL_NEWSLETTER_EMAIL_PLACEHOLDER') ?>" name="email" required>
                    </div>
                    <br>

                    <button type="submit" name="subscribe-newsletter-btn" class="btn btn-primary"><?= JText::_('MOD_AL_NEWSLETTER_SUBSCRIBE_BTN') ?></button>
                </form>
            </div>
        </div>
    </div>
</div>

<script>
    jQuery(document).ready(function() {
        jQuery('#alNewsletterBtn').after('<button class="btn btn-primary" data-toggle="modal" data-target="#newsLetterSubscribeModal">Abonnieren</button>');

        /*if (localStorage.getItem('al_newsletter') == null)
            jQuery("#newsLetterSubscribeModal").modal();*/

        jQuery('#newsLetterSubscribeModal').on('shown.bs.modal', function(e) {
            if (localStorage.getItem('al_newsletter') == null)
                localStorage.setItem('al_newsletter', true);
        });
    });
</script>