// JavaScript Document
$(document).ready(function(){
	setNavMenu();//加载菜单效果
	$("a[href*='http://']:not([href*='"+location.hostname+"']),[href*='https://']:not([href*='"+location.hostname+"'])").attr("target","_blank");//处理外部链接
	$(".H_qlinks select").change(function(){
		if($(this).find("option:selected").val() == 0 || $(this).find("option:selected").val() == ''){return false;}
		else{window.open($(this).find("option:selected").val(),'_blank'); $(this).find("option:first").attr("selected","selected");}
	});//处理下拉列表
	autoShow();//新闻图片
	autoImg();//首页大图
    noticeList();//首页公告
	festival();//节日图
	$(".H_news > .H_home_title").mouseover(function(){
		var newsIndex = $(".H_news > .H_home_title").index(this);
		$(".H_news > .H_home_title .E235").removeClass('E235');
		$(".H_news > .H_home_title .H_home_title_en").eq(newsIndex).addClass('E235');
		$(".H_news > .H_home_title .H_home_title_ch").eq(newsIndex).addClass('E235');
		$(".H_news > .H_news_list:visible").hide();
		$(".H_news > .H_news_list").eq(newsIndex).show();
	});//新闻和媒体湖大标题效果
});

function festival(){
	var Len = $(".H_festival a").length;
	if(Len == 1){
		$(".H_festival").animate({height:"230px"},1500);
		$(".H_festival a").click(function(){
			$(this).parent(".H_festival").animate({height:"0px"},1000);
		});
		setTimeout(function(){$(".H_festival").animate({height:"0px"},1000);},9500);
	}
}//首页节日图

function noticeList(){
	var len  = 6;
	var index = 0;
	//滑入 停止动画，滑出开始动画.
	$(".H_notice_list > ul").hover(
	function(){ if(MyTime){$(".H_notice_list > ul").stop(); clearInterval(MyTime);}},
	function(){ MyTime = setInterval(function(){if(index > len){$(".H_notice_list > ul").css('margin-top','0px'); index=0;} autoRun(index); index++;},1000);}
	);
	//自动开始
	var MyTime = setInterval(function(){if(index > len){$(".H_notice_list > ul").css('margin-top','0px'); index=0;} autoRun(index); index++;},1000);
	function autoRun(i){
		$(".H_notice_list > ul").stop(true,false).animate({marginTop : -23*i},1000);
	}
}//公告滚动

function autoShow(){
	//$(".H_news_imgs ul li").eq(0).show();
	var Index = 1;
	var Len = $(".H_news_imgs ul li").length;
	setInterval(function(){imgShow(Index); Index++; if(Index == Len){Index = 0;}},5000);
	function imgShow(i){
		$(".H_news_imgs ul li:visible").fadeOut("slow");
		$(".H_news_imgs ul li").eq(i).fadeIn("slow");
	}
}//新闻图片

function autoImg(){
	//$(".H_banner_imgs ul li").eq(0).show();
	var Index = 1;
	var Len = $(".H_banner_imgs ul li").length;
	setInterval(function(){imgShow(Index); Index++; if(Index == Len){Index = 0;}},5000);
	function imgShow(i){
		$(".H_banner_imgs ul li:visible").fadeOut("slow");
		$(".H_banner_imgs ul li").eq(i).fadeIn("slow");
	}
}//首页大图滚动

var lastNavIndex=0;
function setNavMenu()
{
	var j = 1;
	$(".H_nav > ul > li").click(function(){
		i = $(".H_nav > ul >li").index(this)+1;
		$(".H_after_"+j).removeClass('H_after_'+j);
		$(this).addClass('H_after_'+i);
		j = i;
		if(lastNavIndex!=i)
		{
			lastNavIndex=i;
			$("#menubg").stop();
			$(".menu").stop();
			$("#menubg").css('left', '-135px');
			$(".menu").css('left','-135px');
			$("#menubg").animate( {left: "0px"},400);
			$("#menu"+i).animate( {left: "0px"},400);

		}else{
			lastNavIndex=0;
			$("#menubg").animate( {left: "-135px"},400);
			$(".menu").animate( {left: "-135px"},400);

		}				
	});
}//菜单效果
