// JavaScript Document
$move_byfather = 421;
$frame_leftfather = 0;
$frame_nofather = 1;




$(document).ready(function()
{
	
	$max_clicksfather = $("#image_containerfather").children().size(); 	
	
	/* Kudos to Rob MacKay [http://www.twitter.com/svgrob] for suggesting that we don't have to put a fatheric style="width: 3960px" attribute in the div tag */
		$(".prevfather").fadeOut();
	$(".prevfather").click(function()
		{
   			/* Set the new position & frame number */
			$new_frame_nofather = (($frame_nofather/1)-1);

			$new_leftfather = (($frame_leftfather/1) + $move_byfather);
			/* Check if we're moving too far over */
			if($new_frame_nofather == 1)

				{$(".prevfather").fadeOut();			}
			else if($frame_nofather == $max_clicksfather )
				{$(".nextfather").fadeIn();}
			
			if($new_frame_nofather <= 0)
				{
					/* Move the images all the way left, minus one frame */
					$new_leftfather = -($move_byfather*$max_clicksfather)+$move_byfather;
					$new_frame_nofather = $max_clicksfather;
					   
				}
			$new_left_attrfather = $new_leftfather+"px";
			$("#image_containerfather").animate({left: $new_left_attrfather}, 800 );
			$frame_leftfather = $new_leftfather;
			$frame_nofather = $new_frame_nofather;
			
		});
	$(".nextfather").click(function()
		{
			/* Set the new position & frame number */
			$new_frame_nofather = (($frame_nofather/1)+1);
			$new_leftfather = (($frame_leftfather/1) - $move_byfather);
			/* Check if we're moving too far over */
			
			if ($new_frame_nofather == $max_clicksfather)
				{$(".nextfather").fadeOut();}
			else if ($frame_nofather == 1)
			{$(".prevfather").fadeIn();}
			
			if($new_frame_nofather > $max_clicksfather)
				{		
						/* Move all the way right, to the beginning*/
					$new_leftfather = 0;
					$new_frame_nofather = 1;
				
				}				
			$new_left_attrfather = $new_leftfather+"px";
			
			$("#image_containerfather").animate({left: $new_left_attrfather}, 800 );
			$frame_leftfather = $new_leftfather;
			$frame_nofather = $new_frame_nofather;
		});	
});







