// =============================================================
// = written by tomonaga tokuyama (tomonagatokuyama.com), 2007 =
// =============================================================
Effect.AnyCSS = Class.create();
Object.extend(Object.extend(Effect.AnyCSS.prototype, Effect.Base.prototype), {
	initialize: function(element) {
		this.element = element;
		if(! this.element) throw(Effect._elementDoesNotExistError);
		var options = Object.extend({ prop:[], start:[], end:[], unit:'px'}, arguments[1] || {});
		this.nProps = options.prop.length;
		if (options.start.length != this.nProps || options.end.length != this.nProps)
			throw '[EffectAnyCSS] Sizes are mismatch';
		this.amt = new Array(this.nProps);
		for (var i=0; i < this.nProps; i++) {
			this.amt[i] = options.end[i]-options.start[i];
			// console.log(this.element.getStyle(options.prop[i]));
		}
		this.start(options);
	},
	setup: function() {
		if(this.element.style.display == 'none') {this.cancel(); return;}
	},
	update: function(position) {
		// console.log(position);
		for (var i = this.nProps - 1; i >= 0; i--)　{
			this.element.style[this.options.prop[i]] = this.options.start[i]+(this.amt[i] * position)+this.options.unit;
		}
	},
	finish: function() {
		for (var i = this.nProps - 1; i >= 0; i--)
			this.element.style[this.options.prop[i]] = this.options.end[i]+this.options.unit;
	}
});

