window.onload = () => {
	let winWidth = window.innerWidth;
	let bottomSize = winWidth < 420 ? "-200px": "-300px";
	let popup = document.querySelector(".page-popup");
  	let closeButton = document.querySelector(".page-popup-close-button");
	let items = document.querySelectorAll(".page-popup-link");
	let activeItem = items[getRandomInt(items.length)];
	activeItem.classList.toggle("active");

	const showPopup = () => {
    	popup.style.animation = winWidth < 420 ? "showAnimSmall 5.0s ease-in-out" : "showAnim 0.0s ease-in-out";
    	popup.style.bottom = winWidth < 420 ? "0" : "0px";
	}

	const closePopup = () => {
		popup.style.animation = winWidth < 420 ? "hideAnimSmall .5s ease-in-out" : "hideAnim .5s ease-in-out";
		popup.style.bottom = bottomSize;
		setTimeout(()=>{popup.style.display = "none"}, 1000);
	}

		if(popup){
			setTimeout(showPopup, 1000);
  			closeButton.onclick = closePopup;
		}

function getRandomInt(max) {
  return Math.floor(Math.random() * Math.floor(max));
}

}
window.addEventListener('load', function() {
    var socialButtons = document.createElement('div');
    socialButtons.classList.add('sharethis-sticky-share-buttons');
    socialButtons.addEventListener('click', function() {
        yaCounter30721283.reachGoal('_seo_shareButtonsBlockClick');
    });
    document.body.appendChild(socialButtons);
    
    const shareScript = document.createElement('script');
    shareScript.type = 'text/javascript';
    shareScript.async = 'async';
    shareScript.src = 'https://platform-api.sharethis.com/js/sharethis.js#property=6329b8420b5e930012a9c6eb&product=sticky-share-buttons';
    document.head.appendChild(shareScript);
});