$(function() {
			
			  //remove js-disabled class
				$("#viewer1").removeClass("js-disabled1");
			
			  //create new container for images
				$("<div>").attr("id", "container1").css({ position:"absolute"}).width($(".wrapper1").length * 170).height(170).appendTo("div#viewer1");
			  	
				//add images to container
				$(".wrapper1").each(function() {
					$(this).appendTo("div#container1");
				});
				
				//work out duration of anim based on number of images (1 second for each image)
				var duration = $(".wrapper1").length * 5000;
				
				//store speed for later (distance / time)
				var speed = (parseInt($("div#container1").width()) + parseInt($("div#viewer1").width())) / duration;
								
				//set direction
				var direction = "rtl";
				
				//set initial position and class based on direction
				(direction == "rtl") ? $("div#container1").css("left", $("div#viewer1").width()).addClass("rtl") : $("div#container1").css("left", 0 - $("div#container1").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#imageScroller2").width(), right:"" });
							
							//restart animation
							animator($(this), duration, "rtl");
							
							//hide controls if visible
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
											
						});
					} else {
					
					  //add direction class
						el.removeClass("rtl").addClass("ltr");
					
						//animate the el
						el.animate({ left:$("div#viewer1").width() + "px" }, time, "linear", function() {
												
							//reset container position
							$(this).css({ left:0 - $("div#container1").width() });
							
							//restart animation
							animator($(this), duration, "ltr");
							
							//hide controls if visible
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
						});
					}
				}
				
				//start anim
				animator($("div#container1"), duration, direction);
				
				//pause on mouseover
				$("a.wrapper1").live("mouseover", function() {
				  
					//stop anim
					$("div#container1").stop(true);
					
					
					
					//variable to hold trigger element
					var title = $(this).attr("title");
					
					//add p if doesn't exist, update it if it does
					($("p#title").length == 0) ? $("<p>").attr("id", "title").text(title).appendTo("div#controls") : $("p#title").text(title) ;
				});
				
				//restart on mouseout
				$("a.wrapper1").live("mouseout", function(e) {
				  
					//hide controls if not hovering on them
					(e.relatedTarget == null) ? null : (e.relatedTarget.id != "controls") ? $("div#controls").slideUp("slow").remove() : null ;
					
					//work out total travel distance
					var totalDistance = parseInt($("div#container1").width()) + parseInt($("div#viewer1").width());
														
					//work out distance left to travel
					var distanceLeft = ($("div#container1").hasClass("ltr")) ? totalDistance - (parseInt($("div#container1").css("left")) + parseInt($("div#container1").width())) : totalDistance - (parseInt($("div#viewer1").width()) - (parseInt($("div#container1").css("left")))) ;
					
					//new duration is distance left / speed)
					var newDuration = distanceLeft / speed;
				
					//restart anim
					animator($("div#container1"), newDuration, $("div#container1").attr("class"));

				});
												
				
			});






//-------------------------�Q�ڂ̃{�b�N�X-------------------------

