 
     # If timer is complete, trigger alert
     if @currentTime is 0
-      @$timer.stop()
+      @pause()
       @resetCountdown()
       return
 

  start: () ->
    @addElements()
    @$timer = $.timer(@updateTimer, @incrementTime, true)

  addElements: () ->
    @$nextDashboardNameContainer = $("<span id='dc-switcher-next-name'></span>")
    @$countdown = $("<span id='dc-switcher-countdown'></span>")
    manualSwitcher = $("<span id='dc-switcher-arrow'>&ensp;&#65515;</span>")
    @$elements.append(@$nextDashboardNameContainer).append(@$countdown).append(manualSwitcher).click( () =>
      location.href = "/#{@nextDashboardName}"
    )

  formatTime: (time) ->
    time = time / 10;

#   - show the name of the next dashboard
#   - add controls for manually cycling through dashboards
class SwitcherControls
  arrowContent = "&#65515;"
  stopTimerContent = "stop timer"

  constructor: (interval=60000, nextDashboardName) ->
    @currentTime = parseInt(interval, 10)
    @interval = parseInt(interval, 10)
    @$elements = $('#dc-switcher-controls')
    @nextDashboardName = nextDashboardName
    @incrementTime = 1000 # refresh every 1000 milliseconds
    @arrowContent = @$elements.data('arrow-content') || SwitcherControls.arrowContent
    @stopTimerContent = @$elements.data('stop-timer-content') || SwitcherControls.stopTimerContent
    @

  present: () ->
    @$elements.length
