function AnimationClass( dir, pictures, pictureID, times2show, speed ) { // AnimationClass this._dir = dir; this._pictures = pictures; this._pictureID = pictureID; this._times2show = times2show; this._speed = speed; this._intID = 0; this._count = 0; // show the first picture this.ChangePicture( ); } // AnimationClass AnimationClass.prototype.StartAnimation = function( ) { // StartAnimation var instant = this; this._intID = setInterval( function( ) { instant.ChangePicture( ); }, this._speed ); } // StartAnimation AnimationClass.prototype.ChangePicture = function( ) { // ChangePicture var whichPicture = Math.random( ); var len = this._pictures.length; var pictureID = document.getElementById( this._pictureID ); var whichPicture2 = whichPicture * len; var whichPicture3 = Math.floor( whichPicture2 ); pictureID.src = this._dir + this._pictures[ whichPicture3 ]; if ( this._times2show > 0 && this._times2show <= ++this._count ) { clearInterval( this._intID ); } } // ChangePicture