var Switchable = {

  create: function(element_or_name) {
    element = $(element_or_name);
    Event.observe(window, 'load', Switchable.switch_event.bindAsEventListener(element));
    Event.observe(element, 'change', Switchable.switch_event.bindAsEventListener(element));
  },

  switch_event: function() {
    if (this.tagName == 'SELECT') {
      Switchable.switch_element(this.id, this.options[this.selectedIndex], this.options);
    }
  },

  switch_element: function(name, selected, options) {
    for (o in options) {
      option = options[o]
      if (option && option.value) {
        class_name = name + '_' + option.value.replace(/ /g, '_');
        elements = document.getElementsByClassName(class_name);
        for (e in elements) {
          element = elements[e];
          if (element && element.style) {
            if (option == selected) {
              Element.show(element);
            } else {
              Element.hide(element);
            }
          }
        }
      }
    }
  }

};
