document.addEventListener("DOMContentLoaded", function() { // Function to check if current Polish time (Europe/Warsaw) is within business hours: Monday-Friday, 9:00-18:00. function isBusinessHours() { var now = new Date(); // Convert current time to Poland time using the "Europe/Warsaw" timezone. var polandTime = new Date(now.toLocaleString("en-US", { timeZone: "Europe/Warsaw" })); var day = polandTime.getDay(); // Sunday = 0, Monday = 1, ... Saturday = 6 var hour = polandTime.getHours(); // Business hours: Monday (1) to Friday (5) and from 9:00 (inclusive) to 18:00 (exclusive) return (day >= 1 && day <= 5 && hour >= 9 && hour < 18); } // Only display the chat widget if it is within the business hours if (isBusinessHours()) { // Create the chat container var chatContainer = document.createElement("div"); chatContainer.id = "chat-container"; // Create the popup message element var chatPopup = document.createElement("div"); chatPopup.id = "chat-popup"; chatPopup.textContent = "Skontaktuj się z nami!"; chatContainer.appendChild(chatPopup); // Create the WhatsApp chat icon/link var chatLink = document.createElement("a"); chatLink.href = "https://wa.me/48662765912"; chatLink.target = "_blank"; chatLink.id = "chat-icon"; var chatImg = document.createElement("img"); chatImg.src = "https://upload.wikimedia.org/wikipedia/commons/6/6b/WhatsApp.svg"; chatImg.alt = "WhatsApp Chat Icon"; chatLink.appendChild(chatImg); chatContainer.appendChild(chatLink); // Append the chat container to the designated container in the page document.getElementById("chat-widget-container").appendChild(chatContainer); // Show the popup message after 10 seconds setTimeout(function(){ chatPopup.style.display = "block"; }, 10000); } });