var $j = jQuery.noConflict();
			$j(function() {
			
		  //Удаляем класс js-disabled. Если этот класс вы удалили из CSS, здесь эту строку также можно удалить.
				$j("#viewer").removeClass("js-disabled");
			
			 //создаем контейнер div id="container" для изображений
				//$j("<div>").attr("id", "container").css({ position:"absolute"}).width($j(".wrapper").length * 170).height(170).appendTo("div#viewer");
				$j("<div>").attr("id", "container").css({ position:"absolute"}).width($j(".wrapper").length * 199).height(290).appendTo("div#viewer");
			  	
				//Добавляем в контейнер изображения
				$j(".wrapper").each(function() {
					$j(this).appendTo("div#container");
				});
				
				var duration = $j(".wrapper").length * 3000; // здесь меняем скорость прокуртки в милисекундах.
				
				var speed = (parseInt($j("div#container").width()) + parseInt($j("div#viewer").width())) / duration;
								
				var direction = "rtl";
				
				//(direction == "rtl") ? $j("div#container").css("left", $j("div#viewer").width()).addClass("rtl") : $j("div#container").css("left", 0 - $j("div#container").width()).addClass("ltr") ;
				
				//animator function
				var animator = function(el, time, dir) {
				 
				//устанавливаем в какую сторону будут двигаться изображения при старте. Здесь - вправо
					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
							$j(this).css({ left:$j("div#imageScroller").width(), right:"" });
							
							//restart animation
							animator($j(this), duration, "rtl");
							
							//hide controls if visible
							($j("div#controls").length > 0) ? $j("div#controls").slideUp("slow").remove() : null ;			
											
						});
					} else {
					
					  //add direction class
						el.removeClass("rtl").addClass("ltr");
					
						//animate the el
						el.animate({ left:$j("div#viewer").width() + "px" }, time, "linear", function() {
												
							//reset container position
							$j(this).css({ left:0 - $j("div#container").width() });
							
							//restart animation
							animator($j(this), duration, "ltr");
							
							//hide controls if visible
							($j("div#controls").length > 0) ? $j("div#controls").slideUp("slow").remove() : null ;			
						});
					}
				}
				
				//start anim
				animator($j("div#container"), duration, direction);
				//alert('fhfg');
				//pause on mouseover
				$j("a.wrapper").live("mouseover", function() {
				  
					//stop anim
					$j("div#container").stop(true);
					
					//show controls
					//($j("div#controls").length == 0) ? $j("<div>").attr("id", "controls").appendTo("div#outerContainer").css({ opacity:0.7 }).slideDown("slow") : null ;
					//($j("a#rtl").length == 0) ? $j("<a>").attr({ id:"rtl", href:"#", title:"rtl" }).appendTo("#controls") : null ;
					//($j("a#ltr").length == 0) ? $j("<a>").attr({ id:"ltr", href:"#", title:"ltr" }).appendTo("#controls") : null ;
					
					//variable to hold trigger element
					var title = $j(this).attr("title");
					
					//add p if doesn't exist, update it if it does
					($j("p#title").length == 0) ? $j("<p>").attr("id", "title").text(title).appendTo("div#controls") : $j("p#title").text(title) ;
				});
				
				//restart on mouseout
				$j("a.wrapper").live("mouseout", function(e) {
				  
					//hide controls if not hovering on them
					(e.relatedTarget == null) ? null : (e.relatedTarget.id != "controls") ? $j("div#controls").slideUp("slow").remove() : null ;
					
					//work out total travel distance
					var totalDistance = parseInt($j("div#container").width()) + parseInt($j("div#viewer").width());
														
					//work out distance left to travel
					var distanceLeft = ($j("div#container").hasClass("ltr")) ? totalDistance - (parseInt($j("div#container").css("left")) + parseInt($j("div#container").width())) : totalDistance - (parseInt($j("div#viewer").width()) - (parseInt($j("div#container").css("left")))) ;
					
					//new duration is distance left / speed)
					var newDuration = distanceLeft / speed;
				
					//restart anim
					animator($j("div#container"), newDuration, $j("div#container").attr("class"));

				});
												
				//handler for ltr button
				$j("#ltr").live("click", function() {
				 					
					//stop anim
					$j("div#container").stop(true);
				
					//swap class names
					$j("div#container").removeClass("rtl").addClass("ltr");
										
					//work out total travel distance
					var totalDistance = parseInt($j("div#container").width()) + parseInt($j("div#viewer").width());
					
					//work out remaining distance
					var distanceLeft = totalDistance - (parseInt($j("div#container").css("left")) + parseInt($j("div#container").width()));
					
					//new duration is distance left / speed)
					var newDuration = distanceLeft / speed;
					
					//restart anim
					animator($j("div#container"), newDuration, "ltr");
				});
				
				//handler for rtl button
				$j("#rtl").live("click", function() {
										
					//stop anim
					$j("div#container").stop(true);
					
					//swap class names
					$j("div#container").removeClass("ltr").addClass("rtl");
					
					//work out total travel distance
					var totalDistance = parseInt($j("div#container").width()) + parseInt($j("div#viewer").width());

					//work out remaining distance
					var distanceLeft = totalDistance - (parseInt($j("div#viewer").width()) - (parseInt($j("div#container").css("left"))));
					
					//new duration is distance left / speed)
					var newDuration = distanceLeft / speed;
				
					//restart anim
					animator($j("div#container"), newDuration, "rtl");
				});
			});













