// JavaScript Document
$(function(){
	//init nav
	$('#nav .nav').hover(function(){
		if($(this).find('.subnav').size()) $('.subbg').height($(this).find('.subnav').height());
		$(this).find('.subnav,.subbg').show();
	}, function(){
		$(this).find('.subnav,.subbg').hide();
	});

	//eq height
	if($('.w660').size() > 0 && $('.w288').size() > 0){
		if($('.w660').height() > $('.w288').height()) $('.w288').height($('.w660').height());
	}
});

$(document).ready(function(){
	var M=$("#run li a");
	var i=-1;
	var T;
	var _timer = 5000;
	M.click(function(){
		var URL=$(this).attr("href");
		//$("#show img").attr("src",URL);
		//$("#show img").css("opacity",0);
		//$("#show img").animate({opacity:1},600);
		
		$("#show img").animate({opacity:0.1}, 200, function(){
			$("#show img").attr("src",URL);
			$("#show img").animate({opacity:1}, 600);
		});
		
		i=M.index($(this));
		$(this).parent("li").siblings("li").children("a").removeClass("over");
		$(this).addClass("over");
		return false;
	}).hover(function(){
		clearTimeout(T);
	},function(){
		T = setTimeout(auto, _timer);
	});
	
	$("#show").hover(function(){
		clearTimeout(T);
	},function(){
		T = setTimeout(auto, _timer);
	});
	
	function auto(){
		if(i+1<M.length){
			i++;
		}else{
			i=0;
		}
		M.eq(i).click();
		$(this).parent("li").siblings("li").children("a").removeClass("over");
		$(this).addClass("over");
		//$("#show img").animate({opacity:1},600);
		T = setTimeout(auto, _timer);
	}
	auto();
});