function setTheme(theme){document.documentElement.setAttribute('data-theme',theme);localStorage.setItem('theme',theme);var icon=document.getElementById('theme-icon');var iconDesktop=document.getElementById('theme-icon-desktop');if(icon)icon.className=theme==='dark'?'fas fa-sun':'fas fa-moon';if(iconDesktop)iconDesktop.className=theme==='dark'?'fas fa-sun':'fas fa-moon';} function toggleTheme(){const current=document.documentElement.getAttribute('data-theme')||'light';setTheme(current==='light'?'dark':'light');} var themeToggle=document.getElementById('theme-toggle');if(themeToggle)themeToggle.addEventListener('click',toggleTheme);var themeToggleDesktop=document.getElementById('theme-toggle-desktop');if(themeToggleDesktop)themeToggleDesktop.addEventListener('click',toggleTheme);(function(){let theme=localStorage.getItem('theme');if(!theme){theme=window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light';} setTheme(theme);})();window.addEventListener('DOMContentLoaded',function(){document.body.classList.add('page-loaded');var fadeEls=document.querySelectorAll('.fade-in-up');fadeEls.forEach(function(el,i){setTimeout(function(){el.classList.add('visible');},200+i*180);});const counters=document.querySelectorAll('.counter');const animateCounters=()=>{counters.forEach(counter=>{const target=parseInt(counter.getAttribute('data-target'));const count=parseInt(counter.innerText);const increment=target/100;if(count+';setTimeout(animateCounters,20);}else{counter.innerText=target;}});};const observerOptions={threshold:0.5,rootMargin:'0px 0px -100px 0px'};const observer=new IntersectionObserver((entries)=>{entries.forEach(entry=>{if(entry.isIntersecting){animateCounters();observer.unobserve(entry.target);}});},observerOptions);const aboutStats=document.querySelector('.about-stats');if(aboutStats){observer.observe(aboutStats);}});document.addEventListener('DOMContentLoaded',function(){var mapDiv=document.getElementById('map');if(mapDiv){var map=L.map('map',{center:[50.77989716345206,4.048368809494087],zoom:13,zoomControl:true,attributionControl:false});var maptilerKey='fyG4fxsIMwJnhJ9hQ1wj';var light=L.tileLayer('https://api.maptiler.com/maps/streets-v2-pastel/{z}/{x}/{y}.png?key='+maptilerKey,{attribution:'© OpenStreetMap contributors © MapTiler',tileSize:512,zoomOffset:-1});var dark=L.tileLayer('https://api.maptiler.com/maps/streets-v2-dark/{z}/{x}/{y}.png?key='+maptilerKey,{attribution:'© OpenStreetMap contributors © MapTiler',tileSize:512,zoomOffset:-1});var isDark=document.documentElement.getAttribute('data-theme')==='dark';var currentLayer=isDark?dark:light;currentLayer.addTo(map);L.marker([50.77989716345206,4.048368809494087]).addTo(map).bindPopup('Kobelly Web Solutions
1755 Oetingen, Pajottegem').openPopup();var observer=new MutationObserver(function(mutations){mutations.forEach(function(mutation){if(mutation.type==='attributes'&&mutation.attributeName==='data-theme'){var newTheme=document.documentElement.getAttribute('data-theme');if(newTheme==='dark'){map.removeLayer(light);dark.addTo(map);}else{map.removeLayer(dark);light.addTo(map);}}});});observer.observe(document.documentElement,{attributes:true});}});document.addEventListener('DOMContentLoaded',function(){var startDate=new Date('2014-01-01');var now=new Date();var years=now.getFullYear()-startDate.getFullYear();if(now.getMonth()card.classList.remove('active'));const activeCard=document.querySelector(`[data-theme="${themeName}"]`);if(activeCard)activeCard.classList.add('active');previewContainer.classList.add('active');if(previewContainer){const previewTop=previewContainer.offsetTop;window.scrollTo({top:previewTop-100,behavior:'smooth'});}} function resetTheme(){const miniWebsite=document.getElementById('mini-website');const previewContainer=document.querySelector('.theme-preview-container');if(miniWebsite){miniWebsite.classList.remove('theme-modern-minimal','theme-bold-vibrant','theme-elegant-professional','theme-tech-startup','theme-creative-agency','theme-ecommerce');miniWebsite.style.removeProperty('--bs-primary');miniWebsite.style.removeProperty('--bs-primary-rgb');} if(previewContainer){previewContainer.removeAttribute('data-theme');} designCards.forEach(card=>card.classList.remove('active'));previewContainer.classList.remove('active');} function hexToRgb(hex){const result=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);return result?`${parseInt(result[1],16)},${parseInt(result[2],16)},${parseInt(result[3],16)}`:'0, 0, 0';} designCards.forEach(card=>{card.addEventListener('click',function(){const themeName=this.getAttribute('data-theme');applyTheme(themeName);});});if(resetButton){resetButton.addEventListener('click',resetTheme);} const style=document.createElement('style');style.textContent=`.color-swatch{width:30px;height:30px;border-radius:50%;border:2px solid#fff;box-shadow:0 2px 4px rgba(0,0,0,0.1);}.preview-mockup{width:200px;height:150px;border-radius:10px;overflow:hidden;box-shadow:0 10px 30px rgba(0,0,0,0.2);margin:0 auto;}.mockup-header{height:30px;}.mockup-content{padding:20px;height:120px;}.mockup-title{height:20px;border-radius:4px;margin-bottom:15px;width:80%;}.mockup-text{height:12px;background:rgba(255,255,255,0.3);border-radius:4px;margin-bottom:8px;width:100%;}.mockup-text:last-child{width:60%;}`;document.head.appendChild(style);});document.addEventListener('DOMContentLoaded',function(){const contactForm=document.querySelector('.contact-form');const submitBtn=document.querySelector('.contact-submit-btn');if(contactForm){contactForm.addEventListener('submit',function(e){e.preventDefault();const formData={firstName:document.getElementById('firstName').value,lastName:document.getElementById('lastName').value,email:document.getElementById('email').value,phone:document.getElementById('phone').value,company:document.getElementById('company').value,service:document.getElementById('service').value,budget:document.getElementById('budget').value,message:document.getElementById('message').value};if(submitBtn){submitBtn.disabled=true;submitBtn.innerHTML='Sending...';} fetch('/contact',{method:'POST',headers:{'Content-Type':'application/json',},body:JSON.stringify(formData)}).then(response=>response.json()).then(data=>{if(data.success){showNotification(data.message,'success');contactForm.reset();}else{showNotification(data.message,'error');}}).catch(error=>{console.error('Error:',error);showNotification('An error occurred. Please try again.','error');}).finally(()=>{if(submitBtn){submitBtn.disabled=false;submitBtn.innerHTML='Send Message';}});});}});function showNotification(message,type='info'){const existingNotifications=document.querySelectorAll('.notification');existingNotifications.forEach(notification=>notification.remove());const notification=document.createElement('div');notification.className=`notification notification-${type}`;notification.innerHTML=`
${message}
`;document.body.appendChild(notification);setTimeout(()=>{notification.classList.add('show');},100);if(type!=='error'){setTimeout(()=>{notification.classList.remove('show');setTimeout(()=>{if(notification.parentElement){notification.remove();}},300);},5000);}}