function agegate_isMobileTablet(){ let check = false; (function(a){ if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))){ check = true; } })(navigator.userAgent||navigator.vendor||window.opera); return check;}
 class AVP { /*constructor(agegate_ldarule, agegate_tooYoungWebsite, agegate_force_minor_redirect, agegate_no_age_input) {*/ constructor(options) { this.debug = true; this.log('-- Age Gate launched'); const urlParams = new URLSearchParams(window.location.search); if (urlParams.has('agdebug')) { this.debug = true; this.log('Debug forced to true'); } else { this.debug = false; } this.log('Options:'); this.log(options); this.json_content = {}; this.user_country_json = {}; this.activeLanguage = ''; this.activeCountry = ''; this.getActiveUserInfo(); this.log('constructor setLda'); this.setLda(options['agegate_ldarule']); this.agegate_tooYoungWebsite = options['agegate_tooYoungWebsite']; this.agegate_force_minor_redirect = options['agegate_force_minor_redirect']; this.agegate_no_age_input = options['agegate_no_age_input']; this.agegate_cached_content_file = options['cached_content_file']; this.allow_switch_language = options['allow_switch_language']; this.dateOfBirth = { year: null, month: null, day: null, }; this.params = {}; this.show = false; this.fieldErrors = []; this.avpBody = null; this.today = new Date(); this.form = null; this.yearInput = null; this.monthInput = null; this.dayInput = null; this.monthInputWrapper = null; this.dayInputWrapper = null; this.rememberMeInput = null; this.fieldErrorMessage = null; this.fieldErrorMessageEl = null; this.submitButton = null; this.isLegalThisYear = false; this.isLegalThisMonth = false; this.initMutationObserver(); this.updateParams(); } log(message){ if(this.debug){ console.log(message); } } setLda(ldaRules){ this.log('-- setLda'); this.ldaRules = ldaRules; this.log(this.ldaRules); this.full = this.ldaRules.full; this.inputOrder = (typeof this.ldaRules.format === 'string' ? this.ldaRules.format.split('-'):''); this.inputOrder = this.inputOrder = (typeof this.inputOrder === 'array' ? this.inputOrder.map(input => { switch(input){ case 'yyyy': return 'year'; case 'mm': return 'month'; case 'dd': return 'day'; } }):[]); } updateParams(){ if(window.location.search !== ''){ this.params = (window.location.search.match( new RegExp("([^?=&]+)(=([^&]*))?", 'g' )) || []).reduce( function( result, each, n, every ){ let[ key, value ] = each.split( '=' ); result[ key ] = value; return( result ); }, {}); } } localStorageTest(){ var t = 't'; try { localStorage.setItem(t, t); localStorage.removeItem(t); return true; } catch(e) { return false; } } get show() { return this._show; } set show(value) { if(this.avpBody != null){ if(value == false){ document.body.classList.remove("avp-showing"); this.avpBody.style.display = 'none'; } else { if(typeof AVPActions !== 'undefined' && typeof AVPActions.beforeShow == 'function') AVPActions.beforeShow(); } } this._show = value; } getAvpUserID(){ return window.avpuid || window.localStorage.getItem('avpuid'); } isAlreadyPassed(){ let ageGateStorageData = this.localStorageTest() === true && window.sessionStorage.getItem('ageGatePassed') != null ? window.sessionStorage.getItem('ageGatePassed') : window.localStorage.getItem('ageGatePassed'); let ageGateCookieData = this.localStorageTest() === true ? ageGateStorageData : this.getCookie('ageGatePassed'); let passThrough = /[?&]?(AvpPassThrough=1|avp=0)[^&?]*/gi.test(window.location.href); return ageGateCookieData; } checkForPassedData(){ if(window.location.href.includes("/wp-admin/")) { this.show = true; return false; } let ageGateStorageData = this.localStorageTest() === true && window.sessionStorage.getItem('ageGatePassed') != null ? window.sessionStorage.getItem('ageGatePassed') : window.localStorage.getItem('ageGatePassed'); let ageGateCookieData = this.localStorageTest() === true ? ageGateStorageData : this.getCookie('ageGatePassed'); let passThrough = /[?&]?(AvpPassThrough=1|avp=0)[^&?]*/gi.test(window.location.href); this.removePassedThroughParam(); if (!ageGateCookieData) { if(passThrough){ if(typeof AVPActions !== 'undefined' && typeof AVPActions.passedThrough == 'function') AVPActions.passedThrough(); if(typeof AVPActions !== 'undefined' && typeof AVPActions.passed == 'function') AVPActions.passed(); window.localStorage.setItem('avpuid', window.avpuid); this.setAgeGateData({ age: null, dateOfBirth: null, dateOfBirthString: null, passed: this.today.getFullYear() + '-' + (this.today.getMonth() + 1) + '-' + this.today.getDate() }); this.show = false; return true; } else { this.show = true; return false; } } else { ageGateCookieData = JSON.parse(ageGateCookieData); if(ageGateCookieData.tooYoung !== undefined && ageGateCookieData.tooYoung === true){ if(this.agegate_force_minor_redirect) { this.redirectTooYoung(); } this.show = true; return false; } window.localStorage.setItem('avpuid', window.avpuid); if(typeof AVPActions !== 'undefined' && typeof AVPActions.passed == 'function') AVPActions.passed(); this.show = false; return true; } } removePassedThroughParam(){ if (!Object.keys(this.params).length) return; let baseUrl = window.location.href.split('?')[0]; let paramStrings = []; Object.entries(this.params).forEach(([key, value]) => { if (key && key.toLowerCase() === 'avppassthrough') return; let param = key; if (value !== undefined) { param += '=' + encodeURIComponent(value); } paramStrings.push(param); }); let newUrl = baseUrl; if (paramStrings.length > 0) { newUrl += '?' + paramStrings.join('&'); } window.history.replaceState({}, '', newUrl); } calcAge(dateString) { const today = new Date(); const birthDate = new Date(dateString); let age = today.getFullYear() - birthDate.getFullYear(); if (today.getMonth() < birthDate.getMonth() || (today.getMonth() === birthDate.getMonth() && today.getDate() < birthDate.getDate())) { age--; } return age; } switchToInvalidField(){ for (let i = 0; i < this.inputOrder.length; i++){ const inputName = this.inputOrder[i]; if(!this.isInputValid(inputName) && this.isInputVisible(inputName)) { if(document.activeElement != null && document.activeElement.name != null && !this.isInputValidForSwitch(document.activeElement.name.toLowerCase())) return; this.showErrorMessageIfErrorsElseRemove(); this[inputName+'Input'].focus(); return; } } } hasVisableFieldsAValue(){ if ( (this.dateOfBirth.year == null) || ( (getComputedStyle(this.monthInput).display === 'block' || getComputedStyle(this.monthInput).display === 'inline-block') && this.dateOfBirth.month == null) || ( (getComputedStyle(this.dayInput).display === 'block' || getComputedStyle(this.dayInput).display === 'inline-block') && this.dateOfBirth.day == null) ) { return false; } else { return true; } } hasVisableFieldsValidInput(){ if ( (!this.validateYear()) || (this.isMonthInputVisible() && !this.validateMonth()) || (this.isDayInputVisible() && !this.validateDay()) ) { this.switchToInvalidField(); return false; } else { return true; } } verifyAge(submitClicked) { if (!this.hasVisableFieldsValidInput()) { return; } let dateOfBirthString = this.dateOfBirth.year !== null ? this.dateOfBirth.year : ''; dateOfBirthString += this.dateOfBirth.month !== null ? '-'+('0' + this.dateOfBirth.month).slice(-2) : '-01'; dateOfBirthString += this.dateOfBirth.day !== null ? '-'+('0' + this.dateOfBirth.day).slice(-2) : '-01'; let birthDate = new Date(dateOfBirthString); let age = this.calcAge(dateOfBirthString); this.isLegalThisYear = age == this.ldaRules.age; this.isLegalThisMonth = (this.today.getMonth() - birthDate.getMonth()) === 0; if (this.isLegalThisYear && !this.isMonthInputVisible()) { this.showMonthInput(); this.monthInput.focus(); return; } if (this.isLegalThisYear && this.isLegalThisMonth && !this.validateDay()) { this.showDayInput(); this.dayInput.focus(); return; } if (age >= this.ldaRules.age) { this.dateOfBirth.month = this.dateOfBirth.month != null ? ('0' + this.dateOfBirth.month).slice(-2) : this.dateOfBirth.month; this.dateOfBirth.day = this.dateOfBirth.day != null ? ('0' + this.dateOfBirth.day).slice(-2) : this.dateOfBirth.day; let passedDateOfBirthString = this.dateOfBirth.year+'-'+this.dateOfBirth.month+'-'+this.dateOfBirth.day; this.setAgeGateData({ age: age, dateOfBirth: this.dateOfBirth, dateOfBirthString: passedDateOfBirthString, passed: this.today.getFullYear() + '-' + String("0" + (this.today.getMonth() + 1)).slice(-2) + '-' + this.today.getDate() }); if(typeof AVPActions !== 'undefined' && typeof AVPActions.passed == 'function') AVPActions.passed(); if(!!Array.from(this.avpBody.querySelectorAll('input')).filter(a => a === document.activeElement).length){ document.activeElement.blur(); } this.show = false; } else { if(true === submitClicked && this.agegate_force_minor_redirect){ this.setAgeGateData({ age: age, tooYoung: true, dateOfBirth: this.dateOfBirth }); } if(typeof AVPActions !== 'undefined' && typeof AVPActions.tooYoung == 'function') { AVPActions.tooYoung(); } if(this.submitButton != null && (getComputedStyle(this.submitButton).display === 'block' || getComputedStyle(this.submitButton).display === 'inline-block') && submitClicked){ this.removeShow(); this.avpBody.querySelector('.agegate_tooyoung-message').classList.add('agegate_show'); this.redirectTooYoung(); } else if(this.submitButton != null) { this.submitButton.style.display = 'inline-block'; this.submitButton.style.fontSize = 'inherit'; } else { this.removeShow(); this.avpBody.querySelector('.agegate_tooyoung-message').classList.add('agegate_show'); } } } noDateInputValidation(agegate){ this.form = agegate.querySelector('form.agegate_content'); this.noAgeInputCheckbox = agegate.querySelector('[name="noAgeInputCheckbox"]').checked; if(!this.noAgeInputCheckbox){ this.avpBody.querySelector('.agegate_tooyoung-message').classList.add('agegate_show'); } else { let birthDate = new Date('1980-07-31T22:30:30Z'); let age = this.calcAge(birthDate); this.dateOfBirth.year = birthDate.getFullYear(); this.dateOfBirth.month = birthDate.getMonth(); this.dateOfBirth.day = birthDate.getDate(); let passedDateOfBirthString = this.dateOfBirth.year+'-'+this.dateOfBirth.month+'-'+this.dateOfBirth.day; this.setAgeGateData({ age: age, dateOfBirth: this.dateOfBirth, dateOfBirthString: passedDateOfBirthString, passed: this.today.getFullYear() + '-' + String("0" + (this.today.getMonth() + 1)).slice(-2) + '-' + this.today.getDate() }); if(typeof AVPActions !== 'undefined' && typeof AVPActions.passed == 'function') AVPActions.passed(); this.show = false; } } redirectTooYoung(){ setTimeout(() => { if(this.agegate_tooYoungWebsite != null && this.agegate_tooYoungWebsite !== ''){ window.location.href = this.agegate_tooYoungWebsite; } }, 1337); } removeShow(){ this.avpBody.querySelector('.agegate_tooyoung-message').classList.remove('agegate_show'); this.avpBody.querySelector('.agegate_field-error-message').classList.remove('agegate_show'); } isInputValid(input){ switch(input){ case 'year': case 'yyyy': return this.validateYear(); case 'month': case 'mm': return this.validateMonth(); case 'day': case 'dd': return this.validateDay(); } } isInputValidForSwitch(input){ switch(input){ case 'year': case 'yyyy': this.validateYear(); return this.validateYearForAutoFocus(); case 'month': case 'mm': this.validateMonth(); return this.validateMonthForAutoFocus(); case 'day': case 'dd': this.validateDay(); return this.validateDayForAutoFocus(); } } isInputVisible(input){ switch(input){ case 'year': case 'yyyy': return this.isYearInputVisible(); case 'month': case 'mm': return this.isMonthInputVisible(); case 'day': case 'dd': return this.isDayInputVisible(); } } isYearInputVisible(){ if(this.yearInputWrapper != null){ return getComputedStyle(this.yearInputWrapper).display === 'none' ? false : true; } else if(this.yearInput !== null){ return getComputedStyle(this.yearInput).display === 'none' ? false : true; } return false; } isMonthInputVisible(){ if(this.monthInputWrapper != null){ return getComputedStyle(this.monthInputWrapper).display === 'none' ? false : true; } else if(this.monthInput !== null) { return getComputedStyle(this.monthInput).display === 'none' ? false : true; } return false; } showMonthInput(){ if(this.monthInputWrapper != null){ this.monthInputWrapper.style.display = 'inline-block'; } else { this.monthInput.style.display = 'inline-block'; } } isDayInputVisible(){ if(this.dayInputWrapper != null){ return getComputedStyle(this.dayInputWrapper).display === 'none' ? false : true; } else if(this.dayInput !== null){ return getComputedStyle(this.dayInput).display === 'none' ? false : true; } return false; } showDayInput(){ if(this.dayInputWrapper != null){ this.dayInputWrapper.style.display = 'inline-block'; } else { this.dayInput.style.display = 'inline-block'; } } validateYearForAutoFocus(){ let year = Number(this.dateOfBirth.year); if (year !== null && year.toString().length === 4) { return true; } return false; } validateMonthForAutoFocus(){ let month = Number(this.dateOfBirth.month); if (month !== null && month > 0 && month < 13 && ['0','1'].indexOf(this.dateOfBirth.month) === -1) return true; return false; } validateDayForAutoFocus(){ let day = Number(this.dateOfBirth.day); if(day > 0 && day <= 31 && ['0','1','2','3'].indexOf(this.dateOfBirth.day) === -1) return true; return false; } validateYear(){ let year = Number(this.dateOfBirth.year); let ix = this.fieldErrors.indexOf('year'); if (ix > -1) { this.fieldErrors.splice(ix, 1); } if ( year !== null && year.toString().length === 4 && (year > (new Date().getFullYear() - 124) ) ) { return true; } else { if(this.dateOfBirth.year != null) this.fieldErrors.push('year'); return false; } } validateMonth(){ let month = Number(this.dateOfBirth.month); let ix = this.fieldErrors.indexOf('month'); if (ix > -1) { this.fieldErrors.splice(ix, 1); } if (month !== null && this.dateOfBirth.month !== '1' && month > 0 && month < 13) { return true; } else { if(this.dateOfBirth.month != null) this.fieldErrors.push('month'); } return false; } validateDay(){ let day = Number(this.dateOfBirth.day); let year = Number(this.dateOfBirth.year); let month = Number(this.dateOfBirth.month) || 12; let ix = this.fieldErrors.indexOf('day'); if (ix > -1) { this.fieldErrors.splice(ix, 1); } if(this.dateOfBirth.day != null && ['0', '1', '2', '3'].indexOf(this.dateOfBirth.day) !== -1){ this.fieldErrors.push('day'); return false; } if((!Number(this.dateOfBirth.year) || !Number(this.dateOfBirth.month))){ if(day > 0 && day <= 31){ return true; } if(this.dateOfBirth.day != null) { this.fieldErrors.push('day'); } return false; } if((month > 12 || month <= 0) && day > 0 && day <= 31){ return true; } if(day > 0 && day <= this.daysInMonth(month - 1, year)){ return true; } else { if(this.dateOfBirth.day != null) { this.fieldErrors.push('day'); } return false; } } daysInMonth(m, y){ switch (m) { case 1 : return (y % 4 == 0 && y % 100) || y % 400 == 0 ? 29 : 28; case 8 : case 3 : case 5 : case 10 : return 30; default : return 31; } } setAgeGateData(data){ let JSONData = JSON.stringify(data); if(this.localStorageTest() === true){ if(this.rememberMeInput.checked){ window.localStorage.setItem('ageGatePassed', JSONData); } else { window.sessionStorage.setItem('ageGatePassed', JSONData); } } else { this.setCookie('ageGatePassed', JSONData, 30, this.rememberMeInput.checked); } } setCookie(name, value, exdays, rememberMe) { let d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); let expires = "expires=" + d.toUTCString(); if(rememberMe) { expires = 'expires=""'; } document.cookie = name + "=" + value + ";" + expires + ";path=/"; } getCookie(name) { name += "="; let decodedCookie = decodeURIComponent(document.cookie); let ca = decodedCookie.split(';'); for (let i = 0; i < ca.length; i++) { let c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return null; } showErrorMessageIfErrorsElseRemove(){ const allInputs = [...this.form.querySelectorAll('input[name="year"],input[name="month"],input[name="day"]')]; for (let i = 0; i < allInputs.length; i++){ const ageGateInput = allInputs[i]; const inputName = ageGateInput.name; if(this.fieldErrors.indexOf(inputName) !== -1){ ageGateInput.classList.add('agegate_error'); } else { ageGateInput.classList.remove('agegate_error'); } } this.updateErrorMessage(); } updateErrorMessage(){ this.removeShow(); if(this.fieldErrorMessageEl != null && this.fieldErrors.length > 0){ const fieldTitles = this.fieldErrors.map(inputName => this[inputName+'Input'].title); let errorMessage = this.fieldErrorMessage.replace('{fields}', fieldTitles.join(' & ')); if(fieldTitles.length === 3){ errorMessage = errorMessage.replace(' &', ', '); } this.fieldErrorMessageEl.innerHTML = errorMessage.charAt(0).toUpperCase() + errorMessage.slice(1); this.fieldErrorMessageEl.classList.add('agegate_show'); } else if(this.fieldErrorMessageEl != null && this.fieldErrors.length == 0) { this.fieldErrorMessageEl.classList.remove('agegate_show'); } } removeInputError(inputName, force = false){ if(this.fieldErrors.indexOf(inputName) === -1 || force == true){ this[inputName+'Input'].classList.remove('agegate_error'); this.updateErrorMessage(); } } onAgeGateExist(agegate){ this.form = agegate.querySelector('form.agegate_content'); this.noAgeInputContainer = agegate.querySelector('.agegate_noAgeInputCheckbox'); this.noAgeInputCheckbox = agegate.querySelector('[name="noAgeInputCheckbox"]'); this.yearInput = agegate.querySelector('[name="year"]'); this.monthInput = agegate.querySelector('[name="month"]'); this.dayInput = agegate.querySelector('[name="day"]'); this.yearInputWrapper = agegate.querySelector('.age-gate__year-input-wrapper'); this.monthInputWrapper = agegate.querySelector('.age-gate__month-input-wrapper'); this.dayInputWrapper = agegate.querySelector('.age-gate__day-input-wrapper'); this.rememberMeContainer = agegate.querySelector('.agegate_rememberMe'); this.rememberMeHelp = agegate.querySelector('.agegate_rememberMeHelp'); this.rememberMeInput = agegate.querySelector('input[name="rememberMe"]'); this.fieldErrorMessageEl = agegate.querySelector('.agegate_field-error-message'); if(this.fieldErrorMessageEl != null) { this.fieldErrorMessage = this.fieldErrorMessageEl.innerHTML; } this.submitButton = agegate.querySelector('.agegate_submit'); this.log('Display management'); if(this.agegate_no_age_input){ this.displayNoAgeInputFields(agegate); } else { this.displayAgeInputFields(agegate); } } displayNoAgeInputFields(agegate){ if(null!== this.noAgeInputContainer){ this.noAgeInputContainer.style.display = 'block'; } this.yearInput.style.display = 'none'; this.monthInput.style.display = 'none'; this.dayInput.style.display = 'none'; this.rememberMeContainer.style.display = 'block'; this.rememberMeHelp.style.display = 'block'; this.submitButton.style.display = 'inline-block'; this.submitButton.addEventListener('click', (e) => { e.preventDefault(); this.noDateInputValidation(agegate); }); } displayAgeInputFields(agegate){ const allNumberInputs = [...agegate.querySelectorAll('input[name="year"],input[name="month"],input[name="day"]')]; if(null!== this.noAgeInputContainer){ this.noAgeInputContainer.style.display = 'none'; } this.yearInput.style.display = 'inline-block'; this.monthInput.style.display = 'inline-block'; this.dayInput.style.display = 'inline-block'; this.rememberMeContainer.style.display = 'block'; this.rememberMeHelp.style.display = 'block'; this.submitButton.style.display = 'inline-block'; this.submitButton.removeEventListener('click', (e) => { e.preventDefault(); this.noDateInputValidation(agegate); }); if(!this.full){ if(null!==this.monthInput){ this.monthInput.style.display = 'none'; } if(null!==this.dayInput){ this.dayInput.style.display = 'none'; } if(null!==this.submitButton){ this.submitButton.style.display = 'none'; } } this.log('Event listeners'); this.log(this.form); if (this.form != null){ this.form.addEventListener('submit', (e) => { e.preventDefault(); this.verifyAge(true); }); } let inputIx = 1; for (let i = 0; i < allNumberInputs.length; i++){ if(allNumberInputs[i] != null && ( getComputedStyle(allNumberInputs[i]).display == 'block' || getComputedStyle(allNumberInputs[i]).display == 'inline-block' ) && typeof allNumberInputs[i].focus == 'function' && !agegate_isMobileTablet()){ setTimeout(() => { allNumberInputs[i].focus(); }, 1); break; } } for (let i = 0; i < allNumberInputs.length; i++){ const ageGateInput = allNumberInputs[i]; const inputName = ageGateInput.name; ageGateInput.addEventListener('input', (e) => { this.dateOfBirth[inputName] = e.target.value == '' ? null : e.target.value; let fieldsAreValid = this.hasVisableFieldsValidInput(); this.removeInputError(inputName); if(!fieldsAreValid || !this.hasVisableFieldsAValue()) this.submitButton.setAttribute('disabled', ''); if (fieldsAreValid){ this.submitButton.disabled = false; this.verifyAge(); } }); ageGateInput.addEventListener('focusout', (e) => { if(this.fieldErrors.indexOf(inputName) !== -1){ this.showErrorMessageIfErrorsElseRemove(); } }); ++inputIx; } } loadLang(e = null, thisObj = null){ var url = "$langfile_url"; var storage_name = "$storage_name"; if(e != null){ e.preventDefault(); e.stopPropagation(); url += '?l='+e.target.value; url += '&s='+storage_name; }else{ url += '?s='+storage_name; } var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.onload = function(){ if (xhr.status == 200) { var responseData = JSON.parse(xhr.responseText); if(thisObj != null){ thisObj.setLda(responseData.ldaRules); this.log(thisObj.full); thisObj.avpBody.querySelector('.agegate_tooyoung-message').classList.remove('agegate_show'); if(thisObj.full){ if(null!==thisObj.monthInput){ thisObj.monthInput.style.display = 'inline-block'; } if(null!==thisObj.dayInput){ thisObj.dayInput.style.display = 'inline-block'; } if(null!==thisObj.submitButton){ thisObj.submitButton.style.display = 'inline-block'; } } else { if(null!==thisObj.monthInput){ thisObj.monthInput.style.display = 'none'; } if(null!==thisObj.dayInput){ thisObj.dayInput.style.display = 'none'; } if(null!==thisObj.submitButton){ thisObj.submitButton.style.display = 'none'; } } thisObj.monthInput.value = ''; thisObj.dayInput.value = ''; thisObj.yearInput.value = ''; } var ageGateElement = document.getElementById('pr_age_gate'); if (ageGateElement) { ageGateElement.setAttribute('data-lang', responseData.lang); } if(null!==document.querySelector('.agegate_change_country')){ document.querySelector('.agegate_change_country').selectedIndex = responseData.lang; } for (var key in responseData.content) { if(key != 'rememberMe'){ var element = document.querySelector('#pr_age_gate .agegate_' + key); } else { var element = document.querySelector('#pr_age_gate .agegate_' + key +' span'); } if (element) { switch(contentType){ case 'innerHTML': element.innerHTML = responseData.content[key]; break; case 'value': element.value = responseData.content[key]; break; case 'placeholder': element.placeholder = responseData.content[key]; break; } } } } }; xhr.send(); } async getActiveUserInfo(){ this.log('-- getActiveUserInfo'); let url = 'https://age-gate-static.pernod-ricard.io/geolocation.json'; /*let url = '/geolocation.json';*/ this.log(url); var response = await fetch(this.addCacheBusterParam(url)); this.user_country_json = await response.json(); this.log('Response ok'); this.log(this.user_country_json); this.setActiveLangCountry(this.user_country_json["cloudfront-viewer-country-code"]); this.loadJson(); } addCacheBusterParam(url){ const cacheBuster = `cb=${Date.now()}`; const separator = url.includes('?') ? '&' : '?'; return `${url}${separator}${cacheBuster}`; } async loadJson(){ this.log('-- loadJson'); /*let url = 'https://age-gate-static.pernod-ricard.io/content_.json';*/ let url = this.agegate_cached_content_file; this.log(url); var response = await fetch(this.addCacheBusterParam(url), { headers: { 'Content-Type': 'application/json', 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0' } }); this.json_content = await response.json(); if (!window.location.search.includes('force_age_gate_lang')) { this.checkUserLang(); } } getMyCountry(){ return this.user_country_json["cloudfront-viewer-country-code"].toLowerCase(); } getActiveLangCountry(){ if(this.getActiveLang() != this.getActiveCountry()){ return this.getActiveLang().toLowerCase() + '-' + this.getActiveCountry().toLowerCase(); } else { return this.getActiveCountry().toLowerCase(); } } getActiveCountry(){ return this.activeCountry; /*return this.json_content.country.toLowerCase();*/ } getActiveLang(){ return this.activeLanguage; /*return this.json_content.lang.toLowerCase();*/ } getCountry(){ return this.user_country_json["cloudfront-viewer-country-code"].toLowerCase(); /*return this.json_content.country;*/ } setActiveCountry(country){ this.log('-- setActiveCountry to :'); this.log(country); this.json_content.country = country; this.activeCountry = country; } setActiveLang(lang){ this.log('-- setActiveLang to :'); this.log(lang); this.json_content.lang = lang; this.activeLanguage = lang; } setActiveLangCountry(langCountry){ this.log('-- setActiveLangCountry :'); this.log('Param given : ' + langCountry); langCountry = langCountry.replace(/_/g, '-').toLowerCase().split('-'); this.log('After split : '); this.log(langCountry); if(langCountry.length > 1){ this.setActiveLang(langCountry[0]); this.setActiveCountry(langCountry[1]); } else { this.setActiveLang(langCountry[0]); this.setActiveCountry(langCountry[0]); } } getLdaRules(){ return this.json_content.ldaRules; } getNoAgeGateSlug(){ return this.json_content.noAgegateSlug; } getTranslations(){ return this.json_content.contents; } getMyLda(lang = null){ let myCountryHere = this.getCountry(); if(lang != null){ myCountryHere = lang; } return this.json_content.ldaRules[myCountryHere]; } checkIfBan(){ this.log('-- checkIfBan'); if(this.getMyLda().age >= 99){ this.log('You are banned'); return true; } else { this.log('You are not banned'); return false; } } checkIfLangChange(){ if(this.getMyLda().name != this.ldaRules.name){ this.log('Need to change LdaRules'); return true; } else { return false; } } replacePatterns(content){ return content.replace("{age}", this.getMyLda().age); } updateInterfaceWithNewLang(){ this.log('-- updateInterfaceWithNewLang'); let translationIndex = ''; let translationTempIndex = this.getActiveLangCountry(); let myTranslations = this.getTranslations(); this.log(myTranslations); this.log('check if ' + translationTempIndex); let forceShowCountrySelector = false; /* check translation lang-country */ if(myTranslations[translationTempIndex] == undefined){ this.log('No translation for lang-country'); /* check translation browser lang - country */ const browserLanguage = navigator.language || navigator.userLanguage; const languageOnly = browserLanguage.split('-')[0].toLowerCase(); this.log('check if '+languageOnly+'-'+this.getActiveCountry()); if(myTranslations[languageOnly+'-'+this.getActiveCountry()] != undefined){ translationIndex = languageOnly+'-'+this.getActiveCountry(); forceShowCountrySelector = true; } else { this.log('No translation for browserlang-country'); this.log('check if '+this.getActiveCountry()); /* check translation only country */ if(myTranslations[this.getActiveCountry()] == undefined){ this.log('No translation for country'); for (let key in myTranslations) { if(translationIndex == ''){ this.log('check if '+key+' contains '+this.getActiveCountry()); this.log(key.endsWith(this.getActiveCountry())); if(key.endsWith(this.getActiveCountry())) { this.log(key+' index is ok'); translationIndex = key; forceShowCountrySelector = true; } } } } else { this.log('Translation for country'); translationIndex = this.getActiveCountry(); forceShowCountrySelector = true; } } } else { translationIndex = translationTempIndex; } if(translationIndex == ''){ translationIndex = 'generic'; } this.log('translationIndex : ' + translationIndex); myTranslations = myTranslations[translationIndex]; this.log(myTranslations); this.avpBody.querySelector('.agegate_tooyoung-message').classList.remove('agegate_show'); if(this.full){ if(null!==this.monthInput){ this.monthInput.style.display = 'inline-block'; } if(null!==this.dayInput){ this.dayInput.style.display = 'inline-block'; } if(null!==this.submitButton){ this.submitButton.style.display = 'inline-block'; } } else { if(null!==this.monthInput){ this.monthInput.style.display = 'none'; } if(null!==this.dayInput){ this.dayInput.style.display = 'none'; } if(null!==this.submitButton){ this.submitButton.style.display = 'none'; } } this.monthInput.value = ''; this.dayInput.value = ''; this.yearInput.value = ''; var ageGateElement = document.getElementById('pr_age_gate'); if (ageGateElement) { ageGateElement.setAttribute('data-lang', translationIndex); } if(forceShowCountrySelector || this.allow_switch_language == true){ document.querySelector('.agegate_countrySelector').style.display = 'block'; this.log('country selector displayed'); } else { document.querySelector('.agegate_countrySelector').style.display = 'none'; this.log('country selector not displayed'); } if(null!==document.querySelector('#agegate_change_country')){ /*let newIndex = this.getActiveCountry(); if(this.getActiveCountry() != this.getActiveLang()){ newIndex = this.getActiveLang() + '-' + this.getActiveCountry(); } */ document.querySelector('#agegate_change_country').value = translationIndex; this.log('Selected index : '); this.log(translationIndex); } if(myTranslations['no-age-input'] != undefined && myTranslations['no-age-input'] == 'ok'){ this.displayNoAgeInputFields(ageGateElement); } else { this.displayAgeInputFields(ageGateElement); } for (var key in myTranslations) { if(key != 'no_age_input'){ var contentType = 'innerHTML'; switch(key){ case 'rememberMe': case 'countrySelector': var element = document.querySelector('#pr_age_gate .agegate_' + key +' span'); break; case 'submit': contentType = 'value'; var element = document.querySelector('#pr_age_gate .agegate_' + key); break; case 'inputYear': case 'inputMonth': case 'inputDay': contentType = 'placeholder'; var inputTypeName = key.replace('input', ''); inputTypeName = inputTypeName.charAt(0).toLowerCase() + inputTypeName.slice(1); var element = document.querySelector('#pr_age_gate input[name="' + inputTypeName + '"]'); break; default: var element = document.querySelector('#pr_age_gate .agegate_' + key +''); break; } if (element) { let thisFieldTranslation = this.replacePatterns(myTranslations[key]); if(key == 'noAgeInputCheckbox'){ let noAgeInputCheckboxChecked = ''; if(myTranslations['no-age-input-checked'] != null && myTranslations['no-age-input-checked'] == 'ok'){ noAgeInputCheckboxChecked = 'checked="checked"'; this.log('No age input checked'); } thisFieldTranslation = '<input type="checkbox" name="noAgeInputCheckbox" class="noAgeInputCheckbox" value="ok" '+noAgeInputCheckboxChecked+' />' + thisFieldTranslation; } thisFieldTranslation = thisFieldTranslation.replace(/<\/?pre>/g, ''); switch(contentType){ case 'innerHTML': element.innerHTML = thisFieldTranslation; break; case 'value': element.value = thisFieldTranslation; break; case 'placeholder': element.placeholder = thisFieldTranslation; break; } } } } } checkUserLang(){ this.log('-- checkUserLang'); this.log('getMyCountry : '); this.log(this.getMyCountry()); this.log('getNoAgeGateSlug : '); this.log(this.getNoAgeGateSlug()); this.log('getTranslations : '); this.log(this.getTranslations()); this.log('getLdaRules : '); this.log(this.getLdaRules()); this.log('getMyLda : '); this.log(this.getMyLda()); if(this.checkIfBan()){ this.showBanned(); } else { if(this.checkIfLangChange()){ this.setLda(this.getMyLda()); this.setActiveCountry(this.getMyCountry()); this.updateInterfaceWithNewLang(); } } } showBanned(){ document.querySelector('#pr_age_gate .agegate_top').style.display = 'none'; document.querySelector('#pr_age_gate .agegate_middle').style.display = 'none'; document.querySelector('#pr_age_gate .agegate_bottom').style.display = 'none'; document.querySelector('#pr_age_gate .agegate_banned').style.display = 'block'; document.querySelector('#pr_age_gate .agegate_countrySelector').remove(); } initMutationObserver(){ var ageGateObserver = new MutationObserver((mutations, me) => { var agegate = document.getElementById('pr_age_gate'); var agegateYear = document.querySelector('#pr_age_gate input[name="year"]'); if (agegate != null && agegateYear != null) { var thisObj = this; /* && document.querySelector('select#agegate_change_country')*/ if (!window.location.search.includes('force_age_gate_lang')) { /*thisObj.loadLang(null, thisObj);*/ /*thisObj.loadLang2(null, thisObj);*/ } if(document.querySelector("select[name='agegate_change_country']") != null){ const self = this; document.querySelector("select[name='agegate_change_country']").addEventListener("change", function(e){ self.log('-----------'); self.log('change country to :'); self.log(this.value); self.setActiveLangCountry(this.value); self.log('New LDA : '); self.log(self.getMyLda(self.json_content.country)); self.setLda(self.getMyLda(self.json_content.country)); self.updateInterfaceWithNewLang(); }); } this.avpBody = agegate; this.onAgeGateExist(agegate); this.checkForPassedData(); me.disconnect(); return; } }); ageGateObserver.observe(document, { childList: true, subtree: true }); } }

function injectAgeGate() {
    // generic
let agegate_tooYoungWebsite = 'https://www.wise-drinking.com';
let agegate_ldarule = JSON.parse('{"name":"Generic","countrycode":"generic","age":21,"langCodes":["generic"],"languages":["English"],"format":"yyyy-mm-dd","full":false}');
let agegate_force_minor_redirect = true;
let allow_switch_language = false;
let allowedSlugsWithoutAgeGate = [''];

let agegate_user_country = 'generic';
if (typeof gcms_user_country === 'undefined') {
    let gcms_user_country = agegate_user_country;
}
let agegate_user_country_language = navigator.language || navigator.userLanguage;
let agegate_no_age_input = false;

let cached_content_file = '/wp-content/uploads/agegate/agegate_content.json';
let cached_script_file = '/wp-content/uploads/agegate/agegate_script.js';

    // Launch age gate
    let agegateOptions = { agegate_ldarule: agegate_ldarule, agegate_tooYoungWebsite: agegate_tooYoungWebsite, agegate_force_minor_redirect: agegate_force_minor_redirect, agegate_no_age_input: agegate_no_age_input, cached_content_file: cached_content_file, allow_switch_language: allow_switch_language, allowedSlugsWithoutAgeGate: allowedSlugsWithoutAgeGate};let noAgeGateToDisplay = false; let currentPath = document.location.pathname;if(currentPath != '/' && allowedSlugsWithoutAgeGate.length > 0){ if (currentPath.startsWith('/')) { currentPath = currentPath.slice(1); } if (currentPath.endsWith('/')) { currentPath = currentPath.slice(0, -1); } for (let i = 0; i < allowedSlugsWithoutAgeGate.length; i++) { let testedUrl = allowedSlugsWithoutAgeGate[i]; if (testedUrl.startsWith('/')) { testedUrl = testedUrl.slice(1); } if (testedUrl.endsWith('/')) { testedUrl = testedUrl.slice(0, -1); } if (currentPath == testedUrl) { noAgeGateToDisplay = true; } }}if(!noAgeGateToDisplay){ window.AVP = new AVP(agegateOptions);}

    // Add styles
    const style = document.createElement('style');
    style.textContent = `#pr_age_gate, #pr_age_gate * {font-family: Arial, Helvetica, Sans-Serif;} #pr_age_gate * {color:#000000;} #pr_age_gate:target {display: block;} #pr_age_gate .agegate_overlay {background-color: rgba(0, 0, 0, 0.5);position: fixed;top: 0px;left: 0px;right: 0px;bottom: 0px;color: transparent;} #pr_age_gate .agegate_dialog {background-color: white;max-width: 900px;width:90%;overflow:hidden;} #pr_age_gate .agegate_dialog .agegate_content {padding: 20px;} #pr_age_gate .agegate_dialog.agegate_center-fix-xy {position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%);}#pr_age_gate p {line-height: unset;margin: unset;} #pr_age_gate .agegate_relative{position:relative;} #pr_age_gate .agegate_inputs_container {} #pr_age_gate .agegate_inputs_container input {display:block; margin:0 auto} #pr_age_gate .agegate_top, #pr_age_gate .agegate_middle, #pr_age_gate .agegate_text {text-align: center;} #pr_age_gate .agegate_banned {text-align: center;display:none;} #pr_age_gate .agegate_bottom {text-align: center;margin-bottom:20px;} #pr_age_gate .age-gate_input {padding: 5px;border-radius: 2px;border-color: rgba(0,0,0,.15);color: #373737;height:40px;border-width:1px;} #pr_age_gate .agegate_field-error-message.agegate_show, #pr_age_gate .agegate_tooyoung-message.agegate_show{display:block;} #pr_age_gate .agegate_field-error-message{display:none;} #pr_age_gate .agegate_tooyoung-message{display:none;} #pr_age_gate .agegate_submit,#pr_age_gate .agegate_submit:hover,#pr_age_gate .agegate_submit:active,#pr_age_gate .agegate_submit:focus {border: none;outline:none;padding:8px;font-size:12px;display:inline-block;height:40px;cursor: pointer;} #pr_age_gate #avp-field-error-message, #pr_age_gate #tooyoung-message{display:none;width:auto;padding:5px 10px;margin:0 auto;z-index:2;background:#e15959;color:#fff;transition:all .28s ease;transform:translate3d(0,-10px,0) scale(.9)} #pr_age_gate #avp-field-error-message.agegate_show,#pr_age_gate #tooyoung-message.agegate_show{display:block;} #pr_age_gate #avp-field-error-message:before,#pr_age_gate #tooyoung-message:before{content:"";display:block;position:absolute;top:-4px;margin:0 auto;left:0;right:0;width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-bottom:5px solid #e15959} #pr_age_gate .agegate_change_country{position:absolute;right:10px;bottom:10px;} #pr_age_gate .agegate_change_country select {width:170px;margin:0 5px;} #pr_age_gate .agegate_banned_title {font-size: 24px;font-weight: bold;margin: 20px 0;} #pr_age_gate .agegate_banned_message {font-size: 18px;;margin: 20px 0;} #pr_age_gate .agegate_banned_terms-title {font-size: 16px;font-weight: bold;;margin: 20px 0;} #pr_age_gate .agegate_banned_term-content {font-size: 14px;width: 100%;height: 500px;overflow: auto;padding:15px;} @media only screen and (max-width: 400px) { #pr_age_gate .agegate_dialog .agegate_content{padding:5px !important;} #pr_age_gate .agegate_logo{max-width:40% !important;} #pr_age_gate .agegate_over18 {font-size:15px !important;line-height:15px !important;margin:20px 0 !important;} #pr_age_gate .agegate_subtitle {font-size:15px !important;line-height:15px !important;margin:20px 0 !important;} #pr_age_gate .agegate_rememberMeHelp {margin-bottom:5px !important;} #pr_age_gate .agegate_rememberMe {margin:5px 0 !important;} #pr_age_gate .agegate_generalConditionsTitle {font-size:12px !important;line-height:12px !important;} #pr_age_gate .agegate_generalConditions, #pr_age_gate .agegate_generalConditions p, #pr_age_gate .agegate_generalConditions p a {font-size:9px !important;line-height:9px !important;} } @media (min-width: 401px) and (max-width: 576px) { #pr_age_gate .agegate_dialog .agegate_content{padding:5px !important;} #pr_age_gate .agegate_logo{max-width:80% !important;} #pr_age_gate .agegate_over18 {font-size:18px !important;line-height:18px !important;margin:20px 0 !important;} #pr_age_gate .agegate_subtitle {font-size:18px !important;line-height:18px !important;margin:20px 0 !important;} #pr_age_gate .agegate_rememberMe {margin:20px 0 !important;} #pr_age_gate .agegate_generalConditions, #pr_age_gate .agegate_generalConditions p, #pr_age_gate .agegate_generalConditions p a {font-size:10px !important;line-height:10px !important;} } @media (min-width: 680px) { #pr_age_gate .agegate_inputs_container input {display:inline-block;} } #pr_age_gate .agegate_content div:empty, #pr_age_gate .agegate_content p:empty, #pr_age_gate .agegate_content span:empty {display: none;} #pr_age_gate {position:relative;z-index: 9999 !important;}#pr_age_gate, #pr_age_gate * {font-family: Trebuchet MS, Helvetica, Sans-Serif;}#pr_age_gate .agegate_overlay {background-color: rgba(0,0,0,0.5);}#pr_age_gate .agegate_dialog {max-width:860px;}#pr_age_gate .agegate_dialog {background-color: #ffffff;border: 0px solid #000000}#pr_age_gate .agegate_logo {width:400px;height:auto;}#pr_age_gate .agegate_rememberMe span {font-size:15px; color:#000000}#pr_age_gate .age-gate_input {border-style: solid;width:150px;height:40px;}#pr_age_gate .age-gate_input {background-color:#ffffff;}#pr_age_gate .age-gate_input {color:#000000;}#pr_age_gate .age-gate_input {::placeholder: ;::-ms-input-placeholder: ;}#pr_age_gate .age-gate_input {border-color:#000000;}#pr_age_gate .age-gate_input {border-width:1px;}#pr_age_gate .agegate_inputs_container input.noAgeInputCheckbox {margin-right:10px;}#pr_age_gate .agegate_submit,#pr_age_gate .agegate_submit:hover,#pr_age_gate .agegate_submit:active,#pr_age_gate .agegate_submit:focus {background-color:#000000;}#pr_age_gate .agegate_submit,#pr_age_gate .agegate_submit:hover,#pr_age_gate .agegate_submit:active,#pr_age_gate .agegate_submit:focus {border: 1px solid #000000;}#pr_age_gate .agegate_submit,#pr_age_gate .agegate_submit:hover,#pr_age_gate .agegate_submit:active,#pr_age_gate .agegate_submit:focus {color:#ffffff;}#pr_age_gate .agegate_submit,#pr_age_gate .agegate_submit:hover,#pr_age_gate .agegate_submit:active,#pr_age_gate .agegate_submit:focus {font-size:12px;}#pr_age_gate .agegate_change_country{position:absolute;right:10px;bottom:10px;}#pr_age_gate .agegate_change_country span {line-height:14px;font-size:14px;color:#000000;}#pr_age_gate .agegate_change_country select {height:40px;width:150px;border-width:1px;border-color:#000000;color:#000000;background-color:#ffffff;}#pr_age_gate .agegate_over18, #pr_age_gate .agegate_over18 p, #pr_age_gate .agegate_over18 p a {color: #000000;font-size: 23px;margin-top: 30px;margin-bottom: 30px;line-height: 23px;}#pr_age_gate .agegate_subtitle, #pr_age_gate .agegate_subtitle p, #pr_age_gate .agegate_subtitle p a {color: #000000;font-size: 23px;margin-top: 30px;margin-bottom: 40px;line-height: 23px;}#pr_age_gate .agegate_rememberMe, #pr_age_gate .agegate_rememberMe p, #pr_age_gate .agegate_rememberMe p a {color: #000000;font-size: 15px;margin-top: 40px;margin-bottom: 1px;line-height: 15px;}#pr_age_gate .agegate_rememberMeHelp, #pr_age_gate .agegate_rememberMeHelp p, #pr_age_gate .agegate_rememberMeHelp p a {color: #000000;font-size: 12px;margin-top: 2px;margin-bottom: 50px;line-height: 12px;}#pr_age_gate .agegate_noAgeInputCheckbox, #pr_age_gate .agegate_noAgeInputCheckbox p, #pr_age_gate .agegate_noAgeInputCheckbox p a {color: #000000;font-size: 23px;margin-top: 30px;margin-bottom: 30px;line-height: 23px;}#pr_age_gate .agegate_generalConditionsTitle, #pr_age_gate .agegate_generalConditionsTitle p, #pr_age_gate .agegate_generalConditionsTitle p a {color: #000000;font-size: 14px;margin-top: 17px;margin-bottom: 1px;line-height: 14px;}#pr_age_gate .agegate_generalConditions, #pr_age_gate .agegate_generalConditions p, #pr_age_gate .agegate_generalConditions p a {color: #000000;font-size: 12px;margin-top: 1px;margin-bottom: 1px;line-height: 12px;}`;
    document.head.appendChild(style);

    // Add html content
    const ageGateContainer = document.createElement('div');
    ageGateContainer.setAttribute('id', 'pr_age_gate');
    ageGateContainer.setAttribute('data-lang', 'generic');
    ageGateContainer.innerHTML = `
        
        <span class="agegate_overlay"></span>
        <div class="agegate_center-fix-xy agegate_dialog">
            <form method="post" class="agegate_content agegate_relative">
                <div class="agegate_content">
                    <div class="agegate_top"><span id="agegate_logo_container"><svg class="agegate_logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1023.76 398.06"><path d="M492.1 0a134.08 134.08 0 0 0-34.78 10.32l19.1 40.9a199.8 199.8 0 0 1 11.66 46.25 58.83 58.83 0 0 1 21.4-6.3 238.18 238.18 0 0 0-4.77-46.44C498.78 17.12 492.1 0 492.1 0zM532 0s-6.7 17.12-12.6 44.72a229.09 229.09 0 0 0-4.59 46.44 58.05 58.05 0 0 1 21.2 6.3 199.8 199.8 0 0 1 11.7-46.25c6.42-16.4 19.1-40.9 19.1-40.9A134.26 134.26 0 0 0 532 0zM430.74 26.37a134.56 134.56 0 0 0-26 26.18s20.5 9 35.55 23.5C460.86 96 468.2 116 468.2 116a51.63 51.63 0 0 1 14.91-15.47s-7.7-24.14-20.06-41.86-32.28-32.3-32.28-32.3zm162.82 0s-20.1 14.63-32.5 32.3S541 100.52 541 100.52A52.2 52.2 0 0 1 555.92 116s7.32-20 27.9-39.94c15-14.53 35.55-23.5 35.55-23.5a134.2 134.2 0 0 0-25.81-26.18zM390.8 76.26a130.64 130.64 0 0 0-10.52 35.34s18.3-2 44.52 8a117.3 117.3 0 0 1 35.73 21.79 50.91 50.91 0 0 1 4.41-19.11s-6.95-13-27.34-26.94c-21.9-15-46.82-19.1-46.82-19.1zm242.5 0s-24.93 4.1-46.82 19.1c-20.36 14-27.33 26.93-27.33 26.93a53.58 53.58 0 0 1 4.4 19.11 117 117 0 0 1 35.74-21.78c26.3-10 44.52-8 44.52-8a130.84 130.84 0 0 0-10.52-35.35z" fill="#4395d1"/><path d="M403 132.24c-15.56-.06-24.28 2.87-24.28 2.87a129.54 129.54 0 0 0 6.11 36.12 105.16 105.16 0 0 1 37.85-9.55c26.2-1.26 44.15 5.74 44.15 5.74a51.15 51.15 0 0 1-5.93-19.49s-20.9-11.77-40.1-14.34a141.12 141.12 0 0 0-17.8-1.34zm218 0a139.3 139.3 0 0 0-17.77 1.35c-19.2 2.56-39.93 14.33-39.93 14.33a50.89 50.89 0 0 1-6.12 19.5s17.94-7 44.15-5.73a105.39 105.39 0 0 1 37.84 9.55 131.09 131.09 0 0 0 6.12-36.11s-8.7-2.94-24.28-2.88zm-176.7 40.7a96.71 96.71 0 0 0-13.76 1.71c-26.7 5.38-38.4 14.7-38.4 14.7a133 133 0 0 0 20.45 30.58s11-10.45 30-19.5c25.7-12.24 51.8-9.75 51.8-9.75a51.55 51.55 0 0 1-23.12-16.81 168.5 168.5 0 0 0-26.94-1zm122.3 0l-13.76.95a51.7 51.7 0 0 1-22.93 16.82s25.9-2.45 51.6 9.75c19 9 30 19.56 30 19.56a133.25 133.25 0 0 0 20.64-30.57s-11.9-9.33-38.6-14.7c-8.82-1.84-19-2-26.95-1.72zM512.15 193c-54.43 0-86.15 39.93-86.15 39.93a134.37 134.37 0 0 0 32.1 20s16.5-32.48 54.1-32.48S566 253 566 253a133.39 133.39 0 0 0 32.1-20.06S566.52 193 512.15 193zM0 289.9v9.93h13.58v86.38H0v9.8h37.65v-9.75H24.28v-32.1h20.06c9.94 0 18-1.34 25.6-8.6a32.37 32.37 0 0 0 10.12-23.89 31 31 0 0 0-12-24.84c-7.34-5.34-15.9-6.88-24.65-6.88zm473 0v9.17h13v36.87c-6.24-12.23-18.8-19.3-32.3-19.3-21.67 0-39.75 18.65-39.75 40.33a44.44 44.44 0 0 0 6.69 22.55c6.82 10.82 21.12 18.53 33.45 18.53a36.33 36.33 0 0 0 31.9-18.53V396h22.93v-9.18h-13.2V289.9H473zm84.85 0v9.93h13.55v86.38h-13.58v9.8h36.87v-9.75h-12.6v-86.42h20.82c8 0 14.8.14 21 5.93a25.8 25.8 0 0 1 8 19.3 24.89 24.89 0 0 1-11.85 21.21c-7 4.3-14.72 4-22.75 4h-4L626.23 396h20.64v-9.74h-14.14l-22.17-29.05c18.1 0 32.1-14.72 32.1-32.68a34.33 34.33 0 0 0-12-26.75c-8.16-7-16.72-7.83-26.94-7.83h-45.9zm111 0v15.28h9.74V289.9zm319.14 0v9.17h13v36.87c-6.24-12.23-18.8-19.3-32.3-19.3-21.66 0-39.93 18.65-39.93 40.33 0 7.72 2.87 16.17 6.88 22.55 6.83 10.82 21.12 18.53 33.45 18.53a36.34 36.34 0 0 0 31.9-18.53V396h22.75v-9.18h-13V289.9H988zm-963.7 9.93H43.2c6.83 0 12.13.66 17.77 5a22.31 22.31 0 0 1 .38 34.59c-5.33 4.45-11.28 5-18 5H24.28v-44.6zm97.27 16.8c-22.56 0-40.13 19-40.13 41.1a40.71 40.71 0 0 0 77.78 16.44h-10.32c-5.64 9.8-15.9 15.1-27.13 15.1-16 0-29.7-12.66-30.58-28.66h71.28v-3.06c0-23-17.73-40.9-40.9-40.9zm157.46 0c-10.68 0-21.28 5.26-26.17 14.9V318H229.9v9.17h13.18v59.62H229.9v9.2h35.92v-9.18h-13V354.3c0-7.34.12-13.94 5.16-19.87a24.49 24.49 0 0 1 18.34-8c7.43 0 16.1 2.1 20.26 9.36 3.57 6.1 3.83 12.84 3.83 19.87v31.15h-13.2v9.2h35.93v-9.18h-13V352a46.74 46.74 0 0 0-4.4-20.45c-5.05-10.24-18-14.9-26.76-14.9zm86.2 0a40.71 40.71 0 1 0 40.51 40.14c0-22-18.35-40.13-40.52-40.13zm364.62 0c-11.28 0-21.07 4.87-28.48 12.42a41 41 0 0 0-11.46 28.67c0 21.83 18.2 40.32 40.32 40.32 17.12 0 32.83-10.38 38.6-26.57h-10.9c-4.6 10.38-15.63 16.64-26.75 16.64-17.52 0-31.34-13.2-31.34-30.58s13.35-31.15 30.57-31.15a31.76 31.76 0 0 1 26.76 15.11h9.17V318h-9.17v11.1a35.63 35.63 0 0 0-27.34-12.42zm83.5 0c-14.1 0-27.5 7.07-33.8 18.35-3.27 5.78-6.5 11-6.5 22.36-.3 8.6 2.45 16 6.3 22.35 6.84 11.3 19.77 18.35 34 18.35a36 36 0 0 0 31.92-18.35V396h22.57v-9.18H855v-59.66h12.8V318h-22.55v17c-7.12-11.86-17.73-18.35-31.92-18.35zM167.8 318v9.17H181v59.62h-13.2v9.2h35.92v-9.18h-13v-31.38c0-16.62 7.62-26.8 24.85-28.28V318c-11.13.44-21.28 5-24.84 15.86V318zm488.07 0v9.17h13v59.62h-13.38v9.2h36.12v-9.18h-13V318h-22.74zm222.44 0v9.17h13.18v59.62H878.3v9.2h35.92v-9.18h-13v-31.38c0-16.62 7.63-26.8 24.85-28.28V318c-11.13.44-21.28 5-24.84 15.86V318zm-756.94 7.64c15.88 0 29.68 11 31.92 26.95H91.15c1.84-14.7 15.2-26.95 30.2-26.95zm333.85.4a31 31 0 0 1 31.15 31c0 17.5-13.63 31.72-31.15 31.72-17.12 0-31.53-13.94-31.53-31.15a31.5 31.5 0 0 1 31.46-31.6zM970 326a31 31 0 0 1 31.15 31c0 17.5-13.64 31.72-31.15 31.72a31.34 31.34 0 1 1 0-62.72zm-608.28.38c1-.1 2.17 0 3.24 0a29.73 29.73 0 1 1-3.24 0zm449.28 0c1.06-.1 2.17 0 3.24 0a31.05 31.05 0 0 1 .18 62.1h-.55A31.11 31.11 0 0 1 811 326.4z" fill="#034ea2"/></svg></span><p class="agegate_text agegate_over18" >WELCOME</p><p class="agegate_text agegate_subtitle" >You need to be of legal drinking age to enter our site...</p></div>
                    <div class="agegate_middle"><div class="agegate_inputs_container"><input type="tel" name="year" title="year" placeholder="YYYY" maxlength="4" onclick="this.select();" class="age-gate_input"><input type="tel" name="month" title="month" placeholder="MM" maxlength="2" onclick="this.select();" class="age-gate_input"><input type="tel" name="day" title="day" placeholder="DD" maxlength="2" onclick="this.select();" class="age-gate_input"><p class="agegate_text agegate_noAgeInputCheckbox" style="display:none;" ><input type="checkbox" name="noAgeInputCheckbox" class="noAgeInputCheckbox" value="ok"  />I am 21, let me in.</p><input type="submit" name="agegate_submit" class="agegate_submit" value="OK" />
                                    <p id="avp-field-error-message" class="agegate_field-error-message">Please enter a valid value for the fields: {fields}</p>
                                    <p id="tooyoung-message" class="agegate_tooyoung-message">You have to be over 21 to enter this site</p>
                                </div><div class="agegate_rememberMe">
                                <input type="checkbox" name="rememberMe" value="ok"  /> <span>Remember me</span>
                                
                            </div><p class="agegate_text agegate_rememberMeHelp" >Don't tick this box if your computer can be accessed by people under legal drinking age</p></div>
                    <div class="agegate_bottom"><p class="agegate_text agegate_generalConditionsTitle" ></p><div class="agegate_text agegate_generalConditions" ><p>By entering this site, you are agreeing to our <a class="notice-link" href="https://havana-club.com/en/terms-and-conditions-of-use/" target="_blank" rel="noopener">Terms & Conditions</a>, <a class="notice-link" href="https://havana-club.com/en/online-privacy-policy/" target="_blank" rel="noopener">Privacy Policy</a>,<br />and by continuing to browse this site you are agreeing to accept our <a href="https://havana-club.com/en/cookies-policy/" target="_blank" rel="noopener">use of cookies.</a><br />Havana Club promotes responsible attitudes to drinking and against the misuse of alcohol. <a class="notice-link" href="https://www.wise-drinking.com/" target="_blank" rel="noopener">Drink responsibly</a>.<br />Forward to those of legal drinking age only.</p>
<p> </p>
<p>© 2024 Havana Club. All rights reserved.</p></div></div>
                    <div class="agegate_banned"><div class="agegate_banned_container">
    <div class="agegate_banned_title">We're sorry</div>
    <div class="agegate_banned_message">You are not allowed to visit our website from your country.</div>
    <div class="agegate_banned_terms-title"></div>
    <div class="agegate_banned_term-content"></div>
</div></div>
                </div>
                <div class="agegate_change_country agegate_countrySelector"><span>Change language</span><select id="agegate_change_country" name="agegate_change_country"><option value="generic" selected>Generic</option><option value="ar" >Arabic</option><option value="be" >Belarusian</option><option value="ca" >Catalan</option><option value="fr" >French</option><option value="de" >German</option><option value="it" >Italian</option><option value="pl" >Polish</option><option value="es" >Spanish</option></select></div>
            </form>

        </div>
    
    `;
    document.body.appendChild(ageGateContainer);
}

document.addEventListener('DOMContentLoaded', function() {
     injectAgeGate();
});