var len = 0;
var move = 0;
var left_no = 0;
var right_no = 5;
$().ready(function(){  
	$("#thumb div ul li").each(function(){len++;});
	left_no = len - 1;
	$("#rightarrow").click(function(){
		if(right_no == len) return;
		move -= 108;
		$("#thumb div ul").stop().animate({"right": move + "px"});
		right_no++;
		left_no--;
	});
	$("#leftarrow").click(function(){
		if(left_no == len) return;
		move += 108;
		$("#thumb div ul").stop().animate({"right": move + "px"});
		right_no--;
		left_no++;
	});	
	$("#bigphoto ul li img").animate({"opacity":"0"},{duration:0});
	$select_item = $("#bigphoto ul li:first img").animate({"opacity":"1"},{duration:0});
	$("#thumb ul li img").click(function(){
		$this = $(this);		
		$select_item.stop().animate({"opacity":"0"}, function(){
			$select_item = ShowSlide(GetSelectPhoto($this));
		});
	});	
});
function GetSelectPhoto($this)
{
	var i = 0;
	var j = 0;
	$("#thumb ul li img").each(function(){
		if($this.attr("src") == $(this).attr("src"))
			j = i;
		i++
	});
	return j;
}
function ShowSlide(index)
{
	var i = 0;	
	$("#bigphoto ul li img").each(function(){
		if(i == index)
		{
			$(this).animate({"opacity":"1"},{duration:300});
			$this = $(this);
		}
		i++;
	});
	return $this;
}
