$(document).ready(function(){
	ieHover('#menu > li');
	initGall();
});
/*--- fade gall ---*/
function initGall(){
	var _a = 0;
	$('.gallery').each(function(){
		var _hold = $(this);
		var _box = _hold.children('.info-box').hide();
		_box.eq(_a).show();
		_hold.find('.list .back').click(function(){
			if(_a > 0) changeEl(_a - 1);
			else changeEl(_box.length - 1);
			resetTimer();
			return false;
		});
		_hold.find('.list .next').click(function(){
			if(_a < _box.length - 1) changeEl(_a + 1);
			else changeEl(0);
			resetTimer();
			return false;
		});
		function changeEl(_ind){
			_box.eq(_a).css('z-index', 1).fadeOut(600);
			_box.eq(_ind).css('z-index', 2).fadeIn(600);
			_a = _ind;
		}
		
	    function resetTimer(){
	        $(this).parent().stopTime();
	        //$(this).everyTime(4000, "AutoRot", function(){
	        //    if(_a < _box.length - 1) changeEl(_a + 1);
		    //    else changeEl(0);
	        //},0,true);
	    }

	    $(this).everyTime(4000, "AutoRot", function(){
	        if(_a < _box.length - 1) changeEl(_a + 1);
		    else changeEl(0);
	    },0,true);

	});
	

}
/*--- ie hover ---*/
function ieHover(_list) {
	if ($.browser.msie && $.browser.version < 7) {
		$(_list).hover(function() {
			$(this).addClass('hover');
		}, function() {
			$(this).removeClass('hover');
		});
	}
}