// JavaScript Document
var setCookie;
var getCookie;
var cookieMessage;
setCookie = (cName, cValue, expDays) => {
let date = new Date();
date.setTime(date.getTime() + (expDays * 24 * 60 * 60 * 1000));
const expires = "expires=" + date.toUTCString();
document.cookie = cName + "="  + cValue + "; " + expires + "; path=/" ;
}

getCookie = (cName) => {
const name = cName + "=";
const cDecoded = decodeURIComponent(document.cookie);
const cArr = cDecoded.split("; ");
let value;
cArr.forEach(val => {
if(val.indexOf(name) === 0) value = val.substring(name.length);
})
return value;
}

document.querySelector("#cookie-btn").addEventListener("click", () => {
document.querySelector("#cookiebox").style.display = "none";
setCookie("CookieConsent", true, 30);
})

cookieMessage = () => {
if(!getCookie("CookieConsent"))
document.querySelector("#cookiebox").style.display = "block";
}

window.addEventListener("load", cookieMessage);