      $(function() {
        var forget, setShowMature, getShowMature, updateMatureFilter;
        
        /**
         * Updates the page to reflect the user's mature content preference.
         */
        updateMatureFilter = function(flag) {
          if ( arguments.length === 0 )
            flag = getShowMature();
          
          if ( flag )
            $('body').addClass('showMature');
          else
            $('body').removeClass('showMature');
        };
        
        if ( window.localStorage ) {
          // Use localStorage to save the mature content settings if it's
          // available.
          
          /**
           * Writes the user's mature content preference to local storage.
           */
          setShowMature = function(flag) {
            localStorage.setItem('showMature', flag);
            updateMatureFilter(flag);
          };
          
          /**
           * Retrieves the user's mature content preference from local
           * storage.
           */
          getShowMature = function() {
            var value = localStorage.getItem('showMature');
            if ( value === 'true' )
              return true;
            else if ( value === 'false' )
              return false;
            else
              return null;
          };
          
          $('.unlessLocalStorage').remove();
        }
        else {
          // Fall back on an obnoxious per-page-load variable if localStorage
          // isn't available. You should use cookies instead of doing this.
          var showMature = null;
          
          setShowMature = function(flag) {
            showMature = flag;
            updateMatureFilter(flag);
          };
          
          getShowMature = function() {
            return showMature;
          };
          
          $('.ifLocalStorage').remove();
        }
        
        // Button callbacks for the warning message.
        $('#warning button.showMatureButton').click(function() {
          setShowMature(true);
          $('#warning, #cover').fadeOut('fast');
        });
        $('#warning button.hideMatureButton').click(function() {
          setShowMature(false);
          $('#warning, #cover').fadeOut('fast');
        });
        
        // Button callbacks for testing stuff.
        $('button.showWarning').click(function() {
          $('#warning, #cover').fadeIn('fast');
        });
        $('button.fuhgeddaboudit').click(function() {
          // Forget the user's preference if localStorage is available, for
          // the sake of testing.
          if ( window.localStorage )
            localStorage.removeItem('showMature');
        })
        
        // Show the mature content warning for first-time visitors.
        if ( getShowMature() == null )
          $('#warning, #cover').show();
        else
          updateMatureFilter();
      });

