/* --------------------------------------------------------------------*\
*                                                                       *
*  This file is a part of ArtWeb effects manager, created by ArtWeb OÜ. *
*                                                                       *
*  Any unauthorized use of this file is strictly prohibited.            *
*  For all questions concerning the usage of this code please send an   * 
*  email to info@art-web.ee or contact us on http://www.art-web.ee      *
*                                                                       *
/* --------------------------------------------------------------------*/

function artWebEffect_opacity()
{
	this.renderFrame = function(frame)
	{
		var direction = 1;
		var startOpacity = this.startOpacity;
		var endOpacity = this.parameters.end;
		var opacityStep = this.parameters.step;
		if (startOpacity > endOpacity)
		{
			direction = -1;
		}
		var currentOpacity = (startOpacity + opacityStep * frame * direction);
		if (currentOpacity*direction > endOpacity*direction) currentOpacity = endOpacity;
		opacityHandler.setOpacity(this.element, currentOpacity);
	}
	this.calculateFramesCount = function()
	{
		var direction = 1;
		if (this.parameters.start)
		{
			var startOpacity = this.parameters.start;
		}
		else
		{
			var startOpacity = opacityHandler.getOpacity(this.element);
		}
		this.startOpacity = startOpacity;
		var endOpacity = this.parameters.end;
		var opacityStep = this.parameters.step;
		var framesCount = 0;
		
		if (startOpacity > endOpacity)
		{
			direction = -1;
		}
		var opacityChange = (endOpacity - startOpacity)*direction;
		
		framesCount = (opacityChange / opacityStep);
		return framesCount;
	}
	
	var instance = this;
	this.opacityType = false;
	this.defaults = {end: 0, step: 0.01};
}
