jQuery(function($) {
	
	var imageWidth;
	
	$(".paging").show();
	$(".paging a:first").addClass("active");

	rotateSlide = function(){
		imageWidth = $(".window").width();
		
		$(".image_reel div").css("width", imageWidth);
		
		var imageSum = $(".image_reel div").size();
		var imageReelWidth = imageWidth * imageSum;
		
		$(".image_reel").css({'width' : imageReelWidth});
	}
	rotateSlide();
	
	rotate = function(){	
		var triggerID = $active.attr("rel") - 1;
		var image_reelPosition = triggerID * imageWidth;

		$(".paging a").removeClass('active');
		$active.addClass('active');
		
		$(".image_reel").animate({ 
			left: -image_reelPosition
		}, 700 );
		
	}; 
	
	rotateSwitch = function(){		
		play = setInterval(function(){
			$active = $('.paging a.active').next();
			if ( $active.length === 0) {
				$active = $('.paging a:first');
			}
			rotate();
		}, 6000);
	};
	
	rotateSwitch();
	
	$(".image_reel a").hover(function() {
		clearInterval(play);
	}, function() {
		rotateSwitch();
	});	
	
	$(".paging a").click(function() {	
		$active = $(this);
		clearInterval(play);
		rotate();
		rotateSwitch();
		return false;
	});
	
	$(window).resize(function() {
	    rotateSlide();
	});
	
});
