       @_addClass results, @config.resultsClass
       @_addClass results, "#{@config.resultsClass}--#{@config.classModifier}" if @config.classModifier
 
-      results.addEventListener 'click', (e) =>
+      @_on(results, 'click', (e) =>
         @_resultsClick e
-      , false
-
-      results.addEventListener 'mouseover', (e) =>
+      , false)
+
+      @_on(results, 'mouseover', (e) =>
         @_resultsMouseOver e.target
-      , false
-
-      results.addEventListener 'mouseout', (e) =>
+      , false)
+
+      @_on(results, 'mouseout', (e) =>
         @_resultsMouseOut e.target
-      , false
-
+      , false)
       results
 
     # event handlers

    _init: (args) ->
      @config = @_updateConfig args
      @el = document.getElementById @config.id
      @_addEventHandlers()
      @results = @_buildResults()
      @xhr = @_setupXHR()

    _updateConfig: (args) ->
      newConfig = {}

      newConfig[key] = value for own key, value of args
      newConfig

    _on: (elt, evt, callback) ->
      if window.addEventListener
        elt.addEventListener evt, callback, false
      else if window.attachEvent
        elt.attachEvent "on#{evt}", callback

    _addEventHandlers: ->
      @_on(@el, 'input', (e) =>
        @_searchFor e.currentTarget.value
      )
      @_on(@el, 'keydown', (e) =>
        @_keypressHandler e
      )

    _setupXHR: ->
      xhr = new XMLHttpRequest()
      xhr.onreadystatechange = =>
        if @xhr.readyState == 4
          if @xhr.status == 200
            @_populateResults JSON.parse(@xhr.responseText), @currentSearch
