SwapButton = function (container_id) {
    this.state = 'START';
    
    var swap_to, start_with;
    $$('#' + container_id + ' form').select(function(form) {
      if (form.hasClassName('hidden')) {
          swap_to = form;
      } else {
          start_with = form;
      }
    });
    this.swap_to = swap_to;
    this.start_with = start_with;
    
    var button_node = $$('#' + container_id + ' a.swap_button')[0]
    this.button_node = button_node;
    button_node.button_obj = this;
    button_node.observe('click', function(evt) { 
        this.button_obj.swap();
        Event.stop(evt);
        return false;
    });
};

SwapButton.prototype = {
    swap: function () {
        var new_state, new_button_label, div_to_show_id, div_to_hide_id;
        if (this.state == 'START') {
            new_state = 'SWAP';
            new_label = this.start_with.id;
            div_to_show = this.swap_to;
            div_to_hide = this.start_with;
        } else {
            new_state = 'START';
            new_label = this.swap_to.id;
            div_to_show = this.start_with;
            div_to_hide = this.swap_to;
        }
        div_to_hide.addClassName('hidden');
        div_to_show.removeClassName('hidden');
        this.state = new_state;
        this.button_node.innerHTML = new_label;
     }
};