var DLHideShow = Class.create();

DLHideShow.prototype = {
  initialize : function(definition_list_id) {
    this.dl   = $(definition_list_id);
    this.dts  = this.dl.select("dt");
    this.dds  = this.dl.select("dd");
    
    this.dds.invoke("hide");
    this.dts.invoke("observe", "click", this.toggleDD);
    this.dts.each(function(element) {
      element.innerHTML = "[+] " + element.innerHTML;
      element.setStyle({ cursor: "pointer" });
    });
  },
  
  toggleDD : function(event) {
    var dd = this.nextSiblings().first();
    
    var newText = "";
    if (dd.visible()) {
      this.removeClassName("active");
      new Effect.BlindUp(dd);
      newText = "[+]";
    }else{
      this.addClassName("active");
      new Effect.BlindDown(dd);
      newText = "[-]";
    }
    
    this.innerHTML = this.innerHTML.replace(/\[[+-]\]/, newText);
  }
  
}
