// JavaScript Document

// Scrolling Image Selectors

// config
	var SIS_interval = 1000;
	var SIS_thumbwidth = 87;
	
// variables	
	var SIS_running = true;
	var SIS_pos = 0;
	var SIS_cycle;
	var SIS_displayed;
	var SIS_sdiv;

//functions

function SIS_step()
{
	var newoffset;
	
	if (SIS_running)
	{
		// calc new offset
		SIS_pos = SIS_pos + 1;
		if (SIS_pos < SIS_cycle)
		{
			newoffset = 0 - SIS_pos;
		}
		else
		{
			SIS_pos = 0;
			newoffset = 0;
		}
		SIS_sdiv.style.left = newoffset + "px";
		
		var t = setTimeout("SIS_step()", SIS_interval);

	}
	else
	{
		var t = setTimeout("SIS_step()", 500);
	}
}


function SIS_init(speed)
{
	// only init when W3C DOM
	if (!document.getElementById)
	{
		return;
	}
	
	// first get sizes
	var thumbs = document.getElementsByName("sis_thumb");
	var fills = document.getElementsByName("sis_fill");
	var images = document.getElementsByName("sis_bigimage");

	var totalw = (thumbs.length + fills.length) * (SIS_thumbwidth+1);
	SIS_sdiv = document.getElementById("sis_thumbs");
	SIS_sdiv.style.width = totalw + "px";			// set correct width of scrolling layer
	
	// start/stop scrolling function
	x = document.getElementById("sis_selector");
	x.onmouseover = function()
	{
		SIS_running = false;
	}
	x.onmouseout = function()
	{
		SIS_running = true;
	}
	
	
	SIS_cycle = thumbs.length * SIS_thumbwidth;
	// setup big image
	SIS_displayed = images[0];
	SIS_displayed.style.display = "block";
	
	//----
	
	for (x=0 ; x < thumbs.length; x++)
	{
		th = thumbs[x];
		th.sis_image = images[x];		//big picture reference		
		
		th.onmouseover = function()
		{
			SIS_displayed.style.display = "none"; 			
			i = this.sis_image;
			i.style.display = "block";
			SIS_displayed = i;
		}

		if (x < fills.length)
		{
			f = fills[x];
			f.sis_image = th.sis_image;
			f.onmouseover = th.onmouseover;
		}
	
	}
	// thumbs initiated

	SIS_interval = 1000 / speed;
	var t = setTimeout("SIS_step()", SIS_interval);
}

