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.
Because JavaScript is going to hoist the var statements anyway, I'd put all the var statements towards the top, like so:
```javascript
var foo = 1,
    bar = 2,
    baz = function (a, b) {
        // stuff here
    },
    qux;
```
And then everything after it.