(function() {
  var fluidSwitch = document.getElementById("fluidSwitch");
  if (fluidSwitch) {
    initFluidTheme();
    fluidSwitch.addEventListener("change", function(event) {
      resetFluidTheme();
    });
    function initFluidTheme() {
      var fluidThemeSelected =
        localStorage.getItem("fluidSwitch") !== null &&
        localStorage.getItem("fluidSwitch") === "on";
      fluidSwitch.checked = fluidThemeSelected;
      fluidThemeSelected
        ? $("div.container").removeClass("container").addClass("container-fluid")
        : $("div.container-fluid").removeClass("container-fluid").addClass("container");
    }
    function resetFluidTheme() {
      if (fluidSwitch.checked) {
        $("div.container").removeClass("container").addClass("container-fluid");
        localStorage.setItem("fluidSwitch", "on");
      } else {
        $("div.container-fluid").removeClass("container-fluid").addClass("container");
        localStorage.setItem("fluidSwitch", "off");
      }
    }
  }
})();
