 
   load_results: (response) ->
     @log "load_results()"
-    ref = this
-    $.each response, (j,el) ->
-      link = ref.build(el)
+    $.each response, (j,el) =>
+      link = @build(el)
       li = $('<li class="file"></li>').append(link)
       $("#asset-results ul").amplePanels('append', li)
-      ref.load_img(link, el.sizes.tn)
+      @load_img(link, el.sizes.tn)
 
   build: (el) ->
     ref = this

  events: ->
    @modal_events()
    @field_events()
    ref = this
    $("a.asset-remove").live 'click', ->
      ref.remove(this)
      false
    $("##{@options.id}-handle").live 'click', ->
      ref.toggle()
      false
    @key_down()
    tabs = $("##{@options.id} a.tab")
    $.each tabs, (idx, el) ->
      $(this).addClass('on') if idx == 0
      $(el).click ->

      @goto(@current)

  get_pages: (tpl = 'page') ->
    html = ''
    $.each @options.pages, (idx,el) => 
      html += Mustache.to_html @tpl(tpl), el
    html

  toggle: ->
    el = $("##{@options.id}")
    if @options.expanded 
      @options.expanded = false
      el.animate {height: @options.collapsed_height}, "fast", =>
        @collapse()
        @options.onCollapse()
    else
      @options.expanded = true
      el.animate {height: @options.expanded_height}, "fast", =>
        @expand()
        @options.onExpand()
        @goto(0)

  load: (i) ->
    ref = this
