$(document).ready(function(){
	ieHover('#menu li')
	slideGall();
});
/*--- IE6 hover ---*/
function ieHover(h_list){
	if ($.browser.msie && $.browser.version < 7){
		$(h_list).hover(function(){
			$(this).addClass('hover');
		}, function(){
			$(this).removeClass('hover');
		});
	}
}
/*--- slide gallery ---*/
function slideGall(){
	var stay_time = 6000; //in ms
	$('#gallery').each(function(){
		var list_h = $(this).find('.frame > ul');
		var _btn = $(this).find('.switcher ul a');
		var _step = list_h.parent().width();
		var _a = _btn.parent().index(_btn.parent('.active:eq(0)'));
		if(_a == -1) _a = 0;
		var _t;
		var _f = true;
		
		_btn.mouseenter(function(){
			changeEl(_btn.index(this));
		});
		$(this).mouseenter(function(){
			_f = false;
			clearTimeout(_t);
		}).mouseleave(function(){
			_f = true;
			clearTimeout(_t);
			if(_f){
				_t = setTimeout(function(){
					if(_a == _btn.length - 1) changeEl(0);
					else changeEl(_a + 1);
				}, stay_time);
			}
		});
		function changeEl(_ind){
			if(_ind != _a){
				clearTimeout(_t);
				list_h.animate({marginLeft: -_ind*_step}, {queue:false, duration: 600});
				_btn.eq(_a).parent().removeClass('active');
				_btn.eq(_ind).parent().addClass('active');
				_a = _ind;
				if(_f){
					_t = setTimeout(function(){
						if(_a == _btn.length - 1) changeEl(0);
						else changeEl(_a + 1);
					}, stay_time);
				}
			}
		}
		if(_f){
			_t = setTimeout(function(){
				if(_a == _btn.length - 1) changeEl(0);
				else changeEl(_a + 1);
			}, stay_time);
		}
	});
	
}
