var Animator = function() {
	// CONSTRUCTOR /////////////////////////////////////////
	this.story = 0;
	jQuery(this).bind('animate', this.animateHander);
}
Animator.prototype.version = '0.01';
Animator.prototype.debug = false;
Animator.prototype.stories = new Array;
Animator.prototype.loop = false;
Animator.prototype.animateHander = function() {
	var self = this;
	
	if(this.stories.length > 0 && this.story < this.stories.length) {
		if(this.stories[this.story].exec) {
			this.stories[this.story].exec();
		} else if(this.debug) {
			alert('DEBUG: stories['+ this.story + '].exec() is undefined.');
		}
		
		if(++this.story >= this.stories.length) {
			if(this.loop) {
				this.story = 0;
			} else {
				if(this.debug) {
					alert('DEBUG: Finished.');
				}
				return true;
			}
		}
		window.setTimeout(function() {
			jQuery(self).trigger('animate');
		}, this.stories[this.story].wait ==undefined ? 1000 : this.stories[this.story].wait);
	} else if(this.debug) {
		alert('DEBUG: story error.');
	}
}

Animator.prototype.run = function() {
	jQuery(this).trigger('animate');
}

