Updated to use HTML5 `localStorage` instead of cookies to store UI state.

Also cleaned up JS variable scope.