   )
   counter
 
+add_media_file_section = () ->
+  counter = $('#media-files').children().size() + 10
+  $('#media-files').append(
+    Handlebars.compile(media_file_html())(
+      {
+        counter:counter
+      }
+    )
+  )
+  counter
+
 $("#data-add").click(add_data_file_section)
-#   () ->
-#     $('#data-files').append(
-#       Handlebars.compile(data_file_html())(
-#         {
-#           counter:$('#data-files').children().size() + 2
-#           fields:[['x', '',       'required', ''],
-#                   ['y', '',       'required', ''],
-#                   ['z', 'hidden', '',         'disabled']]
-#         }
-#       )
-#     )
-# )
-
-$("#media-add").click(
-  () ->
-    $('#media-files').append(
-      Handlebars.compile(media_file_html())(
-        {
-          counter:$('#media-files').children().size() + 10
-        }
-      )
-    )
-)
-
+
+$("#media-add").click(add_media_file_section)
 
 $("#data-files").on('click', '.data-remove',
   () ->

  $('#acc_' + DATA.metadata.hardware.acc_architecture).attr('selected', '')
  $('#par_' + DATA.metadata.hardware.parallel_model).attr('selected', '')
  populate_data_section(DATA)

    $('#dim-contour-' + counter).attr('checked', '')
    $('#line-contour-' + counter).removeAttr('checked')

populate_data_section = (data) ->
  map(
    populate_data
    data.data.filter(
      (d) -> (d.type == 'contour' or d.type == 'line') and d.url?
    )
  )

populate_media_section = (data) ->
  map(
    populate_media
    data.data.filter(
      (d) -> (d.type == 'youtube' or d.type == 'image') and d.url?
    )
  )

