$(document).ready(function() {

	//!Homepage banner - autoscroll
	var banner = $('#banner-list li');
	var duration = 10000;
	
	setInterval(function(){
		
		$(banner).filter('.active').removeClass(function(){
			//Remove the active class from active list item
			$(this).attr('class');
			$('#banner .banner').hide();
			//Add active class to next list item
			if($(this).next(banner).size()){
				var this_banner = $(this).next().attr('id');
				$(this).next().addClass('active');
				$('.' + this_banner).fadeIn();
			}
			else{
				//Go back to the top of the list
				$(banner).eq(0).addClass('active');
				var this_banner = $(banner).eq(0).attr('id');
				$('.' + this_banner).fadeIn();
			}
		});
	
	}, duration);

	//Homepage banner - on click
	$('#banner-list li').click(function(){
		var this_banner = $(this).attr('id');
		//Remove the active class
		$('#banner-list li').removeClass('active');
		//Add the active class to this list item
		$(this).addClass('active');
		//Show the banner
		$('#banner .banner').hide();
		$('.' + this_banner).fadeIn();
	});
	
});
