$(document).ready(function() {
	
	var total = 0;
	var num = 0;
	var backnum = 0;
	var baf = 0;
	
	$('.slideImg', this.group).each(function(){
		$(this).hide();
		$(this).css({"z-index": "0"});
		total++;
	}).filter(':eq(0)').css({"z-index": "1"}).fadeIn("slow");
	
	if(total > 1){
		setInterval(newsF,4500);
		
		var html = '<ul id="num">';
		for (var i = 1; i < total+1; i++){
			html += '<li class="'+i+'"><img src="images/top/sliderNav_off.gif" alt="no.'+i+'" width="14" height="13" /></li>';
		}
		html += '</ul>';
		
		$('#left_img').append(html);
		smartRollover();
	}
	
	
	$('#num > li', this.group).each(function(){
		$(this).click(function() {
			
			$('.slideImg', this.group).each(function(){
				$(this).hide();
			});
			
			$('#num > li', this.group).each(function(){
				$(this).children('img').attr('src', 'images/top/sliderNav_off.gif');
			});
			
			num = ~~$(this).attr('class');
			num--;
			if( num == total ){
				num = 0;
			}
			
			if(num == 0){
				backnum = (total-1);
			} else {
				backnum = (num-1);
			}
			
			$('.slideImg', this.group).each(function(){
					$(this).css({"z-index": "0"});
			});
			$('.slideImg', this.group).filter(':eq('+num+')').css({"z-index": "1"});
			$('.slideImg', this.group).filter(':eq('+num+')').stop(false, true).fadeIn();
			
			$('#num > li', this.group).filter(':eq('+num+')').children('img').attr('src', 'images/top/sliderNav_active.gif');
			smartRollover();
		});
		
	}).filter(':eq(0)').children('img').attr('src', 'images/top/sliderNav_on.gif');
	
	
	
	function newsF(){
	
		if( num < (total - 1)){
			num++;
		} else {
			num = 0;
		}
		
		if(num == 0){
			backnum = (total-1);
			
		} else {
			backnum = (num-1);
		}
		
		$('.slideImg', this.group).filter(':eq('+backnum+')').css({"z-index": "1"});
		$('.slideImg', this.group).filter(':eq('+num+')').css({"z-index": "0"});
		
		
		$('.slideImg', this.group).each(function(){
			//$(this).hide();
		}).filter(':eq('+num+')').fadeIn(1500, function(){
			$('.slideImg', this.group).filter(':eq('+backnum+')').fadeOut(1500);
			
			
			$('#num > li', this.group).filter(':eq('+backnum+')').children('img').attr('src', 'images/top/sliderNav_off.gif');
			$('#num > li', this.group).filter(':eq('+num+')').children('img').attr('src', 'images/top/sliderNav_active.gif');
		});
		
	
	}
	
});
