function MovieClip(container, framerate) {
    this._container = container;
	this._framerate = framerate;
	this._frames = new Array();
	this._curr_frame = 0;
}

MovieClip.prototype._container;
MovieClip.prototype._framerate;
MovieClip.prototype._frames;
MovieClip.prototype._curr_frame;

MovieClip.prototype.getContainerId = function() {
    return this._container;
}

MovieClip.prototype.getFramerate = function() {
    return this._framerate;
}

MovieClip.prototype.getFrames = function() {
    return this._frames;
}


MovieClip.prototype.render_current = function() {

	if (this._curr_frame < this._frames.length){
		
		// Se un frame � nullo non viene renderizzato nulla.
		// Serve per mantenere il frame precedente per pi� tempo.
		if( this._frames[this._curr_frame] == null){
			return true;
		}
		
		// sostituisce il contenuto del div con il frame corrente
		$("#"+this._container).empty();
		$("#"+this._container).append(this._frames[this._curr_frame]);
		
		// passa al prossimo frame
		this._curr_frame++;
		return true;
	}
	return false;
}

MovieClip.prototype.play = function() {

	if (this._curr_frame < this._frames.length){
		
		this.render_current();
		
		// setta un nuovo time-out
		setTimeout(this.play, 1000 / this._framerate);
		return true;	
    }
	else
	{
		return false;
	}
   
    
}

MovieClip.prototype.reset = function() {
	this._curr_frame = 0;
}