// JavaScript Document
function AnimationFade( el, att ) {

	this.el = el;

	this.milisec = att.milisec;

	this._ctrl = null;

	this.stop = function() {
		if( this._ctrl != null )
			clearInterval(this._ctrl);
	}

	var variance = 8;

	this.opacity = 0;
	
	this.show = function() {

		var objFade = this;
		
		var f = function( ) {

			if( objFade.opacity > 100 ) {
				objFade.stop();
			} else if( objFade.opacity == 0 ) {
				Util.manipulaEl(objFade.el,"show");
			}

			objFade.el.style.filter		= 'alpha(opacity=' + objFade.opacity + ')';
			objFade.el.style.MozOpacity	= objFade.opacity / 100;
			objFade.opacity += variance;
		}

		this.stop();

		this._ctrl = setInterval( f , this.milisec );
	}

	this.hide = function() {

		var objFade = this;
		
		var f = function( ) {

			if( objFade.opacity < 0 ) {
				objFade.stop();
				Util.manipulaEl(objFade.el,"hide");
			}

			objFade.el.style.filter		= 'alpha(opacity=' + objFade.opacity + ')';
			objFade.el.style.MozOpacity	= objFade.opacity / 100;
			objFade.opacity -= variance;
		}

		this.stop();

		this._ctrl = setInterval( f , this.milisec );
	}
}