function $(id){
	return document.getElementById(id);
}

function toggleInfo(obj){
	if(document.getElementById(obj).style.display=='none'){
		document.getElementById(obj).style.display='';
		obj.title = "折叠";
	}else{
		document.getElementById(obj).style.display='none';
		obj.title = "展开";
	}
	
}

function fGoto(num){
	 var p;
	 var p1;
	 if (num>0){
	 for (i=1;i<=4;i++) 
     {
	 p =top.f0.document.getElementById("m"+i);
     p.className="";
	 }
	 p =top.f0.document.getElementById("m"+num);
     p.className="on";
	 }
	 for (i=1;i<=3;i++) 
     {
	 p1 =top.f0.document.getElementById("sl"+i);
	 p1.className="";
	 }
	 switch(num){
	 case 1:
	 top.f0.document.getElementById("sl2").className="spl";
	 top.f0.document.getElementById("sl3").className="spl";
	 break;
	 case 2:
	 top.f0.document.getElementById("sl3").className="spl";	 
	 break;
	 case 3:
	 top.f0.document.getElementById("sl1").className="spl";
	 break;
	 case 4:
	 top.f0.document.getElementById("sl1").className="spl";
	 top.f0.document.getElementById("sl2").className="spl";
	 break;
	 }

}

function Fsel(num,num1){
	 var p;
	 var tnum
	 tnum=num1+4
	 if (num>0){
		 for (i=1;i<=tnum;i++) 
		 {
		 p =top.f1.document.getElementById("left_btn"+i);
		 p.className="";
		 }
		 p =top.f1.document.getElementById("left_btn"+num);
		 p.className="on";
	 }
}

function theright(rurl, onlyone) {
	var mrstr = String(Math.random());
	
	if (onlyone == true)
		parent.f2.window.location.href = rurl + "?GRSN=" + mrstr.substring(2, 10);
	else
		parent.f2.window.location.href = rurl + "&GRSN=" + mrstr.substring(2, 10);
}

function msearch() {
    frmsearch.mailsearch.value = "\t\tSubject\t1\t" + frmsearch.stext.value + "\t\tRecDate\t1\t" + frmsearch.syear.value + frmsearch.smonth.value + frmsearch.sday.value + "\t\tSize\t1\t\tRead\t1\t1\t\tFolders\tin\tout\tsed\t\del\t\t";
	frmsearch.submit();
}

function emptyfolder() {
	if (confirm("确实要清空垃圾箱吗?") == false)
		return ;

	theright('mulmail.jsp?mode=cleanTrash', false);
	alert ("已清空垃圾箱。");
	theright('listmail.jsp?mode=del', false);
}

var xmlHttp;
function GetFolderInfo(ibxcount)
   {  
     xmlHttp = false;  
     if(window.XMLHttpRequest) 
     {  
        try
         {  
            xmlHttp = new XMLHttpRequest();  
        } catch(e) {  
            xmlHttp = false;  
        }  

        } else if(window.ActiveXObject) 
        {  
           try 
           {  
                  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");  
           } catch(e)
           {  
                 try {  
                     xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  
                    } catch(e) 
                    {  
                         xmlHttp = false;  
                    }  
           }  
        }  
       if(xmlHttp) 
      {  
        xmlHttp.onreadystatechange = UpdateFolderInfo; 
        xmlHttp.open("GET", "Ajax_InfoList.jsp?NewEmailAlarm="+ibxcount, true);  
        xmlHttp.send();  
      }
  }  

function UpdateFolderInfo()   
{ 
	
	//调用Ajax更新文件夹新邮件数目
	
		if (xmlHttp.readyState == 4) 
		{  
			if (xmlHttp.status == 200) 
			{  
				
				 var FolderInfoCount=xmlHttp.responseText.split("|");
				 if (FolderInfoCount[0] > 0){
					 top.f1.document.getElementById("FdIbx").innerHTML="<span id='FdIbx'><strong>收件箱("+ FolderInfoCount[0] + ")</strong></span>";
				 }else{
					 top.f1.document.getElementById("FdIbx").innerHTML="<span id='FdIbx'>收件箱</span>";
				 }
				 
				 if (FolderInfoCount[1] > 0){
					top.f1.document.getElementById("FdDel").innerHTML="<span id='FdDel'><strong>已删除("+FolderInfoCount[1]+")</strong></span>";
				 }else{
					top.f1.document.getElementById("FdDel").innerHTML="<span id='FdDel'>已删除</span>"; 
				 }
				 
				 if (FolderInfoCount[2] > 0){
					popmsg("您好，您有"+FolderInfoCount[2]+"封新邮件！");
				 }
				 
			} else {  
				alert("网络连接故障，请稍后重试或管理员联系!:\n" + xmlHttp.statusText);  
			}  
		}
}  


function UpdateFolderInfo_d(Ibxcount,Delcount)   
{ 
    //直接更新文件夹新邮件数目，避免再次调用AJAX更新，减少服务器负担
	
    if (Ibxcount!="" || Delcount!=""){
		if (Ibxcount > 0){
			 top.f1.document.getElementById("FdIbx").innerHTML="<span id='FdIbx'><strong>收件箱("+ Ibxcount + ")</strong></span>";
		 }else{
			 top.f1.document.getElementById("FdIbx").innerHTML="<span id='FdIbx'>收件箱</span>";
		 }
		 
		 if (Delcount > 0){
			top.f1.document.getElementById("FdDel").innerHTML="<span id='FdDel'><strong>已删除("+Delcount+")</strong></span>";
		 }else{
			top.f1.document.getElementById("FdDel").innerHTML="<span id='FdDel'>已删除</span>"; 
		 }
	}
}

function NewEmailAlarm(mailnow){
   setInterval("GetFolderInfo("+mailnow+")",5000);
}


var oPopup = window.createPopup();
var popTop=40;

function popmsg(msgstr){
var winstr="<table style=\"border: 1 solid  #6D93C8\"  width=\"241\" height=\"80\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"   >";
winstr+="<tr><td align=\"center\"><table width=\"90%\" height=\"10\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
winstr+="<tr><td valign=\"top\" style=\"font-size:12px; color: #6D93C8;\"><b>"+msgstr+"</b></td></tr></table></td></tr></table>";
oPopup.document.body.innerHTML = winstr;
popshow();
}

function popshow(){
window.status=popTop;
if(popTop>1000){
clearTimeout(mytime);
oPopup.hide();
return;
}else if(popTop>820&&popTop<1000){
oPopup.show(screen.width-250,screen.height,241,1000-popTop);
}else if(popTop>800&&popTop<820){
oPopup.show(screen.width-250,screen.height+(popTop-820),241,80);
}else if(popTop<100){
oPopup.show(screen.width-250,screen.height,241,popTop);
}else if(popTop<50){
oPopup.show(screen.width-250,screen.height-popTop,241,80);
}
popTop+=10;
var mytime=setTimeout("popshow();",30);
}

