
/*

	Input: div html element
	Output: None.
	Side-effects: Slide div

	Max 20 pics. Too many and the copy-node-routin won't work properly. 
	This is not tested thoroughly.

	Works on div like this:

	div gallerywrapper overflow hidden
		div gallerythumbnails width 3000
 			ul
				li a img float left
				li a img
				...
 */

function Slideshow(o) {

	var l = 0;
	var ul = o.childNodes[1];
	var list = o.childNodes[1].childNodes;
	var node;
	var startnode;
	var intv = 30;	// interval value, ms

	var timer = setInterval(scroll, intv);
	o.addEventListener('mouseover', stopscroll, false);
	o.addEventListener('mouseout', startscroll, false);

	for (i = 1; i < list.length && i < 30; i = i+2) {
		node = list[i].cloneNode(true);
		ul.appendChild(node);
		if (i == 1)
			startnode = node;
	}

	function scroll() {
		$("#gallerythumbnails").animate({left: l}, {duration: 0});	// should only get info through function args (o)
		l = l - 1;
		if (l <= -startnode.offsetLeft)
			l = 0;
	}

	function stopscroll() {
		clearInterval(timer);
	}

	function startscroll() {
		timer = setInterval(scroll, intv);
	}
}

