Fix function hoisting bug (firefox) + jslint 50% of app.js

Functions inside blocks are not hoisted according to spec:
http://statichtml.com/2011/spidermonkey-function-hoisting.html