$(document).ready(function() {
	$(".paging").show();
	$(".paging a:first").addClass("active");
	var imageWidth = $(".window").width();
	var imageSum = $(".image_reel img").size();
	var imageReelWidth = imageWidth * imageSum;
	
	$(".image_reel").css({'width' : imageReelWidth});
	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
		}, 500 );
	}; 
	rotateSwitch = function(){		
		play = setInterval(function(){ 
			$active = $('.paging a.active').next();
			if ( $active.length === 0) {
				$active = $('.paging a:first');
			}
			rotate(); 
		}, 5000);
	};
	
	rotateSwitch(); 
	$(".image_reel a").hover(function() {
		clearInterval(play); 
	}, function() {
		rotateSwitch(); 
	});	
	
	$(".paging a").click(function() {	
		$active = $(this); 
		clearInterval(play);
		rotate(); 
		rotateSwitch(); 
		return false;
	});	
	
	
	//BANNER
	$(".paging_2").show();
	$(".paging_2 a:first").addClass("active");
	var imageWidth_2 = $(".window_2").width();
	var imageSum_2 = $(".image_reel_2 img").size();
	var imageReelWidth_2 = imageWidth_2 * imageSum_2;
	
	$(".image_reel_2").css({'width' : imageReelWidth_2});
	rotate_2 = function(){	
		var triggerID_2 = $active_2.attr("rel") - 1; 
		var image_reelPosition_2 = triggerID_2 * imageWidth_2; 

		$(".paging_2 a").removeClass('active'); 
		$active_2.addClass('active'); 
		$(".image_reel_2").animate({ 
			left: -image_reelPosition_2
		}, 500 );
	}; 
	rotateSwitch_2 = function(){		
		play_2 = setInterval(function(){ 
			$active_2 = $('.paging_2 a.active').next();
			if ( $active_2.length === 0) {
				$active_2 = $('.paging_2 a:first');
			}
			rotate_2(); 
		}, 10000);
	};
	
	rotateSwitch_2(); 
	$(".image_reel_2 a").hover(function() {
		clearInterval(play); 
	}, function() {
		rotateSwitch_2(); 
	});	
	
	$(".paging_2 a").click(function() {	
		$active = $(this); 
		clearInterval(play);
		rotate_2(); 
		rotateSwitch_2(); 
		return false;
	});	
	
	
});
