/*
extenions to moo.fx ().
by Jason Tremblay (http://www.iamtremblay.com) MIT-style LICENSE.
for more info ().
Sunday, May 07, 2006
based on moo.fx v 1.2.3
*/

Object.extend(fx.Layout.prototype, {
	initialize: function(el, options) {
		this.el = $(el);
		this.el.style.overflow = "hidden";
		this.iniWidth = this.el.offsetWidth;
		this.iniHeight = this.el.offsetHeight;
		this.iniX = options.iniX || this.getX();
		this.iniY = options.iniY || this.getY();
		this.setOptions(options);
	},
	
	getX: function(){
		var x = Element.getStyle(this.el,'left');
		return (parseInt(x.substring(0,x.indexOf('px'))));
	},
	
	getY: function(){
		var y = Element.getStyle(this.el,'top');
		return (parseInt(y.substring(0,y.indexOf('px'))));
	}
});

// x motion
fx.XPos = Class.create();
Object.extend(Object.extend(fx.XPos.prototype, fx.Layout.prototype), {	
	increase: function() {
		this.el.style.left = this.now +"px";
	},

	toggle: function() {
		if (this.getX() > 0) this.custom(this.getX(), 0);
		else this.custom(0, this.iniX);
	},
	
	activate: function() {
		this.custom(this.getX(), this.iniX);
	},
	
	deactivate: function() {
		this.custom(this.getX(), 0);
	}
});

//
fx.Opacity.prototype = Object.extend(fx.Opacity.prototype, {
	fadeout: function() {
		if (this.now >= .9999) this.custom(1, 0);
	}
});

// added functions from prototype.js
Object.extend(Element, {
	getStyle: function(element, style) {
		element = $(element);
		var value = element.style[style];
			if (!value) {
			if (document.defaultView && document.defaultView.getComputedStyle) {
				var css = document.defaultView.getComputedStyle(element, null);
				value = css ? css.getPropertyValue(style) : null;
			} else if (element.currentStyle) {
				value = element.currentStyle[style];
			}
		}
		
		if (window.opera && ['left', 'top', 'right', 'bottom'].include(style))
		if (Element.getStyle(element, 'position') == 'static') value = 'auto';
		
		return value == 'auto' ? null : value;
	}
});
