   return "http://localhost:#{serverPort}/better-bibtex/#{url}"
 
 Zotero.BetterBibTeX.pref.styleChanged = (index) ->
-  listbox = document.getElementById('better-bibtex-abbrev-style')
-  selectedItem = if index != 'undefined' then listbox.getItemAtIndex(index) else listbox.selectedItem
+  stylebox = document.getElementById('better-bibtex-abbrev-style')
+  selectedItem = if index != 'undefined' then stylebox.getItemAtIndex(index) else stylebox.selectedItem
   styleID = selectedItem.getAttribute('value')
   Zotero.BetterBibTeX.pref.set('auto-abbrev.style', styleID)
   Zotero.BetterBibTeX.keymanager.journalAbbrevCache = Object.create(null)

      itemNode = document.createElement('listitem')
      itemNode.setAttribute('value', style.styleID)
      itemNode.setAttribute('label', style.title)
      listbox.appendChild(itemNode)
    if style.styleID is selectedStyle then selectedIndex = i
  if selectedIndex is -1 then selectedIndex = 0
  @styleChanged(selectedIndex)

  window.setTimeout((->
    listbox.ensureIndexIsVisible(selectedIndex)
    listbox.selectedIndex = selectedIndex
    return), 0)
  return


  styles = (style for style in Zotero.Styles.getVisible() when style.usesAbbreviation)

  stylebox = document.getElementById('better-bibtex-abbrev-style')
  fillList = stylebox.children.length is 0
  selectedStyle = Zotero.BetterBibTeX.pref.get('auto-abbrev.style')
  selectedIndex = -1
  for style, i in styles
