     player = getPlayerObjects()
     player.jquery.attr("controls", "controls")
     player.jquery.bind "ended", playRandomSong
-    $(document).bind "hashchange", playHashSong
+    $(window).bind "hashchange", playHashSong
 
     $.getJSON "/files", (data) =>
         songData = []


playRandomSong = ->
    song = nextSong
    window.location = "#" + song
    $("#status").text(song)
    player = getPlayerObjects()

SONGS = []
PLAYBACK_TYPES = {ogg: 'audio/ogg', mp3: 'audio/mpeg'}
PLAYBACK_TYPE = null
CURRENT_SONG = null
nextSong = null

playHashSong = ->
        if document.location.hash.length <= 1
                return
        songName = document.location.hash.substr(1)
        if songName == CURRENT_SONG
                return
        playSong songName

playSong = (song) ->
