
var Fx = function(el) {

	this.fps = 60;
	this.position = 0;
	this.duration = 2000;
	
	this.speed = ( this.duration / this.fps );
	
	var element = el;
	var callback = null;
	var timer = null;
	var self;
	
	this.fadeIn = function() {
		self = this;		
		this.position = 0;
		timer = setInterval(function(){ self.stepIn(); }, self.speed);
		if( arguments ) callback = arguments[0];
	}
	
	this.stepIn = function() {
		this.set( this.position );
		this.position++;
		if( element.style.display == "none" ) element.style.display = "block";
		if( this.position > 10 ) {
			clearInterval(timer);
			this.position = 0;
			if( callback ) callback();
		}	
	}
	
	this.fadeOut = function() {
		self = this;		
		this.position = 10;
		timer = setInterval(function(){ self.stepOut(); }, self.speed);
		if( arguments ) callback = arguments[0];
	}
	
	this.stepOut = function() {
		this.set( this.position );
		this.position--;
		if( element.style.display == "none" ) element.style.display = "block";
		if( this.position < 0 ) {
			clearInterval(timer);
			element.style.display = "none";
			this.position = 10;
			if( callback ) callback();
		}	
	}
	
	this.set = function(v) {
		var value = ( v > 9 ) ? "1.0" : "0." + v ;
		if (window.ActiveXObject) {
			element.style.filter = (v == 10) ? '' : 'alpha(opacity=' + value * 100 + ')';
			element.style.zoom = 1;
		}
		element.style.opacity = value;
	}
};
