if (typeof Effect == 'undefined') 
	throw("viacounter.js requires including script.aculo.us' effects.js library!");
	
var viacounter = Class.create();
viacounter.prototype = {


initialize: function(container, big) {
	 this.contain = $(container);
	 
	 
		
		this.big = big;
		
		this.counterinst = [];
		
		this.current = 0;
		
		var self = this;
		new Ajax.Request('/counter.php', {
  			onSuccess: function(transport) {
     		 
     		 
     		 
     		 var myNumber = transport.responseText;
     		 
     		 self.theInit(myNumber);
			
     		 
     		 
  			}
		});



		
		
		

			
		
		
	 
	},
	
	theInit: function(myNumber){
		
		this.mySplitResult = myNumber.split("");
		
		for(var i = this.mySplitResult.length; i > 0; i--){
			this.createCounter(this.contain, this.mySplitResult[i-1]);
		}
		
		this.startSpin();
	},
	
	createCounter: function(mod, num){
		

	var counters = new protocounter(mod, num, this.big);
	this.counterinst.push(counters)
	  
	  
	},
	startSpin: function() {
		
		this.counterinst[this.current].startSpin(this);
		
	},
	triggerNext: function() {
		
		if(this.current < this.mySplitResult.length-1)
		{
			this.current = this.current + 1;
			this.startSpin();
			
			
		}
		
	}
		
}