jQuery(document).ready(function($) {

	$(".handles a.num:first").addClass("act");	
	$("#banner .item:first").addClass("active");
		
	rotate = function(){	
		var triggerID = $active.attr("href") - 1;
		
		var cur = id($current.attr('href'));
		var next = id($active.attr('href'));
		
		$(cur).fadeOut(1000);
		$(next).fadeIn(1000);
						
		$(".handles a.num").removeClass('act');
		$active.addClass('act');			
		
	}; 
	
	//Rotation + Timing Event
	rotateSwitch = function(){		
		play = setInterval(function(){
			findCur();
			$active = $current.next('.handles a.num');
			if ( $active.length === 0) {
				$active = $('.handles a.num:first');
			}
			rotate();
		}, 8000);
	};
	
	findCur = function() {
		$current = $('.handles a.act:first');		
	};
	
	id = function(id) {
		return id.replace('#' , '#l');
	};
	
	rotateSwitch();
	/*
	$("#banner .item").hover(function() {
		clearInterval(play);
	}, function() {
		if($('.handles a.lp').hasClass('act')) {
			rotateSwitch();
		}
	});
	*/
	$(".handles a.num").click(function() {
		clearInterval(play);
		findCur();
		$active = $(this);
		rotate();
		return false;
	});	
	
	$('.handles a.ls').click(function() {
		if(!$(this).hasClass('act')){
			clearInterval(play);		
			$(this).addClass('act');
			$('.handles a.lp').removeClass('act');
		}
		return false;
	});
	
	$('.handles a.lp').click(function() {
		if(!$(this).hasClass('act')){
			rotateSwitch();	
			$(this).addClass('act');
			$('.handles a.ls').removeClass('act');
		}
		return false;
	});
	
});