$(function() {
			
			  //remove js-disabled class
				$("#viewer2").removeClass("js-disabled2");
			
			  //create new container for images
				$("<div>").attr("id", "container2").css({ position:"absolute"}).width($(".wrapper2").length * 170).height(170).appendTo("div#viewer2");
			  	
				//add images to container
				$(".wrapper2").each(function() {
					$(this).appendTo("div#container2");
				});
				
				//work out duration of anim based on number of images (1 second for each image)
				var duration = $(".wrapper2").length * 3000;
				
				//store speed for later (distance / time)
				var speed = (parseInt($("div#container2").width()) + parseInt($("div#viewer2").width())) / duration;
								
				//set direction
				var direction = "rtl";
				
				//set initial position and class based on direction
				(direction == "rtl") ? $("div#container2").css("left", $("div#viewer2").width()).addClass("rtl") : $("div#container2").css("left", 0 - $("div#container2").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#imageScroller2").width(), right:"" });
							
							//restart animation
							animator($(this), duration, "rtl");
							
							//hide controls if visible
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
											
						});
					} else {
					
					  //add direction class
						el.removeClass("rtl").addClass("ltr");
					
						//animate the el
						el.animate({ left:$("div#viewer2").width() + "px" }, time, "linear", function() {
												
							//reset container position
							$(this).css({ left:0 - $("div#container2").width() });
							
							//restart animation
							animator($(this), duration, "ltr");
							
							//hide controls if visible
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
						});
					}
				}
				
				//start anim
				animator($("div#container2"), duration, direction);
				
				//pause on mouseover
				$("a.wrapper2").live("mouseover", function() {
				  
					//stop anim
					$("div#container2").stop(true);
					
					
					
					//variable to hold trigger element
					var title = $(this).attr("title");
					
					//add p if doesn't exist, update it if it does
					($("p#title").length == 0) ? $("<p>").attr("id", "title").text(title).appendTo("div#controls") : $("p#title").text(title) ;
				});
				
				//restart on mouseout
				$("a.wrapper2").live("mouseout", function(e) {
				  
					//hide controls if not hovering on them
					(e.relatedTarget == null) ? null : (e.relatedTarget.id != "controls") ? $("div#controls").slideUp("slow").remove() : null ;
					
					//work out total travel distance
					var totalDistance = parseInt($("div#container2").width()) + parseInt($("div#viewer2").width());
														
					//work out distance left to travel
					var distanceLeft = ($("div#container2").hasClass("ltr")) ? totalDistance - (parseInt($("div#container2").css("left")) + parseInt($("div#container2").width())) : totalDistance - (parseInt($("div#viewer2").width()) - (parseInt($("div#container2").css("left")))) ;
					
					//new duration is distance left / speed)
					var newDuration = distanceLeft / speed;
				
					//restart anim
					animator($("div#container2"), newDuration, $("div#container2").attr("class"));

				});
												
				
			});

//-------------------------3�ڂ̃{�b�N�X-------------------------

$(function() {
			
			  //remove js-disabled class
				$("#viewer3").removeClass("js-disabled3");
			
			  //create new container for images
				$("<div>").attr("id", "container3").css({ position:"absolute"}).width($(".wrapper3").length * 170).height(170).appendTo("div#viewer3");
			  	
				//add images to container
				$(".wrapper3").each(function() {
					$(this).appendTo("div#container3");
				});
				
				//work out duration of anim based on number of images (1 second for each image)
				var duration = $(".wrapper3").length * 3000;
				
				//store speed for later (distance / time)
				var speed = (parseInt($("div#container3").width()) + parseInt($("div#viewer3").width())) / duration;
								
				//set direction
				var direction = "rtl";
				
				//set initial position and class based on direction
				(direction == "rtl") ? $("div#container3").css("left", $("div#viewer3").width()).addClass("rtl") : $("div#container3").css("left", 0 - $("div#container3").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#imageScroller3").width(), right:"" });
							
							//restart animation
							animator($(this), duration, "rtl");
							
							//hide controls if visible
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
											
						});
					} else {
					
					  //add direction class
						el.removeClass("rtl").addClass("ltr");
					
						//animate the el
						el.animate({ left:$("div#viewer3").width() + "px" }, time, "linear", function() {
												
							//reset container position
							$(this).css({ left:0 - $("div#container3").width() });
							
							//restart animation
							animator($(this), duration, "ltr");
							
							//hide controls if visible
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
						});
					}
				}
				
				//start anim
				animator($("div#container3"), duration, direction);
				
				//pause on mouseover
				$("a.wrapper3").live("mouseover", function() {
				  
					//stop anim
					$("div#container3").stop(true);
					
					
					
					//variable to hold trigger element
					var title = $(this).attr("title");
					
					//add p if doesn't exist, update it if it does
					($("p#title").length == 0) ? $("<p>").attr("id", "title").text(title).appendTo("div#controls") : $("p#title").text(title) ;
				});
				
				//restart on mouseout
				$("a.wrapper3").live("mouseout", function(e) {
				  
					//hide controls if not hovering on them
					(e.relatedTarget == null) ? null : (e.relatedTarget.id != "controls") ? $("div#controls").slideUp("slow").remove() : null ;
					
					//work out total travel distance
					var totalDistance = parseInt($("div#container3").width()) + parseInt($("div#viewer3").width());
														
					//work out distance left to travel
					var distanceLeft = ($("div#container3").hasClass("ltr")) ? totalDistance - (parseInt($("div#container3").css("left")) + parseInt($("div#container3").width())) : totalDistance - (parseInt($("div#viewer3").width()) - (parseInt($("div#container3").css("left")))) ;
					
					//new duration is distance left / speed)
					var newDuration = distanceLeft / speed;
				
					//restart anim
					animator($("div#container3"), newDuration, $("div#container3").attr("class"));

				});
												
				
			});


