<?php

/**

 * 初回アクセス時のダイアログ表示

 */

?>

<div id="modal-wrap">

    <div id="modal-background">

    </div>

    <div id="modal-block">

        <div id="confirmation_modal">

            <div id="confirmation-wrap">

                <p id="confirmation-text1" class=confirmation-text>

                    このサイトは、医療機関向けの個人輸入に関しての情報提供サイトです。医療関係者の皆様に、海外医薬品の輸入に関する情報を提供しております。

                </p>

                <p id="confirmation-text2" class="confirmation-text">

                    あなたは医療関係従事者の方ですか?

                </p>

                <div class="button-box">

                    <a href="#" id="confirm-button" class="button" data-confirm="y">はい</a>

                    <a href="/medicsonly/" id="deny-button" class="button" data-confirm="n">いいえ</a>

                </div>

            </div>

        </div>

    </div>

</div>

<script>

    var confirm = localStorage.initialConfirmation;

    var expiration = localStorage.initialConfTerm;

    var dUTC = Date.parse(new Date().toGMTString());

    var modal = document.getElementById('modal-wrap');

    var modalBlock = document.getElementById('modal-block');

    var buttons = document.querySelectorAll('[data-confirm]');

    // check user confirmation

    if ( confirm == 'yes' && ( expiration >= dUTC ) ) { //in case of confiramtion made and not expired

        document.body.removeChild(modal);

        document.documentElement.setAttribute('style','overflow: visible;');

        document.body.setAttribute('style','overflow: visible;');

    } else { // in case of first visit and data expired

        localStorage.setItem('initialConfirmation', false);

		modal.setAttribute('style','visibility: visible;');

    }

    for (var i = 0; i < buttons.length; i++) {

        buttons[i].addEventListener('click', function(){

            if ( this.getAttribute('data-confirm') == 'y' ) {

                localStorage.setItem('initialConfirmation', 'yes');

                localStorage.setItem('initialConfTerm', dUTC+86400000);

                document.body.removeChild(modal);

                document.documentElement.setAttribute('style','overflow: visible;');

                document.body.setAttribute('style','overflow: visible;');

            } else {

                localStorage.clear();

                modal.removeChild(modalBlock);

            }

        });

    }

</script>