$(function(){
	if($('#image_header .image_box').length > 1){
		$('#image_header .image_box:not(:first)').hide();
		var autoRotate = true;
		$('#image_header .ul_pages a').click(function(){
			var li = $(this).closest('li');
			if(li.hasClass('slc')){
				return false;
			}
			$('li', $(this).closest('.ul_pages')).removeClass('slc');
			li.addClass('slc');
			$('#image_header .image_box').hide();
			$('#image_header .image_box:eq('+ li.prevAll('li').length +')').fadeIn(800);
			autoRotate = false;
			return false;
		});
		
		var INTERVAL = 8000;
		
		var changeFunc = function(){
			var activeLi = $('#image_header .ul_pages li.slc');
			var newLi;
			if(activeLi.next('li').length < 1){
				newLi = $('#image_header .ul_pages li:first');
			} else {
				newLi = activeLi.next('li:first');
			}
			$('#image_header .image_box').hide();
			$('#image_header .image_box:eq('+ newLi.prevAll('li').length +')').fadeIn(800);
			activeLi.removeClass('slc');
			newLi.addClass('slc');
			if(autoRotate){
				setTimeout(changeFunc, INTERVAL);
			}
		};
		setTimeout(changeFunc, INTERVAL);
	}
})