//-------------------------4�ڂ̃{�b�N�X-------------------------

$(function() {
			
			  //remove js-disabled class
				$("#viewer4").removeClass("js-disabled4");
			
			  //create new container for images
				$("<div>").attr("id", "container4").css({ position:"absolute"}).width($(".wrapper4").length * 170).height(170).appendTo("div#viewer4");
			  	
				//add images to container
				$(".wrapper4").each(function() {
					$(this).appendTo("div#container4");
				});
				
				//work out duration of anim based on number of images (1 second for each image)
				var duration = $(".wrapper4").length * 3000;
				
				//store speed for later (distance / time)
				var speed = (parseInt($("div#container4").width()) + parseInt($("div#viewer4").width())) / duration;
								
				//set direction
				var direction = "rtl";
				
				//set initial position and class based on direction
				(direction == "rtl") ? $("div#container4").css("left", $("div#viewer4").width()).addClass("rtl") : $("div#container4").css("left", 0 - $("div#container4").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#imageScroller4").width(), right:"" });
							
							//restart animation
							animator($(this), duration, "rtl");
							
							//hide controls if visible
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
											
						});
					} else {
					
					  //add direction class
						el.removeClass("rtl").addClass("ltr");
					
						//animate the el
						el.animate({ left:$("div#viewer4").width() + "px" }, time, "linear", function() {
												
							//reset container position
							$(this).css({ left:0 - $("div#container4").width() });
							
							//restart animation
							animator($(this), duration, "ltr");
							
							//hide controls if visible
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
						});
					}
				}
				
				//start anim
				animator($("div#container4"), duration, direction);
				
				//pause on mouseover
				$("a.wrapper4").live("mouseover", function() {
				  
					//stop anim
					$("div#container4").stop(true);
					
					
					
					//variable to hold trigger element
					var title = $(this).attr("title");
					
					//add p if doesn't exist, update it if it does
					($("p#title").length == 0) ? $("<p>").attr("id", "title").text(title).appendTo("div#controls") : $("p#title").text(title) ;
				});
				
				//restart on mouseout
				$("a.wrapper4").live("mouseout", function(e) {
				  
					//hide controls if not hovering on them
					(e.relatedTarget == null) ? null : (e.relatedTarget.id != "controls") ? $("div#controls").slideUp("slow").remove() : null ;
					
					//work out total travel distance
					var totalDistance = parseInt($("div#container4").width()) + parseInt($("div#viewer4").width());
														
					//work out distance left to travel
					var distanceLeft = ($("div#container4").hasClass("ltr")) ? totalDistance - (parseInt($("div#container4").css("left")) + parseInt($("div#container4").width())) : totalDistance - (parseInt($("div#viewer4").width()) - (parseInt($("div#container4").css("left")))) ;
					
					//new duration is distance left / speed)
					var newDuration = distanceLeft / speed;
				
					//restart anim
					animator($("div#container4"), newDuration, $("div#container4").attr("class"));

				});
												
				
			});


//-------------------------5�ڂ̃{�b�N�X-------------------------

