/**
 * @author pierre
 */


Yke.YkeTimer = function() {};


Yke.YkeTimer.Timer = function(delay)
{
	
	this.endTimerEvent = null;
	this.delay = delay;
	this.timerPrototype = null;
	
	
	/*public*/ this.Stop = function()
	{
		this.timerPrototype.stop();
	}
	
	/*private*/ StopBecauseTimerOver = function() //fonction callback du prototype timer donc this=timerproto
	{
		this.stop();
		timer.endTimerEvent();
	}

	/*public*/ this.go = function()
	{	
		this.timerPrototype = new PeriodicalExecuter( StopBecauseTimerOver , this.delay );
		var t = 0;
	}	

   
	
	
	/*PeriodicalExecuter.prototype.registerCallback = function() {
    this.intervalID = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
    }

    PeriodicalExecuter.prototype.stop = function() {
    clearInterval(this.intervalID);
    }*/
	
}
	
//	/*public*/// this.Id = Yke.YkeTimer._TimerInfo_.length; //la taille du tableau indique l'index du dernier timer crée
	
//	/*public*/ this.timerID = null;
//	/*public*/ this.timerRunning = false;
	
//	/*public*/ this.secs = delay; // Set the length of the timer, in seconds
	
//	/*public*/ this.endTimerEvent = null;
	
//	/*public*/ this.counter=0;
	
 //   /*public*/ this.go = function()
/*	{		
		Yke.YkeTimer._TimerInfo_[this.Id] = {StartTheTimer:this.StartTheTimer, 
											 secs:this.secs,
											 Stop:this.Stop,
											 timerID:this.timerID,
											 timerRunning:this.timerRunning,
											 endTimerEvent:this.endTimerEvent};
											 
		//alert("lauch timerID : "+this.timerID+" / id : "+this.Id);
		
		this.Stop();
    	this.StartTheTimer();	
	}
	
    /*public*/// this.Stop = function(id)
/*	{
		if(id==null) id=this.Id;
		
		if(Yke.YkeTimer._TimerInfo_[id].timerRunning)
		{
       		clearTimeout(Yke.YkeTimer._TimerInfo_[id].timerID);
			//alert("stop timerID : "+this.timerID+" / id : "+id);
		}
   		Yke.YkeTimer._TimerInfo_[id].timerRunning = false;
	}
	
	
   /*public*/// this.StartTheTimer = function(id)
/*	{
		if(id==null) id=this.Id;
			
		if (Yke.YkeTimer._TimerInfo_[id].secs<=0)
	    {
				Yke.YkeTimer._TimerInfo_[id].Stop(id);
			
				if(Yke.YkeTimer._TimerInfo_[id].endTimerEvent != null)
				{
					Yke.YkeTimer._TimerInfo_[id].endTimerEvent();
				}	
	    }
	    else
	    {
			Yke.YkeTimer._TimerInfo_[id].secs = Yke.YkeTimer._TimerInfo_[id].secs - 1;
	        Yke.YkeTimer._TimerInfo_[id].timerRunning = true;
			ref = 'Yke.YkeTimer._TimerInfo_['+id+'].StartTheTimer('+id+')';
	        Yke.YkeTimer._TimerInfo_[id].timerID = setTimeout(ref, 1000);			
	    }
	}
	
}*/

