Effect.Resize = Class.create();
Object.extend(Object.extend(Effect.Resize.prototype, Effect.Base.prototype), {

  initialize: function(element) {

    this.element = $(element);

    if(!this.element) throw(Effect._elementDoesNotExistError);

    var options = Object.extend({
      width:    0,
      height:    0,
      mode: 'relative'
    }, arguments[1] || {});

    this.start(options);
  },
  setup: function() {
    // Bug in Opera: Opera returns the "real" position of a static element or
    // relative element that does not have top/left explicitly set.
    // ==> Always set top and left for position relative elements in your stylesheets 
    // (to 0 if you do not need them) 
    this.element.makePositioned();
    this.originalWidth = parseFloat(this.element.getStyle('width') || '0');
    this.originalHeight  = parseFloat(this.element.getStyle('height')  || '0');

    if(this.options.mode == 'absolute') {
      // absolute movement, so we need to calc deltaX and deltaY
      this.options.width = this.options.width - this.originalLeft;
      this.options.height = this.options.height - this.originalTop;
    }

  },
  update: function(position) {

	this.element.style.width = Math.round(this.options.width * position + this.originalWidth) + 'px';
	this.element.style.height = Math.round(this.options.height * position + this.originalHeight)  + 'px';

/*    this.element.setStyle({
      width: Math.round(this.options.width * position + this.originalWidth) + 'px',
      height:  Math.round(this.options.height * position + this.originalHeight)  + 'px'
    });
*/
  }
});
