Move function declarations outside blocks

Function declarations should not be within blocks; they won't be hoisted (if following the spec; some browsers do it anyway). This breaks on Spidermonkey (Firefox) if on a touch-enabled device (e.g. a laptop with a touch screen). This is the problem mentioned on #754.

For reference: http://statichtml.com/2011/spidermonkey-function-hoisting.html