Update main.js

Move var and init forward, use defined function in music auto-load and make the auto-load block more sense
Merge pull request #2 from viztor/patch-1

Update main.js