﻿$(document).ready(function(){
	if(!(typeof(jQuery)=='undefined')){
				
		if(typeof(t)!='undefined'){
			if(t=="index"){
				news_fun(); // 先执行一次函数 news()
				newInter = setInterval('news_fun()', 6100); // 然后每隔 6100 毫秒执行一下函数 news()	
			}
			if(t=="service"){
				flag_fun(); // 先执行一次函数 news()
				newInter = setInterval('flag_fun()', 8100); // 然后每隔 6100 毫秒执行一下函数 news()	
			}
			if(t=="list"){
				changeli('list_ul');
				smenuchange();
			}
			if(t=="solutions"){
				changebox('splitBox');	
			}
		}
		
	}
});

/*首页用到的功能*/
var news_i = 0, //li排序序号
news_li_arr = 0;
news_li_num = 0; // 统计li数量并减 1 处理
var newInter;
var newTime;

function news_fun() {
	if(news_li_arr==0){
	news_li_arr = $("#news_ul").children("li");
	news_li_num = news_li_arr.length - 1; // 统计li数量并减 1 处理
	}
	if (news_i > news_li_num) {news_i = 0;} // 如果计数器（li排序）大于 news_li_num 时归零
	$('#news_ul li:eq('+news_i+')').fadeIn(800); //渐显效果显示第 news_i 个li
	newTime = setTimeout(function() {$('#news_ul li:eq('+news_i+')').fadeOut(800);news_i++;},6100);
};

/*服务与支持页面*/
function flag_fun() {
	if(news_li_arr==0){
	news_li_arr = $("#servicepinfo").children("p");
	news_li_num = news_li_arr.length - 1; // 统计li数量并减 1 处理
	}
	if (news_i > news_li_num) {news_i = 0;} // 如果计数器（li排序）大于 news_li_num 时归零
	$('#servicepinfo p:eq('+news_i+')').fadeIn(800); //渐显效果显示第 news_i 个li
	newTime = setTimeout(function() {$('#servicepinfo p:eq('+news_i+')').fadeOut(800);news_i++;},7100);
};

/**
 * 首页上一条新闻，下一条新闻事件
 **/
function nextNews(fun){
	if(typeof(newTime)!='undefined'){
		clearTimeout(newTime);
	}
	if(typeof(newInter)!='undefined'){
		clearInterval(newInter);
	}
	$('#news_ul li:eq('+news_i+')').fadeOut(800);
	if(fun>0){
	  news_i++;
	  if (news_i > news_li_num) {news_i = 0;}
	}else if(fun<0){
	  news_i--;
	  if (news_i < 0) {news_i = news_li_num;}
	}
	$('#news_ul li:eq('+news_i+')').fadeIn(800);
	newInter = setInterval('news_fun()', 6100);
}

/*列表页面隔行加on样式*/
function changeli(id){
	$.each($("#"+id).children("li"),function(n,v){
		if(n%2==0)
			$(v).addClass("on");								 
	});
}

/*选项卡效果*/
function changebox(id){
	$("#"+id+">.tit>ul>li>a").bind("click",function(){
		var html = $(this).html();
		$.each($("#"+id+">.tit>ul>li"),function(n,o){				
			if(html==$(o).children('a').html()){
				$("#"+id+">.tit>ul>li").removeClass("on");
				$("#"+id+">.cont>dl").hide();
				$("#"+id+">.cont>dl:eq("+n+")").show();
			}
		});
		$(this).parent().addClass("on");
	});	
}

/*改变二级菜单显示*/
function smenuchange(){
	$("#smenu_"+pid).addClass("show");
	$.each($("#smenu_ul>li>a"),function(n,v){
		if(typeof(cname)!='undefined'&&$(v).html()==cname){
			$(v).parent().addClass("show");
			if($(v).parent().attr("class")!="show")
			  $(v).parent().addClass("show");
		}
	});
	$.each($("#smenu_ul>li>ol>li>a"),function(n,v){
		if(typeof(cname)!='undefined'&&$(v).html()==cname){
			$(v).parent().addClass("on");
			if($(v).parent().parent().parent().attr("class")!="show")
			  $(v).parent().parent().parent().addClass("show");
		}
	});
}
