﻿// JavaScript Document
$(function(){
	//搜索条的选项下拉菜单	   
	$("#sel_search_txt>a").click(function(){
		$("#sel_search_txt>ul").slideDown("fast"); 
	})	
	$("#sel_search_txt>ul>li>a").click(function(){
		$("#sel_search_txt>b").html($(this).html());	
		$("#search_txt_ul_value").attr("value",($(this).attr("title")));
		$("#sel_search_txt>ul").slideUp("fast"); 
	})
	$("#sel_search_txt").bind("mouseleave", function(){
		$("#sel_search_txt>ul").slideUp("slow"); 
	})
	
	//下拉导航菜单
	//$("#header_nav a").click(function(){
		//alert($(thisObj).offset().left);  
	$("#header_nav>li>a>span").each(function(index){
		$(this).mouseover(function(){
			var obj_left = $(this).position().left;
			var obj_width = $(this).width()+30;
			
			var menu_list=new Array();
			menu_list = eval($(this).parent().next().attr("value"));
			if (menu_list.length>0){
				$("#down_menu_li").html("");
				$("#down_menu_li").append("<ul></ul>"); 
				for (i=0; i<menu_list.length ;i++){
				
				    var temp_content = "";
				    
				    temp_content="<li><a href='" + menu_list[i].menu_url + "' >" + menu_list[i].menu_name + "</a></li>";
					$("#down_menu_li>ul").append(temp_content); 
				}
				$("#down_menu_li").hide();
				$("#down_menu_li").css("left",obj_left-19);
				$("#down_menu_li").width(obj_width+4);
				$("#down_menu_li").height(menu_list.length*25);
				$("#down_menu_li").slideDown("fast"); 
				
				//alert($("#down_menu_li").html());
			}
		})
	})
	
	$("#down_menu_li").bind("mouseleave", function(){
		$("#down_menu_li").fadeOut("slow"); 
	})
	
	//关键字高亮显示
	search_fu('search_txt_value','search_content_list');


	
	
	//得到实时间显示在导航条上
	fGetTime ();
	

	//服务机构表
	$("#sever_list_ul>li:first").addClass("li_sel");	
	//$("#sever_list_ul_main>dl>dd:not(:first)").hide();
	$("#sever_list_ul>li").each(function(index){
		$(this).click(function(){
			$("#sever_list_ul>li").removeClass("li_sel");
			$(this).addClass("li_sel");	
			//$("#sever_list_ul_main>dl>dd").hide();
			//$("#sever_list_ul_main>dl>dd:eq("+ index +")").show();
		})
	})
	
	//首页上小栏目切换
	$("#main_right .menu_center_dl").each(function(index_1){
	//$("#main_right .menu_center_dl:not(:has(.menu_center_dt3))").each(function(index_1){
		//$(this).children().children(".menu_center_dt_small").children().eq(0).addClass("sel");
		$(this).children("dd").each(function(index_2){
			if (index_1!=2){
				if(index_2>7){								 
					$(this).hide();
				}
			//$("#main_right .menu_center_dl:eq("+ index_1 +")").css("height","237px");
			}
			else{
				if(index_2>6){								 
					$(this).hide();
				}
			//$("#main_right .menu_center_dl:eq("+ index_1 +")").css("height","212px");
			}
		})
		$(this).children().children("b").click(function(index_5){
			$(this).parent().parent().children("dd").hide();
			if (index_1!=2){
				$(this).parent().parent().children("dd:lt(8)").show();
			}
			else{															
				$(this).parent().parent().children("dd:lt(7)").show();
			}
			$(this).parent().children(".menu_center_dt_small").children().removeClass("sel");	   
		})
		
		$(this).children().children(".menu_center_dt_small").children().each(function(index_3){
			$(this).click(function(){	
				$(this).parent().children().removeClass("sel");	   
				$(this).addClass("sel");
				//的的现实和隐藏
				$(this).parent().parent().parent().children("dd").hide();
				$(this).parent().parent().parent().children("dd").each(function(index_4){
				if (index_1!=2){																
					if(((index_3+1)*8<=index_4) && (index_4< (index_3+2)*8)){
						$(this).show();
					}
				}
				else{															
					if(((index_3+1)*7<=index_4) && (index_4< (index_3+2)*7)){
						$(this).show();
					}
				}
				});
				return false;
			})
		})
	})
		   
})


//当前时间的自定义函数；
function fGetTime () {
	var datNow = new Date();
	var year = datNow.getFullYear();
	var month = datNow.getMonth() + 1;
	var week = datNow.getUTCDay();
	var date = datNow.getDate();
	var hours = datNow.getHours();
	var minutes = datNow.getMinutes();
	var seconds = datNow.getSeconds();
	var day = datNow.getDay();
	var strTime = "";

	week = fFormatWeek(week);

	strTime +="当前时间："+ year + "年" + month + "月" + date + "日 ";
	strTime += "星期"+ week + " ";
	strTime += ((hours <= 24) ? hours : hours - 24);
	strTime += ((minutes < 10) ? ":0" : ":") + minutes;
	strTime += ((seconds < 10) ? ":0" : ":") + seconds;
	//spnDate.innerText = strTime;
	document.getElementById("welcome_infor").firstChild.nodeValue =strTime;
	timerID = window.setTimeout("fGetTime()",1000);
	timerRunning = true;
}

function fFormatWeek(src){
	var sValue ="";
	var sTmp = "1,2,3,4,5,6,7,0";

	if(sTmp.indexOf(src) == -1) return "1";	//如果异常,则退出，返回星期一.
	switch(src)
	{
		case 1:	
			sValue = "一";
			break;
		case 2:	
			sValue = "二";
			break;
		case 3:	
			sValue = "三";
			break;
		case 4:	
			sValue = "四";
			break;
		case 5:	
			sValue = "五";
			break;
		case 6:	
			sValue = "六";
			break;
		case 7:	
			sValue = "日";
			break;
		case 0:	
			sValue = "日";
			break;
		default :	
			sValue = "3";
			break;
	}
	return sValue;
}


//关键字高亮显示
function search_fu(search_id,area_id){
	if(document.getElementById(search_id) != null){
		var search_txt=document.getElementById(search_id).value;
		if(search_txt.length > 0){
			search_num=search_txt.split(","); 
			for (i=0;i<search_num.length ;i++ ){  
				var search_txt_temp=document.getElementById(area_id).innerHTML; 
				document.getElementById(area_id).innerHTML=search_txt_temp.replace(new RegExp(search_num[i],'g'),"<font color='red'>"+search_num[i]+"</font>");	
			}
		}
	}
}

