//create an image scroller object
var imageScroller;

//delay all code execution untill after page load
addAnEvent(window, "load", loadScroller);

    function loadScroller() {
	
		timer = window.setTimeout("scrollImages()", 300);
    };
	
var direction;
function scrollImages() {
	//set how many thumb shown, 3 in this example, modify to your number
	var currentThumbnail = imageScroller.getCurrentThumbIndex();
	var lastThumbnail = imageScroller.getThumbnailCount();
	
	var scrollType = imageScroller.getScrollType();
	
	if (scrollType == 0) {
		var currentPosition = parseInt(document.getElementById("imageScrollerImageRow").style.left);
		var endPosition = -1 * (parseInt(document.getElementById("imageScrollerImageRow").style.width) - parseInt(document.getElementById("imageScrollerFrame").style.width));
	} else {
		var currentPosition = parseInt(document.getElementById("imageScrollerImageRow").style.top);
		var endPosition = -1 * imageScroller.iNumOfThumbsShownHeightTotal_;
	}
	
	//0=forward, 1=backward
	//if we are at image 1, go forward, if we are on last one, go backward
	if (currentPosition > (endPosition + 2)) {
		direction = 0;
	} else {
		direction = 1;
	}
	
	//move the scroller based on direction
	if (direction == 0) {
		if (scrollType == 0) {
			imageScroller.smoothScrollForward();
		} else {
			imageScroller.smoothScrollUp();
		}
	} else {
		if (scrollType == 0) {
			imageScroller.smoothScrollReverse();
		} else {
			imageScroller.smoothScrollDown();
		}
	}
	//call it again for next scroll
	timer = window.setTimeout("scrollImages()", 1);
};
