Move Settings from viewer.js to its own file

This is yet another patch that reduces the size of viewer.js. It's done in two separate commits:
* The first one just moves the code to a new file.
* The second one fixes the coding style (adding braces to single line statements and adding strict equalities).                                                                                                                                                        
The comment describing what the code does is also updated somewhat.