// JavaScript Document
$move_bymother = 421;
$frame_leftmother = 0;
$frame_nomother = 1;




$(document).ready(function()
{
	
	$max_clicksmother = $("#image_containermother").children().size(); 	
	
	/* Kudos to Rob MacKay [http://www.twitter.com/svgrob] for suggesting that we don't have to put a motheric style="width: 3960px" attribute in the div tag */
		$(".prevmother").fadeOut();
	$(".prevmother").click(function()
		{
   			/* Set the new position & frame number */
			$new_frame_nomother = (($frame_nomother/1)-1);

			$new_leftmother = (($frame_leftmother/1) + $move_bymother);
			/* Check if we're moving too far over */
			if($new_frame_nomother == 1)

				{$(".prevmother").fadeOut();			}
			else if($frame_nomother == $max_clicksmother )
				{$(".nextmother").fadeIn();}
			
			if($new_frame_nomother <= 0)
				{
					/* Move the images all the way left, minus one frame */
					$new_leftmother = -($move_bymother*$max_clicksmother)+$move_bymother;
					$new_frame_nomother = $max_clicksmother;
					   
				}
			$new_left_attrmother = $new_leftmother+"px";
			$("#image_containermother").animate({left: $new_left_attrmother}, 800 );
			$frame_leftmother = $new_leftmother;
			$frame_nomother = $new_frame_nomother;
			
		});
	$(".nextmother").click(function()
		{
			/* Set the new position & frame number */
			$new_frame_nomother = (($frame_nomother/1)+1);
			$new_leftmother = (($frame_leftmother/1) - $move_bymother);
			/* Check if we're moving too far over */
			
			if ($new_frame_nomother == $max_clicksmother)
				{$(".nextmother").fadeOut();}
			else if ($frame_nomother == 1)
			{$(".prevmother").fadeIn();}
			
			if($new_frame_nomother > $max_clicksmother)
				{		
						/* Move all the way right, to the beginning*/
					$new_leftmother = 0;
					$new_frame_nomother = 1;
				
				}				
			$new_left_attrmother = $new_leftmother+"px";
			
			$("#image_containermother").animate({left: $new_left_attrmother}, 800 );
			$frame_leftmother = $new_leftmother;
			$frame_nomother = $new_frame_nomother;
		});	
});







