       click   : -> app.quit()
     ]
 
+
+    if (keys = Object.keys teams).length
+      submenu = \
+        keys.map (key) ->
+          return  if key is 'latest'
+          teamName = teams[key]
+          return { label: teamName, click: -> win.loadURL "http://#{key}.koding.com" }
+        .filter(Boolean)
+
+      menu.unshift { type: 'separator', visible: on }
+      menu.unshift { label: 'Teams', submenu }
+
+    @_contextMenu = Menu.buildFromTemplate menu.concat menuItems
+
     @tray.popUpContextMenu @_contextMenu  if show
+
 
 
   setFailed: (err) ->

    else @checkKdStatus yes


  setMenu: (menu, show = no) ->

    if typeof menu is 'string'
      menu = [ label: menu, enabled: no ]

    @_contextMenu = Menu.buildFromTemplate menu.concat [
      type    : 'separator'
      visible : @_isKdRunning
    ,


module.exports = class KodingTray

  constructor: (mainWindow) ->

    # Globals
    @_mainWindow = mainWindow
    @_inProgress  = no
    @_isKdRunning = no
    @_contextMenu = []
    @_previousTeams = {}

    @tray = new Tray TRAY_ICON
    # @tray.setPressedImage TRAY_ICON_REV

    @tray.on 'click', => @handleClick()

    kallback = =>
      @checkKdStatus no
      @loadPreviousTeams()

    @_mainWindow.webContents.on 'did-navigate', kallback
    @_mainWindow.webContents.on 'did-navigate-in-page', kallback

    setTimeout kallback, 2000
    setInterval kallback, 1000 * CHECK_TIMER



  handleClick: ->
