
ActionChain.add({

  'form:submit': function() {
    this.getElements('input[type=submit]').set('disabled', true);
},

  'input[name=continue]:click': function() {
    $('to_confirmation').set('value', 'Y');
  },

  '.send_on_click:click': function() {
    this.getParent('form').submit();
  },
  
  '.popup_link:click': function() {
    return popitup(this.get('href'));
  },

  'body': function() {
    new QuickBox();
  },

  '.remote_partial_link:click': function() {
    new Request({
      url: this.get('href'),
      onSuccess: function(htmlResponse) {
        // wrap raw html into a span element for easy injecting
        var partial = new Element('span', { html: htmlResponse });
        var target = $(this.get('data-inject_inside'));

        partial.inject(target);
        ActionChain.apply(target);
      }.bind(this)
    }).get();
    return false;
  },

  '.remove_picture:click': function() {
    this.getParent('.picture').dispose();
    return false;
  },

  '.remove_asset:click': function() {
    this.getParent('.asset').dispose();
    return false;
  }

});

function popitup(url) {
  var newWindow = window.open(url, 'name','height=800,width=600,scrollbars=1');
  if (window.focus) newWindow.focus();
  return false;
}

function printpage() {
window.print();
}