<script>
function wcagGetCookie(name) {
let nameEQ = name + "=";
let ca = document.cookie.split(';');
for(let i=0; i < ca.length; i++) {
let 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 wcagApplyInitialState() {
var fontSizes = ['fsize70','fsize80','fsize90','fsize100','fsize110','fsize120','fsize130'];
var fontSizeCookie = wcagGetCookie('jm-font-size');
document.documentElement.classList.remove(...fontSizes);
if (fontSizeCookie) {
var count = parseInt(fontSizeCookie, 10);
if (fontSizes.includes('fsize' + count)) {
document.documentElement.classList.add('fsize' + count);
}
}
var contrastClasses = ['night', 'highcontrast', 'highcontrast2', 'highcontrast3'];
var contrastCookie = wcagGetCookie('contrast');
document.documentElement.classList.remove(...contrastClasses);
if (contrastCookie && contrastClasses.includes(contrastCookie)) {
document.documentElement.classList.add(contrastCookie);
}
}
document.addEventListener('DOMContentLoaded', wcagApplyInitialState);
</script>