// JavaScript Document
// --- 设置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;
 }

$(document).ready(function(){
	var iframe=document.getElementById("iframe");
	var A=getCookie("A");
	var B=getCookie("B");
	if(A==17){
	iframe.src="help.html";
	}
	if(A==18){
	iframe.src="help.html";
	}
	if(A==21){
	iframe.src="learnonline/peixun.php";
	}
	if(A==19){
	iframe.src="learnonline/seo.php";
	}
	if(A==20){
	iframe.src="learnonline/sem.php";
	}
	if(A==""||A==null){
		A=100;
		}
	if(A==100){
	iframe.src="welcome.php";
	}
	if(A==16){
	iframe.src="tool/index.php";
	}
	if(A==12){
	iframe.src="msg/receive.php";
	}
	if(A==13){
	iframe.src="flink/index.php";
	}
	if(A==14){
	iframe.src="msg/gonggao.php";
	}
	if(A==15){
	iframe.src="zhizhu/index.php";
	}
	if(A==0){
	if(B==11)
	iframe.src="keyword/content/index.php";
	if(B==""||B=="undefined"||B==12)
	iframe.src="keyword/paiming/index.php";
	if(B==13)
	iframe.src="keyword/kwcreate/index.php";
	}
	if(A==1){
	if(B==""||B=="undefined"||B==11)
	iframe.src="keyword/content/index.php";
	if(B==12)
	iframe.src="keyword/paiming/index.php";
	if(B==13)
	iframe.src="keyword/kwcreate/index.php";
	}
	if(A==2){
	iframe.src="weblink/index.php";
	}
	if(A==3){
	iframe.src="blog/index.php";
	}
	if(A==4){
	iframe.src="negative/index.php";
	}
	if(A==5){
	if(B==1||B==""||B=="undefined")
	iframe.src="datacount/flow/index.php";
	if(B==2)
	iframe.src="datacount/consulting/index.php";
	}
	if(A==6){
	if(B==1||B==""||B=="undefined")
	iframe.src="shujufenxi/indexf.php";
	if(B==2)
	iframe.src="shujufenxi/indexc.php";
	}
	if(A==7){
	iframe.src="renwutongji/index.php";
	}
	if(A==8){
	iframe.src="report/index.php";
	}
	if(A==9){
	iframe.src="news/index.php";
	}
	if(A==10){
	if(B==""||B=="undefined"||B==1)
	iframe.src="systemset/webset/index.php";
	if(B==2)
	iframe.src="systemset/typeset/index.php";
	if(B==3)
	iframe.src="systemset/userset/index.php";
	if(B==4)
	iframe.src="systemset/channel/index.php";
	if(B==5)
	iframe.src="systemset/reportset/index.php";
	if(B==6)
	iframe.src="systemset/negativeset/index.php";
	}
	if(A==11){
	if(B==1)
	iframe.src="systemset/webset/index.php";
	if(B==2)
	iframe.src="systemset/typeset/index.php";
	if(B==""||B=="undefined"||B==3)
	iframe.src="systemset/userset/index.php";
	if(B==4)
	iframe.src="systemset/channel/index.php";
	if(B==5)
	iframe.src="systemset/reportset/index.php";
	if(B==6)
	iframe.src="systemset/negativeset/index.php";
	}
	changebg(A);
	$("a").click(function(){
		$("tr").css({"background":"none"});	
		var A=getCookie("A");
		changebg(A);
			$.post("getmail.php",{},function(data){
	var gonggao=data.split("|")[0];
	var title=gonggao.split(",")[0];
	var content=gonggao.split(",")[1];
	var date=gonggao.split(",")[2];
	var send=gonggao.split(",")[3];
	var num=data.split("|")[1];
	var marqueebox0=document.getElementById("marqueebox0");
	marqueebox0.innerHTML="";
	marqueebox0.innerHTML="<div style='text-align:center;color:#000000;'>["+date+"]&nbsp;"+title+"</div><div style='text-align:left;'>"+content+"</div><div style='text-align:center;color:#000000;'>["+date+"]&nbsp;"+title+"</div><div style='text-align:left;'>"+content+"</div>";
	var newmail=document.getElementById("newmail");
	if(num==0){
		newmail.innerHTML="<a href='javascript:void(0);' onclick='change(12)'>收件箱</a>";
		}else{
			newmail.innerHTML="<a href='javascript:void(0);' onclick='change(12)'>"+"收件箱&nbsp;("+num+")</a>";
			}
									 });
						  });
	$.post("getmail.php",{},function(data){
	var gonggao=data.split("|")[0];
	var title=gonggao.split(",")[0];
	var content=gonggao.split(",")[1];
	var date=gonggao.split(",")[2];
	var send=gonggao.split(",")[3];
	var num=data.split("|")[1];
	var marqueebox0=document.getElementById("marqueebox0");
	marqueebox0.innerHTML="";
	marqueebox0.innerHTML="<div style='text-align:center;color:#000000;'>["+date+"]&nbsp;"+title+"</div><div style='text-align:left;'>"+content+"</div><div style='text-align:center;color:#000000;'>["+date+"]&nbsp;"+title+"</div><div style='text-align:left;'>"+content+"</div>";
	var newmail=document.getElementById("newmail");
	if(num==0){
		newmail.innerHTML="<a href='javascript:void(0);' onclick='change(12)'>收件箱</a>";
		}else{
			newmail.innerHTML="<a href='javascript:void(0);' onclick='change(12)'>"+"收件箱&nbsp;("+num+")</a>";
			}
					 });
	
		
						   });
