 if jQuery?
   jQuery.fn.extend
     openSongLyrics: (lyrics) ->
-      openSong.renderLyrics this, lyrics
+      new OpenSong this, lyrics
 
 
 Handlebars.registerHelper 'human_header', (abbr) ->

      abbr


openSong =

  getDomElem: (domElem) ->
    if typeof domElem is 'string'
      return document.getElementById domElem

    if domElem.jquery
      return domElem.get(0)

    if domElem.nodeType
      return domElem

    undefined

  renderLyrics: (element, lyrics) ->
    # TODO: support comments
    templateSrc = """
      {{#this}}

    template = Handlebars.compile templateSrc

    # clear Html Element and add opensong class
    @el.innerHTML = template @model
    @el.className += " opensong" unless /opensong/.test @el.className


  getDomElem = (domElem) ->
    if typeof domElem is 'string'
      return document.getElementById domElem

    if domElem.jquery
      return domElem.get(0)

    if domElem.nodeType
      return domElem

    undefined

  ###