$(function() {
			
			  //remove js-disabled class
				$("#viewer5").removeClass("js-disabled5");
			
			  //create new container for images
				$("<div>").attr("id", "container5").css({ position:"absolute"}).width($(".wrapper5").length * 170).height(170).appendTo("div#viewer5");
			  	
				//add images to container
				$(".wrapper5").each(function() {
					$(this).appendTo("div#container5");
				});
				
				//work out duration of anim based on number of images (1 second for each image)
				var duration = $(".wrapper5").length * 3000;
				
				//store speed for later (distance / time)
				var speed = (parseInt($("div#container5").width()) + parseInt($("div#viewer5").width())) / duration;
								
				//set direction
				var direction = "rtl";
				
				//set initial position and class based on direction
				(direction == "rtl") ? $("div#container5").css("left", $("div#viewer5").width()).addClass("rtl") : $("div#container5").css("left", 0 - $("div#container5").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#imageScroller5").width(), right:"" });
							
							//restart animation
							animator($(this), duration, "rtl");
							
							//hide controls if visible
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
											
						});
					} else {
					
					  //add direction class
						el.removeClass("rtl").addClass("ltr");
					
						//animate the el
						el.animate({ left:$("div#viewer5").width() + "px" }, time, "linear", function() {
												
							//reset container position
							$(this).css({ left:0 - $("div#container5").width() });
							
							//restart animation
							animator($(this), duration, "ltr");
							
							//hide controls if visible
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
						});
					}
				}
				
				//start anim
				animator($("div#container5"), duration, direction);
				
				//pause on mouseover
				$("a.wrapper5").live("mouseover", function() {
				  
					//stop anim
					$("div#container5").stop(true);
					
					
					
					//variable to hold trigger element
					var title = $(this).attr("title");
					
					//add p if doesn't exist, update it if it does
					($("p#title").length == 0) ? $("<p>").attr("id", "title").text(title).appendTo("div#controls") : $("p#title").text(title) ;
				});
				
				//restart on mouseout
				$("a.wrapper5").live("mouseout", function(e) {
				  
					//hide controls if not hovering on them
					(e.relatedTarget == null) ? null : (e.relatedTarget.id != "controls") ? $("div#controls").slideUp("slow").remove() : null ;
					
					//work out total travel distance
					var totalDistance = parseInt($("div#container5").width()) + parseInt($("div#viewer5").width());
														
					//work out distance left to travel
					var distanceLeft = ($("div#container5").hasClass("ltr")) ? totalDistance - (parseInt($("div#container5").css("left")) + parseInt($("div#container5").width())) : totalDistance - (parseInt($("div#viewer5").width()) - (parseInt($("div#container5").css("left")))) ;
					
					//new duration is distance left / speed)
					var newDuration = distanceLeft / speed;
				
					//restart anim
					animator($("div#container5"), newDuration, $("div#container5").attr("class"));

				});
												
				
			});


//-------------------------6�ڂ̃{�b�N�X-------------------------

$(function() {
			
			  //remove js-disabled class
				$("#viewer6").removeClass("js-disabled6");
			
			  //create new container for images
				$("<div>").attr("id", "container6").css({ position:"absolute"}).width($(".wrapper6").length * 170).height(170).appendTo("div#viewer6");
			  	
				//add images to container
				$(".wrapper6").each(function() {
					$(this).appendTo("div#container6");
				});
				
				//work out duration of anim based on number of images (1 second for each image)
				var duration = $(".wrapper6").length * 3000;
				
				//store speed for later (distance / time)
				var speed = (parseInt($("div#container6").width()) + parseInt($("div#viewer6").width())) / duration;
								
				//set direction
				var direction = "rtl";
				
				//set initial position and class based on direction
				(direction == "rtl") ? $("div#container6").css("left", $("div#viewer6").width()).addClass("rtl") : $("div#container6").css("left", 0 - $("div#container6").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#imageScroller6").width(), right:"" });
							
							//restart animation
							animator($(this), duration, "rtl");
							
							//hide controls if visible
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
											
						});
					} else {
					
					  //add direction class
						el.removeClass("rtl").addClass("ltr");
					
						//animate the el
						el.animate({ left:$("div#viewer6").width() + "px" }, time, "linear", function() {
												
							//reset container position
							$(this).css({ left:0 - $("div#container6").width() });
							
							//restart animation
							animator($(this), duration, "ltr");
							
							//hide controls if visible
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
						});
					}
				}
				
				//start anim
				animator($("div#container6"), duration, direction);
				
				//pause on mouseover
				$("a.wrapper6").live("mouseover", function() {
				  
					//stop anim
					$("div#container6").stop(true);
					
					
					
					//variable to hold trigger element
					var title = $(this).attr("title");
					
					//add p if doesn't exist, update it if it does
					($("p#title").length == 0) ? $("<p>").attr("id", "title").text(title).appendTo("div#controls") : $("p#title").text(title) ;
				});
				
				//restart on mouseout
				$("a.wrapper6").live("mouseout", function(e) {
				  
					//hide controls if not hovering on them
					(e.relatedTarget == null) ? null : (e.relatedTarget.id != "controls") ? $("div#controls").slideUp("slow").remove() : null ;
					
					//work out total travel distance
					var totalDistance = parseInt($("div#container6").width()) + parseInt($("div#viewer6").width());
														
					//work out distance left to travel
					var distanceLeft = ($("div#container6").hasClass("ltr")) ? totalDistance - (parseInt($("div#container6").css("left")) + parseInt($("div#container6").width())) : totalDistance - (parseInt($("div#viewer6").width()) - (parseInt($("div#container6").css("left")))) ;
					
					//new duration is distance left / speed)
					var newDuration = distanceLeft / speed;
				
					//restart anim
					animator($("div#container6"), newDuration, $("div#container6").attr("class"));

				});
												
				
			});
