if (typeof window.RadControlsNamespace == "undefined")
{
	window.RadControlsNamespace = {};
}

RadControlsNamespace.Alpha = function (element, startValue, endValue, duration, framesCount)
{
	this.Element = element;
	this.StartValue = startValue;
	this.EndValue = endValue;
	this.Ticker = new RadControlsNamespace.Ticker(this);
	this.Ticker.Configure({Duration : duration, FramesCount : framesCount});
	this.Amount = Math.round((endValue - startValue)/framesCount);
}


RadControlsNamespace.Alpha.prototype.Show = function ()
{
	this.Coef = 1;
	this.Ticker.Start();
	this.Value = this.StartValue;
	this.UpdateOpacity();
}



RadControlsNamespace.Alpha.prototype.Hide = function ()
{
	this.Coef = -1;
	this.Ticker.Start();
	this.Value = this.EndValue;
	this.UpdateOpacity();
}

RadControlsNamespace.Alpha.prototype.OnTick = function ()
{
	this.Value += this.Coef * this.Amount;
	this.UpdateOpacity();
}

RadControlsNamespace.Alpha.prototype.OnTickEnd = function ()
{
	this.Element.style.filter = "";
}

RadControlsNamespace.Alpha.prototype.UpdateOpacity = function ()
{
	var el = this.Element;
    el.style.filter = 'alpha(opacity=' + (this.Value) + ')';
    var v = this.Value / 100;
    el.style.opacity = v;
    el.style['-moz-opacity'] = v;
    el.style['-khtml-opacity'] = v;
}

