var link, mode;

(function () {
  'use strict';

  document.addEventListener('DOMContentLoaded', function () {
    link = document.querySelector('link[rel=stylesheet][href*="main.css"]');
    mode = localStorage.getItem('css-mode');
    if (mode == null) {
      mode = 'main'
      localStorage.setItem('css-mode', 'main');
    }

    if (mode == 'high-contrast') setMode();
  });
})();

function switchMode() {
  mode = mode == 'main' ? 'high-contrast' : 'main';
  localStorage.setItem('css-mode', mode);
  setMode();
}

function setMode() {
  link.href = 'css/' + mode + '.css';
}