(function(){

    // if (document.querySelector('.show-promo-popup')) {
    //     alert(1);
    // }

    function addPopup(){
        var popup = '<div class="promo-popup">' +
                    '<a href="#" class="pp-close"><span class="icon-close"></span></a>' +
                    '<div class="pp-text">Sign up to Learn How to Get Your Book Published!</div>' + 
                    '<div class="pp-btn"><a href="https://livecarta.com/user/registration" class="button mp-top-left xxl">sign up for free</a></div>' +
                '</div>';
    
        document.body.insertAdjacentHTML('beforeend', popup);
        setTimeout(function(){
            document.querySelector('.promo-popup').classList.add('show');
            document.querySelector('.promo-popup .pp-close').addEventListener('click', function(e){
                e.preventDefault();
                var popup = document.querySelector('.promo-popup');
                popup.parentElement.removeChild(popup);
            })
        },500);  
    }

    if (document.querySelector('.show-promo-popup')) {
        setTimeout(function(){
            if (!document.querySelector('.signed-user')){
                addPopup();
            }                
        }, 6000);
    }

})();

