//alert( "animation.js" );
/*
function timer()
{
	var timeout_ms;
	var timerObj = null;

	function _cbTimeout()
	{
		this.timerObj = setTimeout( 'this.cbTimeout();', this.timeout_ms );
		if( this.cbDoWork != null )
		{
			this.cbDoWork();
		}
	}

	function _start( timeout_ms, cbDoWork )
	{
		this.timeout_ms = timeout_ms;
		this.cbDoWork = cbDoWork;
		this.timerObj = setTimeout( 'this.cbTimeout();', timeout_ms );
	}

	this.cbTimeout = _cbTimeout;
	this.start = _start;
	this.cbDoWork = null;
};
*/

var g_animTimer;
var g_animFileRangeMin;
var g_animFileRangeMax;
var g_animCurrentImageId;
var g_animImageObject;
var g_animTimeout;
var g_animImageList = new Array();


function cbTimeoutWork()
{
	g_animImageObject.src = g_animImageList[g_animCurrentImageId].src;
	g_animCurrentImageId++;
	if( g_animCurrentImageId > g_animFileRangeMax )
	{
		g_animCurrentImageId = g_animFileRangeMin;
	}
//...
	g_animTimer = setTimeout( 'cbTimeoutWork();', g_animTimeout );	
}



function animLoadImageList( fileName, fileType, docImageId, rangeMin, rangeMax, cycle_ms )
{
// alert( 'loadImageListFromFiles( ' + fileName + ', ' + fileType + ', ' + docImageId + ', ' + rangeMin + ', ' + rangeMax + ', ' + cycle_ms + ' );' );
//	g_animTimer = new timer();
	g_animImageObject = document.getElementById( docImageId );
	g_animImageObject.onload = '';
	g_animFileRangeMin = rangeMin;
	g_animFileRangeMax = rangeMax;
	g_animCurrentImageId = rangeMin;
	g_animTimeout = cycle_ms;

	for( var i = rangeMin; i <= rangeMax; i++ )
	{
		g_animImageList[i] = new Image;
		g_animImageList[i].src = fileName + ( ( i < 10 ) ? ( '0' + i ) : i ) + fileType;
	}

//	g_animTimer = setTimeout( 'cbTimeoutWork();', cycle_ms );	
//	g_animTimer.start( cycle_ms, cbTimeoutWork );
}

function animStart()
{
	g_animTimer = setTimeout( 'cbTimeoutWork();', g_animTimeout );
}

function animStop()
{
	clearTimeout( g_animTimer );
}
