// JavaScript Document
$move_byxmas = 421;
$frame_leftxmas = 0;
$frame_noxmas = 1;




$(document).ready(function()
{
	
	$max_clicksxmas = $("#image_containerxmas").children().size(); 	
	
	/* Kudos to Rob MacKay [http://www.twitter.com/svgrob] for suggesting that we don't have to put a xmasic style="width: 3960px" attribute in the div tag */
		$(".prevxmas").fadeOut();
	$(".prevxmas").click(function()
		{
   			/* Set the new position & frame number */
			$new_frame_noxmas = (($frame_noxmas/1)-1);

			$new_leftxmas = (($frame_leftxmas/1) + $move_byxmas);
			/* Check if we're moving too far over */
			if($new_frame_noxmas == 1)

				{$(".prevxmas").fadeOut();			}
			else if($frame_noxmas == $max_clicksxmas )
				{$(".nextxmas").fadeIn();}
			
			if($new_frame_noxmas <= 0)
				{
					/* Move the images all the way left, minus one frame */
					$new_leftxmas = -($move_byxmas*$max_clicksxmas)+$move_byxmas;
					$new_frame_noxmas = $max_clicksxmas;
					   
				}
			$new_left_attrxmas = $new_leftxmas+"px";
			$("#image_containerxmas").animate({left: $new_left_attrxmas}, 800 );
			$frame_leftxmas = $new_leftxmas;
			$frame_noxmas = $new_frame_noxmas;
			
		});
	$(".nextxmas").click(function()
		{
			/* Set the new position & frame number */
			$new_frame_noxmas = (($frame_noxmas/1)+1);
			$new_leftxmas = (($frame_leftxmas/1) - $move_byxmas);
			/* Check if we're moving too far over */
			
			if ($new_frame_noxmas == $max_clicksxmas)
				{$(".nextxmas").fadeOut();}
			else if ($frame_noxmas == 1)
			{$(".prevxmas").fadeIn();}
			
			if($new_frame_noxmas > $max_clicksxmas)
				{		
						/* Move all the way right, to the beginning*/
					$new_leftxmas = 0;
					$new_frame_noxmas = 1;
				
				}				
			$new_left_attrxmas = $new_leftxmas+"px";
			
			$("#image_containerxmas").animate({left: $new_left_attrxmas}, 800 );
			$frame_leftxmas = $new_leftxmas;
			$frame_noxmas = $new_frame_noxmas;
		});	
});







