       @log "panels(#{i})"
       el = "##{@options.id} .pages .page:nth-child(#{(i+1)}) ul"
       @options.pages[i]['panel_selector'] = el
+      @active_panel = el
       @options.pages[i][''] = $(el).attr('id',"#{@options.pages[i]['id']}-panel")
+      
       $(el).amplePanels(@options.pages_options)
         .bind 'slide_horizontal', (e,d,dir) ->
           ref.load(i) if dir == 'next'


  enable_panel: (i) ->  
    @log "enable_panel(#{i})"
    $(@options.pages[i]['panel_selector']).amplePanels('enable') if @options.pages[i]['panel_selector']

  already_loaded: (i) ->
    @log "already_loaded(#{i})"

        false

  field_events: ->
    $('textarea, input').bind 'blur', =>
      @keys_enabled = true
    $('textarea, input').bind 'focus', =>
      @keys_enabled = false

  modal_events: ->
    @modal_active = false
    $(document).bind 'afterClose.facebox', =>
      @keys_enabled = true
      @modal_active = false
    $(document).bind 'loading.facebox', =>
      @keys_enabled = false
      @modal_active = true

  search: ->
    @log 'search_events()'
