// Creare's 'Implied Consent' EU Cookie Law Banner v:2.4 // Conceived by Robert Kent, James Bavington & Tom Foyster var dropCookie = true; // false disables the Cookie, allowing you to style the banner var cookieDuration = 365; // Number of days before the cookie expires, and the banner reappears var cookieName = 'complianceCookie'; // Name of our cookie var cookieValue = 'on'; // Value of cookie function createDiv(){ var bodytag = document.getElementsByTagName('body')[0]; var div = document.createElement('div'); div.setAttribute('id','cookie-law'); div.innerHTML = cookieMessage; bodytag.insertBefore(div,bodytag.firstChild); $('#cookie-law-content').slideToggle(650); // createCookie(window.cookieName,window.cookieValue, window.cookieDuration); // Create the cookie var i; for (i = 1; i <= 3; i++) { createCookie("cookie-consent-option-"+i, "1", window.cookieDuration) } } function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; if(window.dropCookie) { document.cookie = name+"="+value+expires+"; path=/"; } } function checkCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } window.onload = function(){ if (checkCookie(cookieName) != cookieValue) { createDiv(); } if ($("#cookie-consent-current-options").length) { updateCookieConsentSelectedOptions() } loadScripts(); } function updateCookieConsentSelectedOptions() { var i; $("#cookie-consent-current-options").text(""); for (i = 1; i <= 3; i++) { if (checkCookie("cookie-consent-option-"+i) == "1") { if (i==1) { $("#cookie-consent-current-options").append($("#cookie-consent-option-"+i).attr("desc")); } else { $("#cookie-consent-current-options").append(", " + $("#cookie-consent-option-"+i).attr("desc")); } $("#cookie-consent-option-"+i).prop('checked', true); } } } function acceptAndClose(){ createCookie(window.cookieName,window.cookieValue, window.cookieDuration); // Create the cookie var i; for (i = 1; i <= 3; i++) { createCookie("cookie-consent-option-"+i, "1", window.cookieDuration) } $('#cookie-law-content').slideToggle(400); } function loadScripts() { var i; for (i = 2; i <= 3; i++) { if (checkCookie("cookie-consent-option-"+i) == "1") { $("script[type*=plain][cookie-consent-option="+i+"]").each(function() { eval($(this).text()) } ); } } } $("#update-cookie-consent-button").click(function() { $('#consent-options').show(); $(this).hide() }) $("#cookie-consent-save-button").click(function() { $(".consent-checkbox").each(function() { if (this.checked) { createCookie(this.id, "1", window.cookieDuration) } else { eraseCookie(this.id) } }); updateCookieConsentSelectedOptions(); createCookie(window.cookieName,window.cookieValue, window.cookieDuration); // Create the cookie $('#cookie-law-content').slideUp(400); // hide $('#consent-options').slideUp(400); // hide $('#update-cookie-consent-button').show(); // show the button again })