//-------------------------7�ڂ̃{�b�N�X-------------------------

$(function() {
			
			  //remove js-disabled class
				$("#viewer7").removeClass("js-disabled7");
			
			  //create new container for images
				$("<div>").attr("id", "container7").css({ position:"absolute"}).width($(".wrapper7").length * 170).height(170).appendTo("div#viewer7");
			  	
				//add images to container
				$(".wrapper7").each(function() {
					$(this).appendTo("div#container7");
				});
				
				//work out duration of anim based on number of images (1 second for each image)
				var duration = $(".wrapper7").length * 5000;
				
				//store speed for later (distance / time)
				var speed = (parseInt($("div#container7").width()) + parseInt($("div#viewer7").width())) / duration;
								
				//set direction
				var direction = "rtl";
				
				//set initial position and class based on direction
				(direction == "rtl") ? $("div#container7").css("left", $("div#viewer7").width()).addClass("rtl") : $("div#container7").css("left", 0 - $("div#container7").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#imageScroller7").width(), right:"" });
							
							//restart animation
							animator($(this), duration, "rtl");
							
							//hide controls if visible
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
											
						});
					} else {
					
					  //add direction class
						el.removeClass("rtl").addClass("ltr");
					
						//animate the el
						el.animate({ left:$("div#viewer7").width() + "px" }, time, "linear", function() {
												
							//reset container position
							$(this).css({ left:0 - $("div#container7").width() });
							
							//restart animation
							animator($(this), duration, "ltr");
							
							//hide controls if visible
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
						});
					}
				}
				
				//start anim
				animator($("div#container7"), duration, direction);
				
				//pause on mouseover
				$("a.wrapper7").live("mouseover", function() {
				  
					//stop anim
					$("div#container7").stop(true);
					
					
					
					//variable to hold trigger element
					var title = $(this).attr("title");
					
					//add p if doesn't exist, update it if it does
					($("p#title").length == 0) ? $("<p>").attr("id", "title").text(title).appendTo("div#controls") : $("p#title").text(title) ;
				});
				
				//restart on mouseout
				$("a.wrapper7").live("mouseout", function(e) {
				  
					//hide controls if not hovering on them
					(e.relatedTarget == null) ? null : (e.relatedTarget.id != "controls") ? $("div#controls").slideUp("slow").remove() : null ;
					
					//work out total travel distance
					var totalDistance = parseInt($("div#container7").width()) + parseInt($("div#viewer7").width());
														
					//work out distance left to travel
					var distanceLeft = ($("div#container7").hasClass("ltr")) ? totalDistance - (parseInt($("div#container7").css("left")) + parseInt($("div#container7").width())) : totalDistance - (parseInt($("div#viewer7").width()) - (parseInt($("div#container7").css("left")))) ;
					
					//new duration is distance left / speed)
					var newDuration = distanceLeft / speed;
				
					//restart anim
					animator($("div#container7"), newDuration, $("div#container7").attr("class"));

				});
												
				
			});


