/**
* AnimationStepper
*
* Stores the object being animated and the function which should be called upon step.  The step function should return true as long as the 
* animation is to continue, and should return false as soon as it is to stop.
*
* @param object_to_animate
* @param animation_function
**/
function AnimationStepper( object_to_animate, animation_function ) {

	this.object_to_animate = object_to_animate;
	this.animation_function = animation_function;

	this.current_animation_step = 0;
	this.current_state_step = 0;
	
	this.animation_state = "default";

}

new AnimationStepper();

/**
* AnimationStepper.setState
*
* Sets the state value and resets the current_state_step counter
*
* @param s The new state
**/
AnimationStepper.prototype.setState = function( s ) { 
	
	this.animation_state = s;
	this.current_state_step = 0;

}

/**
* AnimationStepper.getState
*
* @returns the Current state
**/
AnimationStepper.prototype.getState = function() { 

	return this.animation_state;

}

/**
* AnimationStepper.getStateStep
*
* @returns the current state step count
**/
AnimationStepper.prototype.getStateStep = function() { 

	return this.current_state_step;

}

/**
* AnimationStepper.step
*
* Increment the animation step and call the animation_function and passes the following parameters:
*   -the AnimationStepper 
*
**/
AnimationStepper.prototype.step = function() { 

	this.current_animation_step ++;
	this.current_state_step ++;

	return this.animation_function( this );

}

