﻿function Fx(obj, ini, end, spd, inc, prp)
{
	this.Ini 		= parseInt(ini);
	this.End 		= parseInt(end);
	this.Obj 		= document.getElementById(obj);
	this.Val 		= parseInt(ini);
	this.Speed		= parseInt(spd);
	this.Inc		= parseInt(inc);
	this.Prp		= prp;
	this.Stopped	= false;
	this.OnEnd		= null;
	
	var _ref = this;
	
	this.Obj.style.overflow = 'hidden';
		
	this.Start = function()
	{
		this.Update();
	}
	
	this.Stop = function()
	{
		this.Stopped = true;
	}
	
	this.Update = function()
	{
		if(!this.Stopped)
		{
			var _continue = true;
			
			if(this.Ini < this.End)
			{
				this.Val = parseInt(this.Val + this.Inc);
				
				if(this.Val >= this.End) _continue = false;
			}
			else
			{
				this.Val = parseInt(this.Val - this.Inc);
				
				if(this.Val <= this.End) _continue = false;
			}
			
			try
			{
				switch(this.Prp)
				{
					case 'width':
						this.Obj.style.width = this.Val + 'px';
						break;
					case 'height':
						this.Obj.style.height = this.Val + 'px';
						break;
					case 'left':
						this.Obj.style.left = this.Val + 'px';
						break;
					case 'top':
						this.Obj.style.top = this.Val + 'px';
						break;
					case 'alpha':
						if(document.all)
						{
							this.Obj.style.filter = 'Alpha(Opacity='+ this.Val +')';
						}
						break;	
					case 'textIndent':
						this.Obj.style.textIndent = this.Val + 'px';
						break;				 
				}
			}
			catch(e)
			{
			}
		
			if(_continue)
			{
				window.setTimeout( function(e)
				{
					_ref.Update();
				}, this.Speed);
			}
			else
			{
				if(this.OnEnd != null) this.OnEnd();
			}
		}	
	}
}