JSHint formatting cleanup, first batch

Since static code analysis has its benefits, I went over the code with JSHint and fixed a first bunch of notices. Most of them are somewhat cosmetic and handle the signal-to-noise ratio  (I'd like to have zero notices, but that's going to take a while). But some are actually problems with bug potential.

The changes were done one step at a time within dedicated commits and appropriate commit messages. The changes outlined:
* Semicolons added where missing
* Set indentation globally to 4 spaces
* Using literals for arrays and objects ([], {}) instead of new operator
* Moved/Modified function declarations that were within blocks or loops
* Using explicit radix parameter for parseInt
* 4 foreach loops created global iterator variables

I used the following .jshintrc:
```
{
    "latedef": true,
    "undef": true,
    "browser": true,

    "globals": {
        "mat3": false,
        "mat4": false,
        "quat4": false,
        "vec3": false,

        "device": true,
        "variableStore": true
    }
}
```
As indicated, JSHint still complains about several more things, I'll address them in dedicated issues.