// $Id$

var word_loop_images = new Array();

var loop_img = "";

var word_img_name = 'wordlp';

var s_img_Flag = false;

var indexIncr = 1;

var beginIndex = 1;
	
var minIndex = 1;

//	window.defaultStatus='';

function wordloop( numImages ) {

//	alert ( "wordloop: " + numImages );
		
//	for (i=1; i =< numImages ; i++) {
	for (i=1; i < numImages + 1; i++) {

			imgName = word_img_name + i;

			file_name = imgName + '.gif';

//	alert ( imgName );
			
			imgPath = "img/home/word_loop/" + file_name;

//			imgPath = document.images[i].src;

			imgHeight = 530; imgWidth = 96;
			
			word_loop_images[ imgName ] = new Image( imgWidth, imgHeight );

			word_loop_images[ imgName ].src = imgPath;		
	}
	
//	 img_array_done ( word_loop_images );
	init_seq ( 9, 2000, 4000 );
}


function init_seq ( a_Max, an_interval, a_pause ) {
// globals

	on_interval = an_interval;

	loop_pause = a_pause;
	
	img_ct = a_Max;
		
	set_img ( beginIndex );
;
}


function set_img ( imgIndex ) {

//	if ( imgIndex == minIndex  && indexIncr == -1 ) {  indexIncr = 1; setTimeout( "set_img (1)", 3000); return;}

	if ( imgIndex == img_ct ) { imgIndex = 0 }
	
	imgIndex = imgIndex + indexIncr;
	
//	alert ("imgIndex " + imgIndex);
		
//	document[ word_img_name ].src= word_loop_images[ imgIndex ].src
	var imgName = word_img_name + imgIndex;
	
//	alert ("imgIndex " + imgIndex);

	if ( ! word_loop_images[ imgName ].complete ) { 
	
		 setTimeout( "set_img ( " + ( imgIndex - 1 ) + " )", loop_pause);  
		
		return false;
	}
	
	document[ word_img_name ].src= word_loop_images[ word_img_name + imgIndex ].src;

//window.status='';

	var jsStatement = "set_img( " + imgIndex + " );";
	
	
//	on_interval = 1500;
	var	next_interval = Math.round( Math.random() * 1000 ) + 1500
	
	setTimeout( "set_img ( " + ( imgIndex ) + " )", next_interval);  

window.status='';

}
