/*
	|||||||     //||
	||   ||    // ||
	||   ||   //  ||
	|||||||  //|||||||
	|| ||         ||
	||  ||        ||
	||   ||       ||    LIBS
	
	$ ARVR 2008 $ 
	$ JS implementation of stack $
*/


	function EventStack()
	{
		this._stack     = new Array()  ;
		this._stack[0]  = false        ;
		this._pointer   = 0	          ;
		this._isRunning = false        ;
	}
	

	
	EventStack.prototype.addItem = function( object )
	{

		this._stack[ this._pointer ] = object ;
		this._pointer++ ;		  
	}
	
	
	EventStack.prototype.getNext = function()
	{
		var object = this._stack[0] ;
		
		for( t=0; t < this._pointer ; t++ )
			this._stack[ t ] = this._stack[ t + 1 ] ;
		
		this._stack[this._pointer] = false ;	

		this._pointer--  ;
		return object ;
	}


	EventStack.prototype.doNext = function()
	{
		var object = this._stack[0] ;

		this._isRunning = true ;

		for( t=0; t < this._pointer ; t++ )
			this._stack[ t ] = this._stack[ t + 1 ] ;

		this._stack[this._pointer] = false ;
		
		this._pointer--  ;
		object() ;

		
	}
	
	EventStack.prototype.isRunning =  function()
	{
		return this._isRunning ;
	}
	
	EventStack.prototype.hasNext =  function()
	{
		this._isRunning = false ;
		if ( this._pointer == 0  ) 
			return false ;
		else 
		 	return true ;
	}
	
	EventStack.prototype.nextZ =  function()
	{
		return ++this._zindex ;
	}
	