   init: ->
     $(".nNewGameMenuCloseButton").on "click", =>
       if noughts.state.hasPreviousState()
-        noughts.state.back()
+        noughts.state.back(-> setStateFromPath(""))
       else
         noughts.state.changeState(noughts.state.INITIAL_PROMO)
 


SPRITE_Z_INDEX = 2 # The Z-Index to add new sprites at

noughts.state =
  PLAY: "PLAY"
  INITIAL_PROMO: "INITIAL_PROMO" # Initial game description state

    Meteor.call "facebookJoinViaRequestId", id, profile, (err, gameId) ->
      if err? then throw err
      playGame(gameId)
  else
    setStateFromPath($.url().segment(1))

# Sets the initial game state based on the request path (specifically the
# first segment after the domain). Does not handle e.g. ?request_ids=
# parameters.
setStateFromPath = (path) ->
  if path == "new"
    noughts.state.changeState(noughts.state.NEW_GAME_MENU,
        noughts.state.UrlBehavior.PRESERVE_URL)
  else if path == "facebookInvite"
