       uri: 'uri'
 
     constructor: (@args) ->
+      alert 'started'
       @el = document.getElementById(args.id)
       @init() if @el
 

        @_searchFor e.currentTarget.value
      , false

      @el.addEventListener 'keypress', (e) =>
        if @showingList
          @_handleKeypress e

      # this needs to be fixed - doesn't pick up span click
      @el.parentNode.addEventListener 'click', (e) =>
        if e.target.tagName == 'LI'
          @el.value = e.target.textContent
          @_removeResults()

    _handleKeypress: (e) ->
      if e.keyCode == 40 # down arrow
        e.preventDefault()
        @_highlightDown()

    _searchFor: (searchTerm)  ->
      if searchTerm && searchTerm.length >= 3
        @searchTerm = searchTerm
        @_doRequest @searchTerm
      else if @showingList
        @_removeResults()

    _doRequest: ->
      if not @throttled
        myRequest = new XMLHttpRequest()
        myRequest.addEventListener 'readystatechange', =>
          if myRequest.readyState == 4
            if myRequest.status == 200
              @_updateUI JSON.parse myRequest.responseText

        myRequest.open 'get', @_generateURI(@args.uri, @args.scope)
        myRequest.setRequestHeader 'Accept', '*/*'
        myRequest.send()
        @throttled = true
        window.setTimeout =>
          @throttled = false
        , 200

    _generateURI: (searchURI, scope) ->
      uri = "#{searchURI}#{@searchTerm}"
