// JavaScript Document
$(document).ready(function(){
	//侧边栏缩放
	$("#hideandshow").click(function(){
		if($(".left").width()>100){
		$(".left").css("width","0px");							 
		$("#menu_list").css("display","none");
		$(".left").css("margin-right","0px");
		$(".right").css("margin-left","5px");
		$("#hideandshow").css("left","0px");
		$("#hideandshow").html(">");
		}else{
			$(".left").css("width","150px");							 
		$("#menu_list").css("display","");
		$(".left").css("margin-right","-150px");
		$(".right").css("margin-left","155px");
		$("#hideandshow").css("left","149px");
		$("#hideandshow").html("<");
			}
									 });
	
	//公告内容获取
	$.post("class/class_getdata_annou.php",{},function(data){
		var datas=data.split("|");
		var date=datas[0];
		var title=datas[1];
		var content=datas[2];
		$("#marqueebox0").html("暂无公告");
		if(date!="")
		$("#marqueebox0").html("<div style='text-align:left;color:#000000;'><img src=\"imgs/notice.png\">["+date+"]&nbsp;"+title+"："+content+"</div><div style='text-align:left;color:#000000;'><img src=\"imgs/notice.png\">["+date+"]&nbsp;"+title+"："+content+"</div>");
													 });
	//获取邮件信息
	$.post("class/class_getdata_email.php",{},function(data){
parent.$("#email").html(data);
});
	//左侧导航显示初始化
	var top_menu=$(".top_menu");
	var auth_fun=$("#auth_fun").val();
	var auth_array=auth_fun.split("|");
	var top_array=auth_array[0].split(",");
	var len=top_array.length;
	for (var i=0;i<len;i++){
		$(".top_menu").eq(top_array[i]).show();
		}
	
  //左边菜单控制显示
  $(".top_menu").click(function(){
		$(".child_menu0,.child_menu1,.child_menu2,.child_menu3,.child_menu4,.child_menu5,.child_menu6").hide();
		var i=$(".top_menu").index(this);
		var child_array=auth_array[i+1].split(",");
		var clen=child_array.length;
		var child_menu="child_menu"+i;
		for(var j=0;j<clen;j++){
		$("."+child_menu).eq(child_array[j]).show();
		}
								});
  //选中二级菜单效果
   $(".child_menu0 a,.child_menu1 a,.child_menu2 a,.child_menu3 a,.child_menu4 a,.child_menu5 a,.child_menu6 a").click(function(){
		$(".child_menu0 td,.child_menu1 td,.child_menu2 td,.child_menu3 td,.child_menu4 td,.child_menu5 td,.child_menu6 td").css("background-image","url(imgs/child_menu.gif)");							  
		var i=$(".child_menu0 a,.child_menu1 a,.child_menu2 a,.child_menu3 a,.child_menu4 a,.child_menu5 a,.child_menu6 a").index(this);
		$(this).parent("td").css("background-image","url(imgs/child_menu_select.gif)");	
		var iframe_src=this.id+"/index.php";
		$("#right_iframe").attr("src",iframe_src);
									  });


  //点击非功能菜单
  $("#welcome,#email,#gonggao,#jiaohuan,#zhuanyi").click(function(){
		$(".child_menu0,.child_menu1,.child_menu2,.child_menu3,.child_menu4,.child_menu5,.child_menu6").hide();		
		$(".child_menu0 td,.child_menu1 td,.child_menu2 td,.child_menu3 td,.child_menu4 td,.child_menu5 td,.child_menu6 td").css("background-image","url(imgs/child_menu.gif)");
											   });
						   
						   });
//公告滚动效果
function startmarquee(lh,speed,delay,index){ 
var t; 
var p=false; 
var o=document.getElementById("marqueebox"+index); 
o.innerHTML+=o.innerHTML; 
o.onmouseover=function(){p=true} 
o.onmouseout=function(){p=false} 
o.scrollTop = 0; 
function start(){ 
t=setInterval(scrolling,speed); 
if(!p){ o.scrollTop += 1;} 
} 
function scrolling(){ 
if(o.scrollTop%lh!=0){ 
o.scrollTop += 1; 
if(o.scrollTop>=o.scrollHeight/2) o.scrollTop = 0; 
}else{ 
clearInterval(t); 
setTimeout(start,delay); 
} 
} 
setTimeout(start,delay); 
} 

	// --- 设置cookie
 function setCookie(sName,sValue,expireHours) {
  var cookieString = sName + "=" + escape(sValue);
  //;判断是否设置过期时间
  if (expireHours>0) {
    var date = new Date();
    date.setTime(date.getTime + expireHours * 3600 * 1000);
    cookieString = cookieString + "; expire=" + date.toGMTString();
  }
  document.cookie = cookieString+";path=/";
 }
 
 //--- 获取cookie
 function getCookie(sName) {
   var aCookie = document.cookie.split("; ");
   for (var j=0; j < aCookie.length; j++){
  var aCrumb = aCookie[j].split("=");
  if (escape(sName) == aCrumb[0])
    return unescape(aCrumb[1]);
   }
   return null;
 }