/**
 * Slide Show
 * Author: Thomas Peri
 * (c) 2008 Bent Media, Inc.
 * Last Change: 2008-01-15
 *
 * See SlideShow.html for example usage.
 */
function SlideShow(settings)
{
	function setImage(index)
	{
		while(target.firstChild)
		{
			target.removeChild(target.firstChild);
		}
		target.appendChild(imgs[index]);
	}

	var source = settings.source,
		target = settings.target;
	
	var i, img, imgs = [], lis;
	
	if (!( source = document.getElementById(source) )) { return null; }
	if (!( target = document.getElementById(target) )) { return null; }
	if (!( lis = source.getElementsByTagName('li') ).length) { return null; }
	
	for (i = 0; i < lis.length; i++)
	{
		if ((img = lis[i].getElementsByTagName('img')).length)
		{
			img = img[0];
			imgs[imgs.length] = img.cloneNode(false);
			img.onclick = (function(i) {
				return function()
				{
					setImage(i);
				};
			})(i);
		}
	}

	this.setImage = setImage;

	setImage(0);
}
