// JavaScript Document
$move_bytote = 422;
$frame_lefttote = 0;
$frame_notote = 1;




$(document).ready(function()
{
	
	$max_clickstote = $("#image_containertote").children().size(); 	
	
	/* Kudos to Rob MacKay [http://www.twitter.com/svgrob] for suggesting that we don't have to put a toteic style="width: 3960px" attribute in the div tag */
		$(".prevtote").fadeOut();
	$(".prevtote").click(function()
		{
   			/* Set the new position & frame number */
			$new_frame_notote = (($frame_notote/1)-1);

			$new_lefttote = (($frame_lefttote/1) + $move_bytote);
			/* Check if we're moving too far over */
			if($new_frame_notote == 1)

				{$(".prevtote").fadeOut();			}
			else if($frame_notote == $max_clickstote )
				{$(".nexttote").fadeIn();}
			
			if($new_frame_notote <= 0)
				{
					/* Move the images all the way left, minus one frame */
					$new_lefttote = -($move_bytote*$max_clickstote)+$move_bytote;
					$new_frame_notote = $max_clickstote;
					   
				}
			$new_left_attrtote = $new_lefttote+"px";
			$("#image_containertote").animate({left: $new_left_attrtote}, 800 );
			$frame_lefttote = $new_lefttote;
			$frame_notote = $new_frame_notote;
			
		});
	$(".nexttote").click(function()
		{
			/* Set the new position & frame number */
			$new_frame_notote = (($frame_notote/1)+1);
			$new_lefttote = (($frame_lefttote/1) - $move_bytote);
			/* Check if we're moving too far over */
			
			if ($new_frame_notote == $max_clickstote)
				{$(".nexttote").fadeOut();}
			else if ($frame_notote == 1)
			{$(".prevtote").fadeIn();}
			
			if($new_frame_notote > $max_clickstote)
				{		
						/* Move all the way right, to the beginning*/
					$new_lefttote = 0;
					$new_frame_notote = 1;
				
				}				
			$new_left_attrtote = $new_lefttote+"px";
			
			$("#image_containertote").animate({left: $new_left_attrtote}, 800 );
			$frame_lefttote = $new_lefttote;
			$frame_notote = $new_frame_notote;
		});	
});







