
// couple of things for prototype & scriptaculous
Element.addMethods({
    hasPosition : function(element, x, y){
        element = $(element);
        this.topleft = Element.cumulativeOffset(element);
        this.bottomright = [
            this.topleft[0] + element.offsetWidth,
            this.topleft[1] + element.offsetHeight,
        ];
        return (y >= this.topleft[1] &&
            y <  this.bottomright[1] &&
            x >= this.topleft[0] &&
            x <  this.bottomright[0]);
    }

});

Effect.YChange = Class.create(Effect.Base, {
  initialize: function(element) {
    this.element = $(element);
    if (!this.element) throw(Effect._elementDoesNotExistError);
    var options = arguments[1] || { };
    this.start(options);
  },
  setup: function() {
    this.originalHeight = parseFloat(this.element.getStyle('height') || '0');
  },
  update: function(position) {
    this.element.setStyle({
      height: ((this.options.y  * position) + this.originalHeight).round() + 'px'
    });
  }
});


Effect.XYChange = Class.create(Effect.Base, {
  initialize: function(element) {
    this.element = $(element);
    if (!this.element) throw(Effect._elementDoesNotExistError);
    var options = arguments[1] || { };
    this.start(options);
  },
  setup: function() {
    this.originalHeight = parseFloat(this.element.getStyle('height') || '0');
		this.originalWidth = parseFloat(this.element.getStyle('width') || '0');
  },
  update: function(position) {
    if(this.options.y){
			this.element.setStyle({
        height: ((this.options.y  * position) + this.originalHeight).round() + 'px'
      });
		}
		if(this.options.x){
		  this.element.setStyle({
        width: ((this.options.x  * position) + this.originalWidth).round() + 'px'
      });
		}
  }
});
