var animationHandler = {
	
	aAll : [],	
	iNewIndex : 0,
	iAnimationsCount : 0,
	bProcessing : false,
	tTimer : null,
	iInterval : 10,
	aFunctions : [],	
	
	addAnimation : function(oAnimation) {
	
		this.aAll[++this.iNewIndex] = oAnimation;
		this.iAnimationsCount++;
		
		return this.iNewIndex;
	
	},
	
	removeAnimation : function(iIndex) {
		
		this.aAll[iIndex] = null;	
		this.iAnimationsCount--;		
		
	},
	
	start : function(oFunction) {
		
		if(!this.bProcessing) {
		
			this.bProcessing = true;		
			this.tTimer = setInterval('animationHandler.process()', this.iInterval);							
			
		}
		
		if(oFunction) {
			this.aFunctions[this.aFunctions.length] = oFunction;
		}		
	
	},
	
	process : function() {
		
		if(this.iAnimationsCount > 0) {
			
			for(var i in this.aAll) {					
			
				if(this.aAll[i] && this.aAll[i].process) {
					this.aAll[i].process();
				}
				
			}
			
		}
		else {
		
			this.bProcessing = false;
		
			clearInterval(this.tTimer);						
			
			if(this.aFunctions.length > 0) {
			
				for(var i in this.aFunctions) {
			
					if(this.aFunctions[i].fFunction) {				
					
						this.aFunctions[i].fFunction(this.aFunctions[i].aParams);			
						delete this.aFunctions[i];
						
					}
					
				}
				
			}
			
		}
	
	}
	
}