//iframe控制
function change(A){
	var iframe=document.getElementById("iframe");
	if(A==17){
		setCookie("A","17");
	iframe.src="help.html";
	}
	if(A==18){
		setCookie("A","18");
	iframe.src="help.html";
	}
	if(A==21){
		setCookie("A","21");
	iframe.src="learnonline/peixun.php";
	}
	if(A==19){
		setCookie("A","19");
	iframe.src="learnonline/seo.php";
	}
	if(A==20){
		setCookie("A","20");
	iframe.src="learnonline/sem.php";
	}
	if(A==100){
		setCookie("A","100");
	iframe.src="welcome.php";
	}
	if(A==16){
		setCookie("A","16");
	iframe.src="tool/index.php";
	}
	if(A==12){
		setCookie("A","12");
	iframe.src="msg/receive.php";
	}
	if(A==13){
		setCookie("A","13");
	iframe.src="flink/index.php";
	}
	if(A==14){
		setCookie("A","14");
	iframe.src="msg/gonggao.php";
	}
	if(A==15){
		setCookie("A","15");
	iframe.src="zhizhu/index.php";
	}
	if(A==0){
	setCookie("A","0");
	iframe.src="keyword/paiming/index.php";
	}
	if(A==1){
	setCookie("A","1");
	iframe.src="keyword/content/index.php";
	}
	if(A==2){
	setCookie("A","2");
	iframe.src="weblink/index.php";
	}
	if(A==3){
	setCookie("A","3");
	iframe.src="blog/index.php";
	}
	if(A==4){
	setCookie("A","4");
	iframe.src="negative/index.php";
	}
	if(A==5){
	setCookie("A","5");
	iframe.src="datacount/flow/index.php";
	}
	if(A==6){
	setCookie("A","6");
	iframe.src="shujufenxi/indexf.php";
	}
	if(A==7){
	setCookie("A","7");
	iframe.src="renwutongji/index.php";
	}
	if(A==8){
	setCookie("A","8");
	iframe.src="report/index.php";
	}
	if(A==9){
	setCookie("A","9");
	iframe.src="news/index.php";
	}
	if(A==10){
	setCookie("A","10");
	iframe.src="systemset/webset/index.php";
	}
	if(A==11){
	setCookie("A","11");
	iframe.src="systemset/userset/index.php";
	}
	$("tr").css({"background":"none"});
	changebg(A);
	setCookie("B","");
	}
//menubg
function changebg(A){
	if(A!=100){
  document.getElementById(A).style.background="#16507a";
	}
	}
	
//公告滚动效果
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); 
} 
function deletecookie(){
setCookie("A","100");
setCookie("B","");
}