// 
// var AmountSelection = Class.create({
//   initialize: function(select_id, custom_id) {
//     this.select = $(select_id);
//     this.custom = $(custom_id).remove();
//     this.select.observe('change', this.onSelectChange.bind(this));
//     // this.select.observe('change', function(e) {alert('testeste');});
//     // this.select.onchange = this.onSelectChange.bindAsEventListener(this);
//     this.form = this.select.up('form');
//   },
//   onSelectChange: function(event) {
//     alert('fired!');
//     el = event.element();
//     alert('Select changed: '+el.selectedIndex);    
//     if (el.selectedIndex == el.options.length - 1) {
//       this.onSelectCustom();
//     } else {
//       this.onSelectStandard();
//     }
//   },
//   onSelectCustom: function() {
//     alert('custom selected');
//     this.select.insert({after: this.custom});
//   },
//   onSelectStandard: function() {
//     alert('standard selected');
//     if (this.custom.parentNode) {
//       this.custom.remove();
//     }
//   },
//   onFormSubmit: function() {
//     
//   }
// });

var AmountSelection = {
  initialize: function(select_id, custom_id) {
    AmountSelection.select = $(select_id);
    AmountSelection.custom = $(custom_id).remove();
    // AmountSelection.select.observe('change', AmountSelection.onSelectChange.bind(AmountSelection));
    // AmountSelection.select.observe('change', function(e) {alert('testeste');});
    // AmountSelection.select.onchange = AmountSelection.onSelectChange.bindAsEventListener(AmountSelection);
    AmountSelection.form = AmountSelection.select.up('form');
  },
  onSelectChange: function(el) {
    if (el.selectedIndex == el.options.length - 1) {
      this.onSelectCustom();
    } else {
      this.onSelectStandard();
    }
  },
  onSelectCustom: function() {
    this.select.insert({after: this.custom});
  },
  onSelectStandard: function() {
    if (this.custom.parentNode) {
      this.custom.remove();
    }
  }
};