// JavaScript Document
$move_bycan = 430;
$frame_leftcan = 0;
$frame_nocan = 1;




$(document).ready(function()
{
	
	$max_clickscan = $("#image_containercan").children().size(); 	
	
	/* Kudos to Rob MacKay [http://www.twitter.com/svgrob] for suggesting that we don't have to put a canic style="width: 3960px" attribute in the div tag */
		$(".prevcan").fadeOut();
	$(".prevcan").click(function()
		{
   			/* Set the new position & frame number */
			$new_frame_nocan = (($frame_nocan/1)-1);

			$new_leftcan = (($frame_leftcan/1) + $move_bycan);
			/* Check if we're moving too far over */
			if($new_frame_nocan == 1)

				{$(".prevcan").fadeOut();			}
			else if($frame_nocan == $max_clickscan )
				{$(".nextcan").fadeIn();}
			
			if($new_frame_nocan <= 0)
				{
					/* Move the images all the way left, minus one frame */
					$new_leftcan = -($move_bycan*$max_clickscan)+$move_bycan;
					$new_frame_nocan = $max_clickscan;
					   
				}
			$new_left_attrcan = $new_leftcan+"px";
			$("#image_containercan").animate({left: $new_left_attrcan}, 800 );
			$frame_leftcan = $new_leftcan;
			$frame_nocan = $new_frame_nocan;
			
		});
	$(".nextcan").click(function()
		{
			/* Set the new position & frame number */
			$new_frame_nocan = (($frame_nocan/1)+1);
			$new_leftcan = (($frame_leftcan/1) - $move_bycan);
			/* Check if we're moving too far over */
			
			if ($new_frame_nocan == $max_clickscan)
				{$(".nextcan").fadeOut();}
			else if ($frame_nocan == 1)
			{$(".prevcan").fadeIn();}
			
			if($new_frame_nocan > $max_clickscan)
				{		
						/* Move all the way right, to the beginning*/
					$new_leftcan = 0;
					$new_frame_nocan = 1;
				
				}				
			$new_left_attrcan = $new_leftcan+"px";
			
			$("#image_containercan").animate({left: $new_left_attrcan}, 800 );
			$frame_leftcan = $new_leftcan;
			$frame_nocan = $new_frame_nocan;
		});	
});







