$(document).ready(function(){
		
		$active = $("#photo_bu li:first");
		$active.children("a").addClass("active");
		
		
		$("#photo_bu li:first").next().children("a").addClass("faafdafadf");
		
		
		
		var photoWidth = $(".photo_window").width();
		var photoSum = $(".photo_reel img").size();
		var photoReelWidth = photoWidth * photoSum;
		
		
		$(".photo_reel").css({"width" : photoReelWidth});
		
		
		rotate  = function(){
			
			var triggerID = $active.children("a").attr("rel")-1;
			
			$("#photo_bu a").removeClass();
			$active.children("a").addClass("active");
			
			
			//alert($active.attr("rel"));
			
			$(".photo_reel").animate({left:-photoWidth*triggerID},500);		
		};
		
		
		rotateSwitch = function(){
			play = setInterval(function(){
				$active =$("#photo_bu a.active").parent().next();
				if($active.length == 0){
					$active = $("#photo_bu li:first");
				}
				rotate();
			},3000);
			
		};
		
		rotateSwitch();
		
		
		$("#photo_bu a").click(function(){
			$active = $(this).parent();
			clearInterval(play);
			rotate();
			rotateSwitch();
			
			return false;
		});
		
		
	
});
