/*
  How to USE:

  Add to following code to the body tag:

	onload="image_scroll( <img tag>, <time delay>, <image files to scroll...> )"

	img tag = name of the image tag containing the initial scrolling image
	time delay = time between image scroll in milliseconds
	image files = filenames( with path if need no in same folder ) for the images to be scrolled

  Example:

	onload="image_scroll('scrollimg','3000','images/img1.gif','images/img2.gif',''images/img3.gif')"

	The image to be scroll is in the tag <img name="scrollimg" ....>. The delay time is set to 3
	seconds and the images to be scrolled are img1.gif, img2.gif, img3.gif located in the images folder.

	NOTE: Remember to use single quote for the items inside the function.	




*/



var image_scroll_imgs = new Array();		// array storing the scolling images
var image_scroll_count = 0;			// counter keeping track of with image is being displayed
var image_scroll_valid = 0;			// indicate whether the script has the data it needs to run correctly
var image_scroll_obj = "img_scroll";		// name of the img tag to scroll (defacult = img_scroll)
var image_scroll_time = 5000;			// wait time before scrolling in millisecond (defacult 5000 --> 5 sec)


function image_scroll() {
	var args = image_scroll.arguments;
	var args_length = args.length;
	
	
	if( args_length >= 2 ) {

		image_scroll_obj = args[0];
		image_scroll_time = parseInt(args[1]);

		var i=0;
		for( i=2; i < args_length; i++) {
			image_scroll_imgs[i-2] = new Image();
			image_scroll_imgs[i-2].src = args[i];
		}
		valid = 1;
	}

	if( valid ) {
	
		if(image_scroll_count == image_scroll_imgs.length) {
			image_scroll_count = 0;
		}
		
		eval("document." + image_scroll_obj + ".src = image_scroll_imgs[image_scroll_count++].src");
		timerID = setTimeout("image_scroll()",image_scroll_time);
	}



}//Image_scroll