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


function peachSlider() {
	var $ = jQuery;
	$('#peach_slider 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
	
	var firstPeach = $('#peach_slider li:first');
	showPeach(firstPeach);
	window.setInterval(function(){
		if($('#peach_slider li:last').hasClass('current')){
			$('#peach_slider li').show();
			showPeach(firstPeach);
		}else {
			showPeach($('#peach_slider li.current').next());
		}
	}, 5000);
};//peachSlider
