 # items   Items for menu, see #popup
 # open    Callback function to execute before opening the popup menu
 # close   Callback function to execute after the popup menu is closed
-jQuery.fn.popup = (items, open, close) ->
+jQuery.fn.popup = (items, open, close, options) ->
   id = popupIDs++
   @click (e) ->
+    e.preventDefault()
     e.stopPropagation()
     element = this
-    options = {}
+    options = $.extend({}, options);
     options.close = -> close.call element if close
     if popupID == id
       closePopup()

          li.append a
          ul.append li
  
  popup.click (e) -> e.stopPropagation()
  
  style = if offset.left < $(window).width() - 150
    "left: #{Math.round offset.left}px"
  else
    "right: #{Math.round($(window).width() - offset.left - element.outerWidth())}px"

  if ST.View && (display instanceof ST.View)
    display.load()
    popup.append display.element()
  else if display instanceof jQuery
    popup.append display
  else
    ul = $ "<ul class=\"popupMenu\"></ul>"
    popup.append ul
