var wait = 40; // controls speed, higher is slower (ms)
var pause_wait = 1000; // controls pause, higher is longer (ms)
var scroll_step = 2; // number of px to scroll each time around
var scroller;  // these two will hold timeouts
var pause;
var item_size = 160;  //these come straight from the css, used for math
var list_size = 518;

function scroll() {
	wrapper.scrollLeft += scroll_step;
	if (wrapper.scrollLeft % item_size == 0) {
		stop_scroll();
		pause = setTimeout('start_scroll()', pause_wait);
		return;
	}
	all_size = wrapper.firstChild.childNodes.length * item_size - 10;
	if (wrapper.scrollLeft == (2 * all_size) - list_size)
		wrapper.scrollLeft -= all_size;
	start_scroll();
}
function stop_scroll() {
	clearTimeout(scroller);
	clearTimeout(pause);
}
function start_scroll() {
	stop_scroll();
	scroller = setTimeout('scroll()', wait);
}
function horizscroll() {
	var i = 0;
	// this just cleans out the empty text nodes...
	// only needed for conditional scrolling.
	wrapper.normalize();
	while (i < wrapper.firstChild.childNodes.length) {
		if (wrapper.firstChild.childNodes.item(i).nodeName == '#text')
			wrapper.firstChild.removeChild(wrapper.firstChild.childNodes.item(i));
		i++;
	}
	if (wrapper.firstChild.childNodes.length <= 2)
		return;
	newdiv = wrapper.firstChild.cloneNode(true);
	newdiv.style.left  = wrapper.firstChild.childNodes.length * item_size + 'px';
	wrapper.appendChild(newdiv);
	start_scroll();
}

