var ReplyForms = {
  // forms: document.getElementsBySelector('form.reply-form'),
  
  original_label: null,
  cancel_label: '&laquo; cancel',
  
  form_for: function(btn){
    return btn.parentNode.parentNode.nextSibling.nextSibling
  },
  
  do_action: function() {
    if (!ReplyForms.original_label) ReplyForms.original_label = this.innerHTML
      
    form = ReplyForms.form_for(this)
    form.style.display = 'block'
    Form.findFirstElement(form).focus()
    
    this.innerHTML = ReplyForms.cancel_label
    this.onclick = ReplyForms.cancel_action
    return false
  },
  cancel_action: function() {
    form = ReplyForms.form_for(this)
    form.style.display = 'none'
    
    this.innerHTML = ReplyForms.original_label
    this.onclick = ReplyForms.do_action
    return false
  },
  
  init: function() {    
    $$('ul.actions li.reply a').each(function(btn,i) {btn.onclick = ReplyForms.do_action})
  }
}

Event.observe(window, 'load', ReplyForms.init)

