function SaveCookiesSettings() {
  if (document.getElementById('customSwitch2').checked) { s2 = '1'; } else { s2 = '0'; }
  if (document.getElementById('customSwitch3').checked) { s3 = '1'; } else { s3 = '0'; }
  SetCookies('1', s2, s3);
}

function SaveCookiesSettingsPage() {
  if (document.getElementById('customSwitch2').checked) { s2 = '1'; } else { s2 = '0'; }
  if (document.getElementById('customSwitch3').checked) { s3 = '1'; } else { s3 = '0'; }
  SaveCookies(1, s2, s3);
  window.location.href = '/';
}

function SetCookies(s0, s1, s2) {
  SaveCookies(s0, s1, s2);
  $('#cookies_info').remove();
}

function SaveCookies(s0, s1, s2) {
  var now = new Date();
  var time = now.getTime();
  var expireTime = time + 10*365*24*3600*1000;
  now.setTime(expireTime);
  document.cookie="cookies=" + s0 + s1 + s2 + "; path=/; expires= " + now.toUTCString();

  if (s1 == '1') {
    gtag('consent', 'update', {
      'ad_storage': 'granted',
      'analytics_storage': 'granted'
    });
  }
}
