function fade( sp )
{
	this.img_ = new Array();
	this.dir  = new Array();
	this.op   = new Array();
	this.speed = sp;
	this.imgTag = "fade";
}

fade.prototype.continua=function()
{

	for(var i=0; i<this.img_.length; i++ )
	{
		 this.op[i]+=this.dir[i]*this.speed;
 		 
		 if( this.op[i]<=0 ) this.op[i]=0;
		 if( this.op[i]>=100 ) this.op[i]=100;

		 this.img_[i].style.MozOpacity = (this.op[i])/100; 
		 this.img_[i].style.filter = "alpha(opacity=" + this.op[i] + ")";
	}
}

fade.prototype.add=function( object )
{

	if( (index=this.is( object )) != -1 )
	{
		this.dir[ index ]=-1;
		return;
	}
	
	this.img_[ this.img_.length ] = object ;
	this.dir[ this.dir.length ] = -1;
	this.op [ this.op.length  ] = 100;
}

fade.prototype.is=function( object )
{

 for( i=0; i<this.img_.length; i++ )
	if( this.img_[i].id == object.id ) 
		return i;

 return -1;
}

fade.prototype.inc=function( object )
{
	this.dir[ this.is( object ) ]=1;
}

fade.prototype.init=function()
{
	var imgs = document.getElementsByTagName( "img" );

	for( var i=0; i<imgs.length; i++ )
	{
		if( imgs[i].name==this.imgTag )
		{
			imgs[i].effect = this;
			imgs[i].onmouseover = function(){ this.effect.add(this);}
			imgs[i].onmouseout = function(){ this.effect.inc(this);}
		}
	}
}
