// JavaScript Document
$move_bygw = 525;
$frame_leftgw = 0;
$frame_nogw = 1;




$(document).ready(function()
{
	
	$max_clicksgw = $("#image_containergw").children().size(); 	
	
	/* Kudos to Rob MacKay [http://www.twitter.com/svgrob] for suggesting that we don't have to put a gwic style="width: 3960px" attribute in the div tag */
		$(".prevgw").fadeOut();
	$(".prevgw").click(function()
		{
   			/* Set the new position & frame number */
			$new_frame_nogw = (($frame_nogw/1)-1);

			$new_leftgw = (($frame_leftgw/1) + $move_bygw);
			/* Check if we're moving too far over */
			if($new_frame_nogw == 1)

				{$(".prevgw").fadeOut();			}
			else if($frame_nogw == $max_clicksgw )
				{$(".nextgw").fadeIn();}
			
			if($new_frame_nogw <= 0)
				{
					/* Move the images all the way left, minus one frame */
					$new_leftgw = -($move_bygw*$max_clicksgw)+$move_bygw;
					$new_frame_nogw = $max_clicksgw;
					   
				}
			$new_left_attrgw = $new_leftgw+"px";
			$("#image_containergw").animate({left: $new_left_attrgw}, 800 );
			$frame_leftgw = $new_leftgw;
			$frame_nogw = $new_frame_nogw;
			
		});
	$(".nextgw").click(function()
		{
			/* Set the new position & frame number */
			$new_frame_nogw = (($frame_nogw/1)+1);
			$new_leftgw = (($frame_leftgw/1) - $move_bygw);
			/* Check if we're moving too far over */
			
			if ($new_frame_nogw == $max_clicksgw)
				{$(".nextgw").fadeOut();}
			else if ($frame_nogw == 1)
			{$(".prevgw").fadeIn();}
			
			if($new_frame_nogw > $max_clicksgw)
				{		
						/* Move all the way right, to the beginning*/
					$new_leftgw = 0;
					$new_frame_nogw = 1;
				
				}				
			$new_left_attrgw = $new_leftgw+"px";
			
			$("#image_containergw").animate({left: $new_left_attrgw}, 800 );
			$frame_leftgw = $new_leftgw;
			$frame_nogw = $new_frame_nogw;
		});	
});







