Optimize index.js and add style consistency

Declared all jQuery objects once where needed instead of diving into the DOM multiple times for the same object.

Added style consistency between variable declarations, if/else statements and functions.
I think it'd be cleaner (and save a few bytes) if you declared vars

```
var inThis,
    sortOf,
    way;
```