Search = Class.create()
Search.prototype = {
  initialize: function (params) 
  {
    $$('a[class~="toggler"]').each(
      function (v) {
        YAHOO.util.Event.addListener(v, "click", this.toggleRevise, null, this)
      }
    ,this)
  },

  toggleRevise: function(e)
  {
    target = YAHOO.util.Event.getTarget(e)
    // FF might grab the img not the A
    if ( target.tagName == 'IMG' )
      target = target.parentNode

    this.cleanWhitespace(target)
    this.cleanWhitespace(target.parentNode)

    // IE doesn't automagically extend the elements
    Element.extend(target.nextSibling)

    if ( target.nextSibling.hasClassName('hide') ) {
      target.nextSibling.removeClassName('hide')
      target.childNodes[0].src = '/images/toggle_active.png'
    } else {
      target.nextSibling.addClassName('hide')
      target.childNodes[0].src = '/images/toggle.png'
    }
  },

  cleanWhitespace: function(element) {
    for (var i = 0; i < element.childNodes.length; i++) {
      var node = element.childNodes[i]
      if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
        Element.remove(node)
    }
  }
}

