 SubjectViewer = require 'zooniverse-readymade/lib/subject-viewer'
 
 SubjectViewer::template = require './templates/subject-viewer'
+
+SubjectViewer::rescale = ()->
+  scale = @markingSurface.el.parentNode.offsetWidth / @maxWidth
+  @markingSurface.maxWidth = @maxWidth
+  @markingSurface.maxHeight = @maxHeight
+  @markingSurface.svg.attr
+    width: scale * @maxWidth
+    height: scale * @maxHeight
 
 ClassifyPage = require 'zooniverse-readymade/lib/classify-page'
 

# moving back and forward through the array of marked SVG rectangles
classify_page.el.on decisionTree.LOAD_TASK, ({originalEvent: detail: {task}})->
  rectangles = []
  scale = ms.el.parentNode.offsetWidth / subjectViewer.maxWidth
  
  for tool in ms.tools
    tool.deselect()

    current_tool.mark.details = value.details

classify_page.on classify_page.LOAD_SUBJECT, (e, subject)->
  ms.rescale 0, 0, subjectViewer.maxWidth, subjectViewer.maxHeight
  
  bhl_link.setAttribute 'href', subject.metadata.bhl_url
