     else
       $("#search-results").hide()
 
-  $(".search.report.row").hide()
+  # Initializer function to set up the page
+  initialize = () ->
 
-  $(".report.repository-select").on 'change', (event) =>
-    repository = $(".report.repository-select").val()
-    window.location = "repository?show=#{repository}"
+    $(".dropdown-toggle").dropdown()
+    $(".search.report.row").hide()
 
-  $(".dropdown-toggle").dropdown()
+    $(".report.repository-select").on 'change', (event) =>
+      repository = $(".report.repository-select").val()
+      window.location = "repository?show=#{repository}"
 
-  $("a.report.search").on 'click', (event) =>
-    record = $(event.target).data('record')
-    $(".search.report.row").show()
-    $("#search-input").data('record', record)
-    $("#search-results").hide()
+    $("a.report.search").on 'click', (event) =>
+      record = $(event.target).data('record')
+      $(".search.report.row").show()
+      $("#search-input").data('record', record)
+      $("#search-results").hide()
 
-  $("#search-input").on 'input', (event) =>
-    $("#search-results tbody").empty()
-    $("#search-results").show()
+    $("#search-input").on 'input', (event) =>
+      $("#search-results tbody").empty()
+      $("#search-results").show()
 
-    query = $("#search-input").val()
-    query = if /\S/.test(query) then query else '*'
-    repository = gon.repository.name
+      query = $("#search-input").val()
+      query = if /\S/.test(query) then query else '*'
+      repository = gon.repository.name
 
-    data =
-      q: query
-      repository: repository
+      data =
+        q: query
+        repository: repository
 
-    $.getJSON("/metadata/search", data, displayRecordResults)
+      $.getJSON("/metadata/search", data, displayRecordResults)
+
+  initialize()

  metric_url_representation = (metric) ->
    return metric.split('_').join('-')

  displayRecordResults = (result) ->

    which_record = $("#search-input").data("record")
    if result.length > 0
      for metadata in result


    return "<tr class='rowlink'>#{tdId}#{tdName}#{tdScores}</tr>"

  # Create the URLs used in the result table
  createReportLink = (record, i) ->

    metric = metric_url_representation(gon.metric)
