/*var images;
var right_icon;
var left_icon;

var dir = "none"; //the direction of the slide (right/left/none)

//slow_interval & fast_interval is how many pixels to move on each slide
//slow_delay & fast_delay is the number of milliseconds to delay each move
//a higher interval value will make the scroll look faster, a low value: slower
//a higher delay slows it down, a low delay makes it faster
//but be careful, too high an interval may appear choppy (depending on the interval values)
var slow_interval = 5; //the number of pixels to move on each slide, while mouseover
var fast_interval = 10; //the number of pixels to move on each slide, while mousedown
var slow_delay = 50; //the time to delay each slide, while mouseover
var fast_delay = 10; //the time to delay each slide, while mousedown

var img_length; //the width of a whole group of images (with padding)
var double_img_length;
var img_id; //the id of the selected image
var prev_img_id = ""; //the id of the previously selected image;

var moved = false;

function initslider()
{
	images = document.getElementById("images");
	right_icon = document.getElementById("right");
	left_icon = document.getElementById("left");
	if( right_icon && left_icon )
	{
		//grab the width of one set of images that has been written into a hidden input
		img_length = parseInt(document.getElementById("width").value);
		double_img_length = img_length * 2;
		
		//create copies of the image set before and after the orig set, so the edges don't drop off
		var prev = document.getElementById("pre_images");
		var next = document.getElementById("post_images");
		var orig = document.getElementById("orig_images");
		prev.innerHTML = orig.innerHTML;
		next.innerHTML = orig.innerHTML;
		
		right_icon.onmouseover = startslideright;
		right_icon.onmousedown = startfastslideright;
		right_icon.onmouseout = stopslide;
		right_icon.onmouseup = stopslide;
		
		left_icon.onmouseover = startslideleft;
		left_icon.onmousedown = startfastslideleft;
		left_icon.onmouseout = stopslide;
		left_icon.onmouseup = stopslide;
	}
}

function startslideright(e)
{
	moved = true;
	dir = "right";
	slide(slow_delay, slow_interval);
}

function startfastslideright(e)
{
	moved = true;
	dir = "right";
	slide(fast_delay, fast_interval);
}

function startslideleft(e)
{
	dir = "left";
	if( !moved )
		images.style.left = "-" + img_length + "px";
	moved = true;
	slide(slow_delay, slow_interval);
}

function startfastslideleft(e)
{
	moved = true;
	dir = "left";
	slide(fast_delay, fast_interval);
}

function stopslide()
{
	dir = "none";
}

function slide(delay, interval)
{
	if( dir == "right" )
	{
		right_position = parseInt(images.style.left) - interval;
		if( right_position < (-1 * double_img_length) )
			addLeft();
		else
			images.style.left = right_position + "px";
		setTimeout("slide(" + delay + ", " + interval + ")", delay);	
	}
	else if( dir == "left" )
	{
		right_position = parseInt(images.style.left) + interval;
		if( right_position > 0 )
			addRight();
		else
			images.style.left = right_position + "px";
		setTimeout("slide(" + delay + ", " + interval + ")", delay);	
	}
}

//addLeft and addRight functions are called when we run out of images
//they reset the whole group to the necessary alignment, depending on which way we're scrolling
function addLeft()
{
	images.style.left = "0px";
}

function addRight()
{
	images.style.left = "-" + parseInt(img_length + img_length) + "px";
}*/

var images;
var start;
var end;
var interval = 10;
var delay = 2;
var difference;
var width = 810;

var number;

var count = 5;

function shiftRight()
{
	number = document.getElementById("number").value;
	images = document.getElementById("images");
	start = parseInt(images.style.left);
	end = start - width;
	goShiftRight();
	count = count + 5;
	checkCount();
}

function goShiftRight()
{
	if( start > end )
	{
		start -= interval;
		images.style.left = start + "px";
		setTimeout('goShiftRight()', delay);
	}
}

function shiftLeft()
{
	number = document.getElementById("number").value;
	images = document.getElementById("images");
	start = parseInt(images.style.left);
	end = start + width;
	goShiftLeft();
	count = count - 5;
	checkCount();
}

function goShiftLeft()
{
	if( start < end )
	{
		start += interval;
		images.style.left = start + "px";
		setTimeout('goShiftLeft()', delay);
	}
}

function checkCount()
{
	if( count <= 5 )
	{
		document.getElementById("right").onclick = shiftRight;
		document.getElementById("right").className = "right";
		document.getElementById("right").innerHTML = "<a href=\"javascript: void(0);\">&nbsp;</a>";
		document.getElementById("left").onclick = "";
		document.getElementById("left").className = "left_na";
		document.getElementById("left").innerHTML = "<a>&nbsp;</a>";
	}
	else if ( count >= number )
	{
		document.getElementById("left").onclick = shiftLeft;
		document.getElementById("left").className = "left";
		document.getElementById("left").innerHTML = "<a href=\"javascript: void(0);\">&nbsp;</a>";
		document.getElementById("right").onclick = "";
		document.getElementById("right").className = "right_na";
		document.getElementById("right").innerHTML = "<a>&nbsp;</a>";
	}
	else
	{
		document.getElementById("left").onclick = shiftLeft;
		document.getElementById("left").className = "left";
		document.getElementById("left").innerHTML = "<a href=\"javascript: void(0);\">&nbsp;</a>";
		document.getElementById("right").onclick = shiftRight;
		document.getElementById("right").className = "right";
		document.getElementById("right").innerHTML = "<a href=\"javascript: void(0);\">&nbsp;</a>";
	}
}
