// JavaScript used to control our slideshow

//all the javascript function and variables are called l_something so they don't interfere with the short version of the picture_slider
var l_mutex_right = 0;	//used to block click on th eright arrow when we get at the end
var l_pic_widths = new Array();


function l_slidePicture(offset)
{
	l_current_index += offset;
	
	if (offset < 0)
		l_mutex_right = 0;
	
	if (l_mutex_right == 1)
	{
		l_current_index -= offset;
	}
	else
	{
	
		if (l_current_index < 0)
			l_current_index = 0;
		if (l_current_index >= l_num_pics)
			l_current_index = l_num_pics - 1;
			
		l_showPictures();
	}
}

function l_showPictures()
{
	var picDiv = document.getElementById("pictures_long");
	
	var i;
	var str = "";
	var j=0;
	var width=0;
	var cancelRightSlide = true;
	for (i = l_current_index; i < l_num_pics; i++)
	{
		
		width += (l_pic_widths[i] + 8);	//6 pixel padding + 2 for border
		if (width > l_max_width)
		{

			cancelRightSlide = false;
			width -= (l_pic_widths[i] + 8);
			
			if ((width <= l_max_width) && (width >= (l_max_width - 8)))		//the picture has to be at least 4 pixels wide
			{
				//do nothing...for now
			}
			else
			{
				str += "<a class=\"cursor_hand\" onclick=\"tb_show('', 'admin/uploads/development/" + l_d_id + "/" + l_pics[i] + ".jpg');\"><img src=\"admin/uploads/development/" + l_d_id + "/tnslideshow_" + l_pics[i] + ".jpg\" alt=\"\" style=\"height:71px; width:" + (l_max_width - width - 8) + "px;\" /></a>";
			}
			break;
		}
		
		str += "<a class=\"cursor_hand\" onclick=\"tb_show('', 'admin/uploads/development/" + l_d_id + "/" + l_pics[i] + ".jpg');\"><img src=\"admin/uploads/development/" + l_d_id + "/tnslideshow_" + l_pics[i] + ".jpg\" alt=\"\" /></a>";
		j++;

	}
	
	if (cancelRightSlide == false)
		picDiv.innerHTML = str;
	else
	{
		picDiv.innerHTML = str;
		l_mutex_right = 1;
	}
}