$(document).ready(function() {
   
	peachSlider();
    
});

function peachSlider() {
	var $ = jQuery;
	$('.homeSlider li').each(function(){
		var t=$(this),
				image = t.find('img').attr('src'),
				eWidth = t.width()/10;
		t.find('img').remove();
		for(var i=0;i<10;i++){
			$('<span/>').css({
				left:(i*eWidth)+'px',
				background:'url('+image+') no-repeat -'+(i*eWidth)+'px 0'
			}).hide().appendTo(t);
		}
	});
	

	

	
	
	
	function showPeach(e) {
		e.show().find('span').each(function(i){
			var t=$(this);
			window.setTimeout(function(){
				t.fadeIn(550, function(){
					if(t.index()===9){
						e.addClass('current').siblings().hide().removeClass('current').find('span').hide();
					}
				});
			}, i*100);
		});
		
	};//showPeach
	
	
	
	function showPeach2(e) {
		e.show().find('span').each(function(i){
			var t=$(this);
			window.setTimeout(function(){
				t.fadeIn(1111, function(){
					if(t.index()===9){
						e.addClass('current').siblings().hide().removeClass('current').find('span').hide();
					}
				});
			}, i*100);
		});
	};//showPeach2
	
	var firstPeach = $('.homeSlider li:first');
	showPeach(firstPeach);
	
	var firstPeach2 = $('.overlay li:first');
	showPeach2(firstPeach2);
	
	
	window.setInterval(function(){
		if($('.homeSlider li:last').hasClass('current')){
			$('.homeSlider li').show();
			showPeach(firstPeach);
		}else {
			showPeach($('.homeSlider li.current').next());
		}
		
		
		if($('.overlay li:last').hasClass('current')){
			$('.overlay li').show();
			showPeach2(firstPeach2);
		}else {
			showPeach2($('.overlay li.current').next());
		}
		
		
	}, 5000);
	
	

	
	
	
};//peachSlider



