// JavaScript Document

    		$(function() {  
  
				//work out duration of anim based on number of images (1 second for each image)  
				  var duration = $("#viewer").length * 20000;  
  
				//store speed for later  
				  var speed = (parseInt($("div#viewer").width())) / duration;  
  
				//set direction  
				  var direction = "rtl";  
  
				//set initial position and class based on direction  
				  (direction == "rtl") ? $("div#viewer").css("left", 956).addClass("rtl") : $("div#viewer").css("left", 0 - $("div#viewer").width()).addClass("ltr") ;

				//animator function  
				  var animator = function(el, time, dir) {  
  
  					//which direction to scroll  
  					if(dir == "rtl") {  
  
    					//add direction class  
   						 el.removeClass("ltr").addClass("rtl");  
  
   						 //animate the el  
    					 el.animate({ left:"-" + el.width() + "px" }, time, "linear", function() {  
  
    						//reset container position  
    						$(this).css({ left:$("div#imageScroller").width(), right:"" });  
  
    						//restart animation  
    						animator($(this), duration, "rtl");  
  
    					});  
  				}  
			}  

			//start anim  
			animator($("div#viewer"), duration, direction);  
			
			//pause on mouseover
				$("a.wrapper").live("mouseover", function() {
				  
					//stop anim
					$("div#viewer").stop(true);
					
				});
			
			//restart on mouseout
				$("a.wrapper").live("mouseout", function(e) {
				  
					//work out total travel distance
					var totalDistance = parseInt($("div#viewer").width()) + parseInt($("div#viewer").width());
														
					//work out distance left to travel
					var distanceLeft = ($("div#viewer").hasClass("ltr")) ? totalDistance - (parseInt($("div#viewer").css("left")) + parseInt($("div#viewer").width())) : totalDistance - (parseInt($("div#viewer").width()) - (parseInt($("div#viewer").css("left")))) ;
					
					//new duration is distance left / speed)
					var newDuration = distanceLeft / speed;
				
					//restart anim
					animator($("div#viewer"), newDuration, $("div#viewer").attr("class"));

				});
			
      });  
