$(document).ready(function(){
	var stay_time = 3000; //in ms
	$('div.slider-holder').each(function(){
		var _t1;
		var _f = true;
		var _btn = $(this).find('ul.menu > li');
		var _list = $(this).find('div.circle > div');
		if(_list.length > 1 && _btn.length > 1){
			var _a = _btn.index(_btn.filter('.active:eq(0'));
			if(_a == -1) _a = 0;
			_btn.children().removeClass('active').eq(_a).addClass('active');
			_list.removeClass('active').eq(_a).addClass('active');
			if($.browser.msie && $.browser.version < 7){
				
			}
			else{
				_list.css('opacity', 0).eq(_a).css('opacity', 1);
			}
			$(this).mouseenter(function(){
				_f = false;
				if(_t1) clearTimeout(_t1);
			}).mouseleave(function(){
				_f = true;
				if(_t1) clearTimeout(_t1);
				_t1 = setTimeout(function(){
					if(_a < _btn.length - 1) changeEl(_a + 1);
					else changeEl(0);
				},stay_time);
			});
			_btn.click(function(){
				changeEl(_btn.index(this));
				return false;
			});
			function changeEl(_ind){
				if(_t1) clearTimeout(_t1);
				if(_a != _ind){
					_btn.eq(_a).children().removeClass('active');
					_btn.eq(_ind).children().addClass('active');
					if($.browser.msie && $.browser.version < 7){
						_list.eq(_a).removeClass('active');
						_list.eq(_ind).addClass('active');
					}
					else{
						_list.eq(_a).removeClass('active').animate({opacity: 0}, { queue:false, duration:800});
						_list.eq(_ind).addClass('active').animate({opacity: 1}, { queue:false, duration:800});
					}
					_a = _ind;
				}
				if(_f){
					_t1 = setTimeout(function(){
						if(_a < _btn.length - 1) changeEl(_a + 1);
						else changeEl(0);
					}, stay_time);
				}
			}
			if(_f){
				_t1 = setTimeout(function(){
					if(_a < _btn.length - 1) changeEl(_a + 1);
					else changeEl(0);
				},stay_time);
			}
		}
	});
});