var MALAdSprite = function ($options, $callback) {
	this.frame = 0;
	this.options = $options;
	this.callback = $callback;

	if (this.options.frames && this.options.time) {
		this.delay = new MALAdDelay();
		this.delay.sprite = this;

		this.options.frames--;

		this.delay.start(this.options.delay, function () {


			if (this.sprite.frame > this.sprite.options.frames) {
				this.remove();
				return;
			}

			this.sprite.callback.apply(this.sprite);

			var time = this.sprite.options.time;

			if (typeof time === 'number') {
				this.start(time/this.sprite.options.frames);
			} else if ((typeof(time)==='object')?time.constructor.toString().match(/array/i)!==null||time.length!==undefined:false) {
				this.start(time[this.sprite.frame-1]);
			} else if ((typeof(time)==='object')?time.constructor.toString().match(/object/i)!==null:false) {
				this.start(typeof time[this.sprite.frame] != 'undefined' ? time[this.sprite.frame] : time.defaultTime);
			}

			this.sprite.frame++;
		});
	}
};

