         ns.displayNextCard()
 
   ns.displayNextCard = ->
+    kksystem.cardsets.study.startLoading()
     incomplete_boxes = @cardboxes.filter (cardbox) => not cardbox.done
     #If incomplete boxes, continue studying, else end study.
     if incomplete_boxes.length > 0

  #
  # params - Object representing serialised data from options form.
  ns.initStudy = (params) ->
    $('#study .js-hide-on-load').hide()
    $('#study .js-loading').show()

    #Flip the card.
    $('.js-hide-back').click (e) ->

        kksystem.cardsets.study.setCardText
          front: @use_card.front
          back: @use_card.back
        kksystem.cardsets.study.hookupCorrectnessButtons(ns.correct,
                                                         ns.incorrect)
        kksystem.cardsets.study.stopLoading()
      else
        current_box.done = true
        ns.displayNextCard()
    else
      kksystem.cardsets.study.finishStudy()

  ns.correct = ->
    index = ((if ns.use_card.current_cardbox_id == cardbox.id then \
              true else false) for cardbox in ns.cardboxes).indexOf(true)
    new_cardbox = if index == -1
                    ns.cardboxes[0]
                  else
                    ns.cardboxes[index + 1] || null
    ns.use_card.set('current_cardbox_id',
                    if new_cardbox then new_cardbox.id else null)
    ns.use_card.save ->
      ns.displayNextCard()

  ns.incorrect = ->
    ns.use_card.set('current_cardbox_id', if ns.cardboxes[0] \
                                          then ns.cardboxes[0].id else null)
    ns.use_card.save ->
      ns.displayNextCard()

namespace 'kksystem.cardsets.study.single_box', (ns) ->
  ns.init = (params) ->
