

/////////////////////////////////////////////////////////////////////////////////////////////////
// 全局JS常量
/////////////////////////////////////////////////////////////////////////////////////////////////
var C_AJAX_TIMEOUT = "100";


/////////////////////////////////////////////////////////////////////////////////////////////////
// 全局JS变量
/////////////////////////////////////////////////////////////////////////////////////////////////
var G_WriteState = 0;			// 写邮件状态：0、邮件未修改，1、邮件已修改



/////////////////////////////////////////////////////////////////////////////////////////////////
// 全局JS函数
/////////////////////////////////////////////////////////////////////////////////////////////////

// 获取顶部window
function getTop()
{
	var _oSelfFunc=arguments.callee;

	if(!_oSelfFunc._moTop)
	{
		try
		{
			if(window!=parent)
			{
				_oSelfFunc._moTop=parent.getTop?parent.getTop():parent.parent.getTop();
			}
			else
			{
				_oSelfFunc._moTop=window;
			}
		}
		catch(aL)
		{
			_oSelfFunc._moTop=window;
		}
	}

	return _oSelfFunc._moTop;
}


// 在顶层显示对话框
function ShowTopDialog(	Width,			// 宽度
						Height,			// 高度
						Html,			//
						Title)			// 可拖动DIV的ID
{
	try{
		var Top = getTop();

		// 获取屏幕尺寸
		var innerWidth =Top.document.body.clientWidth;
		var innerHeight = Top.document.body.clientHeight;
        if(innerWidth=='0' || innerHeight=='0')
		{
			innerWidth='1200';
			innerHeight='600';
		}
		var x = (innerWidth - Width)/6;
		var y = (innerHeight - Height)/6;

		// 设置尺寸并展示
		Top.$("Dialog").style.left			= x+"px";
		Top.$("Dialog").style.top			= y+"px";
		//Top.$("Dialog").style.width			= Width+"px";
		//Top.$("Dialog").style.height		= Height+"px";

		Top.$("Dialog").innerHTML			= Html;
		Top.$("Dialog").style.display		= "";
		Top.$("DialogMask").style.display	= "";

		// 注册可拖动
		dragdrop.registerDragdropHandler(Title, "Dialog");
	}catch(err){}
}


// 关闭顶层对话框
function CloseTopDialog()
{
	try{
		var Top = getTop();

		// todo
//		Top.$("Dialog").innerHTML			= "";
		Top.$("Dialog").style.display		= "none";
		Top.$("DialogMask").style.display	= "none";
	}catch(err){}
}


// 用于被Ajax.Responders.register注册，显示和关闭进度提示
var AjaxRespondersHandlers =
{
	onCreate: function()
	{
		getTop().$("showdialog").style.display='';
	},

	onComplete: function()
	{
		// 正在处理中的Ajax请求的个数
		if(Ajax.activeRequestCount == 0)
		{
			getTop().$("showdialog").style.display='none';
		}
	}
};

function AjaxRequest(strUrl, objParams)
{
	try{
		var strParams = "checktime=" + new Date().getTime() + Math.random();

		for(var key in objParams)
		{
			strParams += "&" + key + "="  + encodeURIComponent(objParams[key]);
		}

		// 注册Ajax.Responders事件
		Ajax.Responders.register(AjaxRespondersHandlers);

		var recvActing = new Ajax.Request(strUrl,
		{
			method:'get',
			parameters:strParams,

			onSuccess: function(transport)
			{
				if (transport.responseText == C_AJAX_TIMEOUT)
				{
					// todo
					alert("AjaxRequest超时");
					return;
				}
				else
				{
					var arrRspInfo = eval("(" + transport.responseText + ")");

					if(!arrRspInfo)
						return;
					else
						return arrRspInfo;
				}
			}
		});
	}catch(err){}
}

function ShowAdvSearch(para,msg)
{
	var Html = ' \
	<div class="Float_box"> \
	<div id="advsearch_Dialog__closebtn_" class="Close" title='+fuwCode["closewindow"]+' onclick="CloseTopDialog();"></div>\
	<div id="advsearch_Dialog__title_div_" class="Float_boxT" unselectable="on"><div id="advsearch_Dialog__title_td_" onselectstart="return false;" unselectable="on"><ul id="advsearch_Dialog__title_" class="Search_ul" style="width:490px;">'+fuwCode["adv_search"]+'</ul>\
</div>\
</div>\
    <div style="width: 536px; height: 305px;" id="advsearch_Dialog__dlgiframe_"> </div>\
	<iframe style="width: 535px; height:335px;display:none;" id="topFrame" src="" frameBorder=0 scrolling=no> </iframe>\
	</div> \
	';
	if(para=='search')
	{
		ShowTopDialog(536, 210, Html, "advsearch_Dialog__title_");
		document.getElementById("advsearch_Dialog__title_").innerHTML=fuwCode["simpSr"];
		document.getElementById("advsearch_Dialog__dlgiframe_").style.height=305+"px";
		var JS=top["jsLoad"];
		var gArrfolder=JS.gArrfolder;
		var gArrarchivefolder = JS.gArrarchivefolder;
		var html = '<form method="post" action="index.php?action=find_mail" target="mainFrame" id="advSearch" name="advSearch" onsubmit="checkAdvKey();">\
					<input name="searchType" type="hidden" value="1"/>\
					<input type="hidden" id="advsearchmail" name="advsearchmail" value="adv_searchmail">\
					<div class="Search_box">\
						<div class="div_FbM_l">'+fuwCode["simpleSreach"]+'</div>\
				        <div class="div_FbM_r">\
				        	<input type="text" id="searchPhrase" class="input_box" name="searchPhrase" maxLength="32" size="32" onkeydown="return disableEnter(event)">\
				        </div>\
				        <div class="div_FbM_l">'+fuwCode["search_position"]+'</div>\
				        <div class="div_FbM_r" style="z-index:100">\
				        	<ol>\
				        		<dl id="range_value" class="f_boxma" onclick="dl_show(\'range\',\'fid\')">'+fuwCode["all_options"]+'</dl>\
				        		<dl id="range" class="f_boxmb" style="display:none;"><div style="width:100%;height:150px;z-index:100;" onmouseover="m_over(event,\'range\');" onmouseout="m_out(event,\'range\');">\
				        			<dd><a id="all" href="#" onclick="change_value(\'range\',\'all\')">'+fuwCode["all_options"]+'</a></dd>\
				        			<dd><a id="sender" href="#" onclick="change_value(\'range\',\'sender\')">'+fuwCode["sortbysender"]+'</a></dd>\
				        			<dd><a id="receive" href="#" onclick="change_value(\'range\',\'receive\')">'+fuwCode["sortbyrecver"]+'</a></dd>\
				        			<dd><a id="subject" href="#" onclick="change_value(\'range\',\'subject\')">'+fuwCode["search_subject"]+'</a></dd>\
				        		</div></dl>\
				        	</ol>\
				        </div>\
				        <div class="div_FbM_b1"></div>\
				        <div class="div_FbM_l">'+fuwCode["search_folder"]+'</div>\
				        <div id="uboxstyle" class="div_FbM_r"><ol>\
							<dl id="fid_value" class="f_boxma" onclick="dl_show(\'fid\',\'range\')">'+fuwCode["all_options"]+'</dl>\
							<dl id="fid" class="f_boxmb" style="display:none"><div style="width:100%;height:140px;overflow-x:hidden;overflow-y:auto;_overflow-y:scroll;" onmouseover="m_over(event,\'fid\');" onmouseout="m_out(event,\'fid\');">\
								<dd><a id="allfolder" href="#" onclick="change_value(\'fid\',\'allfolder\')">'+fuwCode["all_options"]+'</a></dd>';
				        for(var i=0;i<gArrfolder.length;i++)
				        {
				        	if(gArrfolder[i].id != 'cur')
				        	{
				        		html+='<dd><a id="f_f'+encodeURIComponent(gArrfolder[i].id)+'" href="#" onclick="change_value(\'fid\',\''+encodeURIComponent(gArrfolder[i].id)+'\')">'+gArrfolder[i].name+'</a></dd>';
				        	}	
				        }
						
						for(var i=0;i<gArrarchivefolder.length;i++)
				        {
			        		html+='<dd><a id="f_f'+encodeURIComponent(gArrarchivefolder[i].id)+'" href="#" onclick="change_value(\'fid\',\''+encodeURIComponent(gArrarchivefolder[i].id)+'\')">'+gArrarchivefolder[i].name+'</a></dd>';
				        }	

				        html += '</div></dl></ol>\
				        		 </div></div><div style="padding-left:20px;">'+fuwCode["tip_archive_search"]+'</div>\
				        		 <div class="Float_boxB">\
				        		 	<span><input type="button" class="inputA" style="cursor:pointer;" value="'+fuwCode["sr"]+'" onclick="CheckSearch();"></span><span><input type="button" class="inputB" style="cursor:pointer;" value="'+fuwCode["cancel"]+'" onclick="CloseTopDialog();"></span>\
				        		 </div>\
				        		 </form>';
		document.getElementById("advsearch_Dialog__dlgiframe_").innerHTML = html;		
	}
	if(para=='editpwd')
	{	
		ShowTopDialog(536, 210, Html, "advsearch_Dialog__title_");
		document.getElementById("advsearch_Dialog__title_").innerHTML=fuwCode["editPwd"];
		document.getElementById("advsearch_Dialog__dlgiframe_").style.display ="none";
		document.getElementById("advsearch_Dialog__closebtn_").style.display = "none";
		document.getElementById("topFrame").style.display ='';
		document.getElementById("topFrame").src="index.php?action=loginPwd";
	}
	if(para=='msg_error')
	{
		ShowTopDialog(536, 210, Html, "advsearch_Dialog__title_");	
		document.getElementById("advsearch_Dialog__title_").innerHTML=fuwCode["showError"];
		document.getElementById("advsearch_Dialog__dlgiframe_").style.display ="none";
		document.getElementById("topFrame").style.display ='';
		document.getElementById("topFrame").style.height ='235px';
		document.getElementById("topFrame").src="index.php?action=msgError&msg="+ msg +"";
	}
	if(para == 'import')
	{
		ShowTopDialog(259, 210, Html, "advsearch_Dialog__title_");
		document.getElementById("advsearch_Dialog__title_").innerHTML=fuwCode["dr_1"];
		document.getElementById("advsearch_Dialog__dlgiframe_").style.height=220+"px";
		var html = '';
		html+='<form name="addressBookIOform" id="addressBookIOform" action="about:blank" method="post" enctype="multipart/form-data" target="mainFrame">\
			<input value="addr_clone" type="hidden" name="t">\
			<input value=import type="hidden" name="fun">\
		<div class="Search_box" style="padding-top:0px;">\
			<div style="height:38px;">'+fuwCode["dr_2"]+'</div>\
			<div class="div_FbM_l" style="padding-top:0px;">'+fuwCode["dr_3"]+'</div>\
			<div class="div_FbM_r" style="padding-top:0px;">\
				<input name="addressIO" id="addressIO" type="file" style="height:32px;"/>\
			</div>\
			<input type="hidden" value="CSV" id="fileType" name="fileType">\
			<div class="div_FbM_l" style="padding-top:0px;">'+fuwCode["dr_6"]+'</div>\
			<div class="div_FbM_r" style="padding-top:0px;">\
				<ol>\
					<dd id="check_N" class="zuo" onclick="checkRided(\'N\');"></dd>\
					<dd>'+fuwCode["dr_7"]+'</dd>\
					<dd id="check_Y" class="you" onclick="checkRided(\'Y\');"></dd>\
					<dd>'+fuwCode["dr_8"]+'</dd>\
					<input type="hidden" name="overrided" id="overrided" value="n">\
				</ol>\
			</div>\
		</div>\
		<div style="color:#a69521;padding:0px 20px;">1.格式--姓名,电子邮件,员工编号,部门,小组,职位,地址,手机号码,电话号码,即时通讯,进入企业日期,生日,性别,备注<br/>\
				2.例如--test,test@aaa.com（其他项均可为空）\
		</div>\
		<div class="Float_boxB">\
			<span><input name="" type="button" value='+fuwCode["dr_10"]+' class="inputA" onclick="_importAddressBook(\'personal\')"/></span>\
			<span><input name="" type="button" value='+fuwCode["cancel"]+' class="inputB" onclick="CloseTopDialog();"/></span>\
		</div></form>';
		document.getElementById("advsearch_Dialog__dlgiframe_").innerHTML = html;
	}
	if(para == 'export')
	{
		ShowTopDialog(147, 210, Html, "advsearch_Dialog__title_");
		document.getElementById("advsearch_Dialog__title_").innerHTML=fuwCode["dc_1"];
		document.getElementById("advsearch_Dialog__dlgiframe_").style.height=147+"px";
		var html = '';
		html += '\
		<div class="Search_box">\
			<div>'+fuwCode["dc_2"]+'</div>\
			<div class="div_FbM_b" style="padding-left:0px;">'+fuwCode["dc_3"]+'</div>\
		</div>\
		<div class="Float_boxB">\
			<span><input type="button" value='+fuwCode["dc_4"]+' class="inputA" onclick="_exportAddressBook(\'personal\');"/></span>\
			<span><input type="button" value='+fuwCode["cancel"]+' class="inputB" onclick="CloseTopDialog();"/></span>\
		</div>';
		document.getElementById("advsearch_Dialog__dlgiframe_").innerHTML = html;
	}
	if(para == 'AddWhite')
	{
		getTop().ShowTopDialog(147, 210, Html, "advsearch_Dialog__title_");
		getTop().document.getElementById("advsearch_Dialog__title_").innerHTML="加到白名单";
		getTop().document.getElementById("advsearch_Dialog__dlgiframe_").style.height=110+"px";
		var html = '';
		var whiteName = '';
		html +='<div class="Search_box" style="padding-top:0px;max-height: 210px;overflow-y: auto;"><form action="" method="post">\
			   <div id="whiteNameList" style="margin:20px 0px">';
		if(msg != "1")
		{
			html +='<input type="checkbox" name="whitename" checked="checked" value="'+msg+'" id="'+msg+'" onclick="NameListSelectOne(this);"/><span style="margin-left:5px;">'+msg+'</span></br>';
		}
		else
		{
			var result = multiBlackNames.unique(); //去除重复数据
			for(var i=0; i<result.length; i++)
			{
				result[i] = result[i].replace(/</ig, '&lt');
				result[i] = result[i].replace(/>/ig, '&gt');				
				if(result[i].indexOf('&lt') >= 0)//如果包含“<”
				{
					var str = result[i].split("&lt"); //以"<"分割字符串 
					var m_from = str[1];
					if(m_from.indexOf("&gt") >= 0)
					{
						var str2 = m_from.split("&gt");
						whiteName = str2[0];
					}
				}else{
					whiteName = result[i];
				}
				html +='<input type="checkbox" name="whitename" checked="checked" value="'+whiteName+'" id="'+whiteName+'" onclick="NameListSelectOne(this);"/><span style="margin-left:5px;">'+result[i]+'</span></br>';
			}
		}
		html += '</div></form></div>\
				<div class="Float_boxB" style="margin-top:0px">\
				<span><input name="" type="button" value='+fuwCode["addToWhite"]+' class="inputB" style="margin-left:155px;"onclick="NameListSelect();addWhiteList();CloseTopDialog();"/></span>\
				<span><input name="" type="button" value='+fuwCode["cancel"]+' class="inputA" style="margin-left:0px;" onclick="CloseTopDialog();"/></span></div>';
			if(multiBlackNames) multiBlackNames.clear();
			if(multiNameList) multiNameList.clear();	
		getTop().document.getElementById("advsearch_Dialog__dlgiframe_").innerHTML = html;
	}
}
Array.prototype.unique = function()
{
	this.sort();
	var re=[this[0]];
	for(var i = 1; i < this.length; i++)
	{
		if( this[i] !== re[re.length-1])
		{
			re.push(this[i]);
		}
	}
	return re;
}
function readEditMail(mid)
{
	autoSend(mid,'read');
}

function autoSend(writeId,type)
{
	if(type == "write")//判断是写信页面的话，首先判断一下收件人是否为空
	{
		var objTo = getId(writeId+"to");
		var objCc = getId(writeId+"cc");
		var objBcc = getId(writeId+"bcc");
		if ( objTo.value.trim().length == 0 && objCc.value.trim().length==0 && objBcc.value.trim().length==0 )
		{
			showerr(fuwCode["fuw24"]);
			objTo.focus();
			return;
		}
	}
	getId("dnsDialog2").style.display = "";
	getId("Dialog_title2").innerHTML= "定时发送邮件";
	dragdrop.registerDragdropHandler("dnsDialog__title_2","dnsDialog2");
	getId("writeSendAuto").style.height=220+"px";
	getId("writeSendAuto").innerHTML=getHtml(writeId,type);
	getTime();
	function getHtml(writeId,type)
	{
		var myDate = new Date();     
		var year = myDate.getFullYear();   //获取完整的年份(4位,1970-????)    
		var month = myDate.getMonth()+1;       //获取当前月份(0-11,0代表1月) 
		var day = myDate.getDate();       //获取当前日(1-31)      
		var hour = myDate.getHours();       //获取当前小时数(0-23)    
		var minutes = myDate.getMinutes();     //获取当前分钟数(0-59)    
		var second = myDate.getSeconds();     //获取当前秒数(0-59) 	
		var html='<div>\
			<div style="padding:20px 28px;text-align:left;">\
				<input type="hidden" id="getMonth" value="'+month+'">\
				<div style="_zoom:1;">选择定时发送的时间：</div>\
				<div style="height:50px;margin-top:20px;">\
				<select id="autoYear" class="sel" name="autoYear">';
				for(var y=2023;y<2033;y++)
		        {
					if(y == year)
					{
						html+='<option value='+y+' selected onclick="getTime();">'+y+'</option>';
					}
					else
					{
						html+='<option value='+y+' onclick="getTime();">'+y+'</option>';
					}
				}
				html+='</select>年&nbsp;&nbsp;\
				<select id="autoMonth" class="sel" name="autoMonth">';
				for(var m=0;m<month_arr.length;m++)
				{
					if(month_arr[m] == month)
					{
						html+='<option value="'+month_arr[m]+'" selected onclick="getMonth(\''+month_arr[m]+'\');getTime();">'+month_arr[m]+'</option>';
					}
					else
					{
						html+='<option value='+month_arr[m]+' onclick="getMonth(\''+month_arr[m]+'\');getTime();">'+month_arr[m]+'</option>';
					}
				}
				html+='</select>月&nbsp;&nbsp;\
				<span id = "autoDaySpan">\
				<select id="autoDay" class="sel" name="autoDay">';
				var dayLen = "";
				if(month == 1|| month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
				{
					dayLen = day_arr.length;
				}
				else if(month == 2)
				{
					dayLen = day_arr.length-3;
				}
				else
				{
					dayLen = day_arr.length-1;
				}
				for(var d=0;d<dayLen;d++)
				{
					if(day_arr[d] == day)
					{
						html+='<option value='+day_arr[d]+' selected onclick="getTime();">'+day_arr[d]+'</option>';
					}
					else
					{
						html+='<option value='+day_arr[d]+' onclick="getTime();">'+day_arr[d]+'</option>';
					}
				}
				html+='</select></span>';
				html+='日&nbsp;&nbsp;\
				<select id="autoHour" class="sel" name="autoHour">';
				for(var h=0;h<hour_arr.length;h++)
		        {
					if (hour == hour_arr[h])
					{
						
						if(hour != 23)
						{
							html+='<option value='+hour_arr[h]+' onclick="getTime();">'+hour_arr[h]+'</option>\
							<option value='+hour_arr[h+1]+' selected onclick="getTime();">'+hour_arr[h+1]+'</option>';
							h=h+1;	
						}
						else
						{
							html+='<option value='+hour_arr[h]+' onclick="getTime();">'+hour_arr[h]+'</option>';
						}
					}
					else
					{
						html+='<option value='+hour_arr[h]+' onclick="getTime();">'+hour_arr[h]+'</option>';
					}
					
				}
				html+='</select>时&nbsp;&nbsp;\
				<select id="autoMinute" class="sel" name="autoMinute">';
				for(var i=0;i<minutes_arr.length;i++)
				{
					if(minutes_arr[i]<= minutes<= minutes_arr[i+1])
					{
						html+='<option value='+minutes_arr[i+1]+' selected onclick="getTime();">'+minutes_arr[i+1]+'</option>';	
					}
					else
					{
						html+='<option value='+minutes_arr[i]+' onclick="getTime();">'+minutes_arr[i]+'</option>';	
					}
				}
				html+='</select>分&nbsp;&nbsp;\
				</div>';
				html+='本邮件将在 <span class="black bold" id="sTime">uuuuu</span> 投递到对方邮箱。</div>\
				<div class="Float_boxB" style="margin-top:0px">\
				<span><input type="button" value=\'确定\' class="inputB" style="margin-left:155px;" onclick="DSend(\''+writeId+'\',\''+type+'\');"/></span>\
				<span><input type="button" value='+fuwCode["cancel"]+' class="inputA" style="margin-left:0px;" onclick="document.getElementById(\'dnsDialog2\').style.display=\'none\';"/></span></div>\
			</div>';
		   return html;

	}
}
function getMonth(month)
{
	getId("autoDaySpan").innerHTML = getHtml(month);
	function getHtml(month )
	{
		var html="";
		var day = getId("autoDay").value;
		html+='<select id="autoDay" class="sel" name="autoDay">';
				var dayLen = "";
				if(month == 1|| month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
				{
					dayLen = day_arr.length;
				}
				else if(month == 2)
				{
					dayLen = day_arr.length-3;
				}
				else
				{
					dayLen = day_arr.length-1;
				}
				for(var d=0;d<dayLen;d++)
				{
					if(day_arr[d] == day)
					{
						html+='<option value='+day_arr[d]+' selected onclick="getTime();">'+day_arr[d]+'</option>';
					}
					else
					{
						html+='<option value='+day_arr[d]+' onclick="getTime();">'+day_arr[d]+'</option>';
					}
				}
				html+='</select>';
				return html;
	}
}
function getTime()//实时改变时间的innerhtml
{
	var year = getId("autoYear").value;
	var month = getId("autoMonth").value;
	var day = getId("autoDay").value;
	var hour = getId("autoHour").value;
	var second = getId("autoMinute").value;
	var sendTime = year+"-"+month+"-"+day+" "+hour+":"+second;
	getId("sTime").innerHTML = sendTime;
}
function DSend(writeId,type)//确定发送
{
	var year = getId("autoYear").value;
	var month = getId("autoMonth").value;
	var day = getId("autoDay").value;
	var hour = getId("autoHour").value;
	var minute = getId("autoMinute").value;
	var sendTime = year+"-"+month+"-"+day+" "+hour+":"+minute+":00";//设定的发送时间
	var timestamp = (new Date()).valueOf();
	var retTime = compareTime(sendTime);//比较现在的时间和设定的时间的时间差
	if(retTime == 0)
	{
			var strUrl = "/webmail/cgijson/autoSend.php";	
			var strParams = "";
			strParams += "checktime=" + new Date().getTime() + Math.random();
			strParams += "&sendTime="  + sendTime;
			strParams += "&type="  + type;
			strParams += "&sendPid=" + timestamp;
			if(type == "read")
			{
				var oldTime = getId("readAuto").value;
				strParams += "&oldTime=" + oldTime;
			}
			strParams += "&mid="  + writeId;
			var recvActing = new Ajax.Request(strUrl,{
			method:'post',
			parameters:strParams,
			onSuccess:function(transport){
				if( (transport.responseText == "1") || (transport.responseText == "3") )
				{
					return;
				}
				if( transport.responseText == "2"){
					showerr(fuwCode["timeout"]);
					top.location.href = Header_Url;	
					return;
				}	
				var arrRspInfo = eval("(" + transport.responseText + ")");
				if(arrRspInfo == "failed")
				{
					showerr("设置错误，请稍后重新设置");
					return;
				}
				else
				{
					if(type == "write")
					{
						getId(writeId+"asTime").value = sendTime;
						getId(writeId+"sendPid").value = timestamp;
						sendMail(writeId,0);
					}
					else
					{
						showerr("修改定时发送时间成功");
					}
					getId("dnsDialog2").style.display = 'none';
				}

			},
			onFailure:function(){}
			});	
	}
	else
	{
		showerr("设置自动发送时间和当前时间太近");
		return;
	}
}
function compareTime(sendTime)//选择发送的时间
{
	var myDate = new Date();      //当前的系统时间
	var now_year = myDate.getFullYear();   //获取完整的年份(4位,1970-????)    
	var now_month = myDate.getMonth()+1;       //获取当前月份(0-11,0代表1月)    
	var now_day = myDate.getDate();       //获取当前日(1-31)     
	var now_hour = myDate.getHours();       //获取当前小时数(0-23)    
	var now_minutes = myDate.getMinutes();     //获取当前分钟数(0-59) 
	var now_second =  myDate.getSeconds();
	var time1 = now_year+"-"+now_month+"-"+now_day+" "+now_hour+":"+now_minutes+":"+now_second; //系统的当前时间
	var time2 = sendTime;//选择的自动发送的时间
	var result = (Date.parse(time2.replace(/-/g,'/'))-Date.parse(time1.replace(/-/g,'/')))/(1000);//得到是相差的秒数
	var time_diff = result/60;
	if(time_diff > 20)
	{
	  return 0;//表示时间差是20分钟
	}
	else
	{
		return 1;//表示时间差小于20分钟，提示时间间隔太小
	}
	   

}
function NameListSelectOne(objCheckBox)
{
	try{
		if(objCheckBox.checked)
		{
			if(!multiNameList.input(objCheckBox))
			{
				multiNameList.push(objCheckBox);
			}
		}else{
			multiNameList.del(objCheckBox);
			objCheckBox.blur();
		}
	}catch(err){};
}

function NameListSelect(){
	try{
		//clear all of the flag of mails selected
		multiNameList.clear();
		var listCheckBox = document.getElementById("whiteNameList").getElementsByTagName("input");
			//select all
		for(var i=0;i<listCheckBox.length;i++)
		{
			NameListSelectOne(listCheckBox[i]);
		}		
	}catch(err){
	}
}
function dp_show(id)
{
	document.getElementById(id).style.display = document.getElementById(id).style.display == 'none' ? "none" : "block";
}
function dl_show(id,id1)
{
	document.getElementById(id).style.display = document.getElementById(id).style.display == 'block' ? "none" : "block";
	document.getElementById(id1).style.display = "none";
}

function change_value(id,value)
{
	document.getElementById(id).value = value;
	if(id == 'fid')
	{
		document.getElementById(id+'_value').innerHTML = document.getElementById('f_f'+value).innerHTML;
	}else{
		document.getElementById(id+'_value').innerHTML = document.getElementById(value).innerHTML;
	}
	document.getElementById(id).style.display = "none";
}
//禁止input框内回车提交表单
function disableEnter(event){ 
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; 
	if (keyCode == 13){ 
		return false; 
	} 
}
//邮件高级搜索
function CheckSearch()
{
	
	var searchPhrase=document.getElementById("searchPhrase").value;
	if(searchPhrase=="")
	{
		showerr(fuwCode["simpleSreach1"]);
		return;
	}
	CloseTopDialog();
	var range=document.getElementById('range').value;
	if(!range){ range="all"; }
	var floder=document.getElementById('fid').value;
	if(!floder){ floder="allfolder"; }
	var advsearchmail=document.getElementById('advsearchmail').value;
	getTop().operatorSearch(searchPhrase,floder,range,advsearchmail);

}
// 去除首尾空白
function trim(ck)
{
	return(ck&&ck.replace?ck:"").replace(/(^\s*)|(\s*$)/ig,"");
}


// 动态加载Css
function LoadCss(Tag, Num)
{
    var CssTag=document.getElementById(Tag);
    CssTag.href=getPath("skin")+"skin"+Num+".css";
}


// 获取全路径
function getPath(key)
{
	var ret;
	var path={
			image:["images_path","/images/"],
			js:["js_path","/jsV2/"],
			css:["css_path","/cssV2/"],
			skin:["skin_path","/cssV2/setskin/"]
			}[key];
	if(path)
	{
		ret=trim(getTop()[path[0]]||path[1]);
		ret=[location.protocol,"//",location.host,"/webmail",ret].join("");
	}

	return ret||"";
}


// 切换邮件夹的时候高亮所选位置
function switchFolder(id)
{
	try
	{
		var id_old = get("leftPanel").getAttribute("_value");
		if (id_old != "")
		{
			get(id_old).className = "fs";
		}
		get(id+"_num").className = "fn";
		get("leftPanel").setAttribute("_value", id+"_num");
	}
	catch (err){}

}


// window.onresize事件触发FolderList尺寸的改变
function resizeFolderList()
{
	try
	{	
       var folderscroll_height = document.body.clientHeight -336;
	   $("folderscroll").style.height = folderscroll_height+"px";
	}
	catch(err)
	{
	}
}

// get a folder list
function getFolderList()
{
	try
	{
		var strUrl = "/webmail/cgijson/folderlistjson.php";
		var strRsp = "";
		var strParams = "";

		strParams += "checktime=" + new Date().getTime() + Math.random();
		var recvActing = new Ajax.Request(strUrl,{
			method:'get',
			parameters:strParams,
			onSuccess:function(transport){

				if( (transport.responseText == "1") || (transport.responseText == "3") ){
					return;
				}
				if( transport.responseText == "2"){
					showerr(fuwCode["timeout"]);
					location.href = Header_Url;
					return;
				}

				var arrRspInfo = eval("(" + transport.responseText + ")");
				if( !arrRspInfo ) return;

				var i = 0;
				top["jsLoad"].gArrfolder = new Array();
				for(var key in arrRspInfo){
					objFolderTemp = new Object();
					objFolderTemp.id = arrRspInfo[key][0];
					objFolderTemp.unread = arrRspInfo[key][3];
					objFolderTemp.num = arrRspInfo[key][2];
					objFolderTemp.name = arrRspInfo[key][5];
					top["jsLoad"].gArrfolder[i++] = objFolderTemp;
				 };
				 refreshshow("personalfolders",top["jsLoad"].gArrfolder);
			},
			onFailure:function(){
				
			}
		});
	}
	catch(err){}
}

//get a pop list
function getPopList(){
	try{		
		var strUrl = "/webmail/cgijson/poplistjson.php";		
		var strRsp = "";
		var strParams = "";

		strParams += "checktime=" + new Date().getTime() + Math.random();
		var recvActing = new Ajax.Request(strUrl,{
			method:'get',
			parameters:strParams,
			onSuccess:function(transport){
				hide_dialog();
				
				if( (transport.responseText == "1") || (transport.responseText == "3") ){
					return;
				}
				if( transport.responseText == "2"){
					showerr(fuwCode["timeout"]);
					location.href = Header_Url;	
					return;
				}
								
				var arrRspInfo = eval("(" + transport.responseText + ")");
				if( !arrRspInfo ) return;
				var i = 0;
				top["jsLoad"].gArrpop = new Array();
				for(var key in arrRspInfo){						
					objPopTemp = new Object();
					objPopTemp.email = arrRspInfo[key][1];
					objPopTemp.folder = arrRspInfo[key][3];
					objPopTemp.active = arrRspInfo[key][5];
					top["jsLoad"].gArrpop[i++] = objPopTemp;
				};
				refreshshow("popfolders",top["jsLoad"].gArrpop);
			},
			onFailure:function(){}
		});
	} catch(err) {}
}

//新建修改删除自定义文件夹和pop代收更新左侧显示
function refreshshow(id,arrFolderList)
{
	if(id != "popfolders"){
		arrFolderList.sort(function(x, y){
			return x['name'].localeCompare(y['name']);
		}); 
	}
	html = '';
	for(var i=0;i<arrFolderList.length;i++)
	{
		if( id == "personalfolders")
		{
			if( (arrFolderList[i].id == "new") || (arrFolderList[i].id == "cur") || (arrFolderList[i].id == ".&XfJSIJZkkK5O9g-") || (arrFolderList[i].id == ".&XfJT0ZABkK5O9g-") || (arrFolderList[i].id == ".&V4NXPpCuTvY-") || (arrFolderList[i].id == ".&g0l6Pw-") )
				continue;
			html+='<li class="fs" style="padding-left:30px;width:100px;overflow:hidden; white-space:nowrap; text-overflow:ellipsis;" id="'+arrFolderList[i].id+'_num"><a href="javascript:void(0);" target="mainFrame" id="'+arrFolderList[i].id+'" name="personal" onClick="switchFolder(this.id);operatorFolderlist(this.id);" title="'+arrFolderList[i].name+'" onFocus="this.blur()">'+arrFolderList[i].name+'<b id="'+arrFolderList[i].id+'_mmm">'+(arrFolderList[i].unread>0?"&nbsp;("+arrFolderList[i].unread+")&nbsp;":"")+'</b></a></li>';
		}
		else
		{
			html+='<li class="fs" style="padding-left:30px;" id="'+arrFolderList[i].email+'"><a href="javascript:void(0);" target="mainFrame" id="" name="personal" onClick="switchFolder(this.id);popMailList(\''+arrFolderList[i].email+'\',\'' +  arrFolderList[i].folder + '\',' + arrFolderList[i].active + ')" title="'+arrFolderList[i].email+'" onFocus="this.blur()" class="fdlist_width"><div>'+arrFolderList[i].email.left(9) +'</div></a></li>';

		}
	}
	getTop().getId(id).innerHTML = html;
}

// 点击邮件夹的“+”和“-”
function showFolders(id)
{
	var obj = $(id+"folders");
	if ($("icon_"+id).className == "fd_on")
	{
		// 打开列表
		obj.style.display = "";
		$("icon_"+id).className = "fd_off";
	}
	else if($("icon_"+id).className == "fd_off")
	{
		// 关闭列表
		obj.style.display = "none";
		$("icon_"+id).className = "fd_on";
	}
	refreshFolders(id+"folders");
}


function refreshFolders(id)
{
	// 区分个人邮件夹和归档邮件夹
	var arrFolderList = null;
	var JS=top["jsLoad"];
	if( id == "personalfolders")
	{
		arrFolderList = JS.gArrfolder;
	}
	if( id == "popfolders")
	{
		arrFolderList = JS.gArrpop;
	}
	//getId(id).innerHTML = "";
	var html = "";
	if(id == "archivefolders")
	{
		var strUrl = "/webmail/cgijson/archivefolderlistjson.php";
		var strRsp = "";
		var strParams = "";

		strParams += "checktime=" + new Date().getTime() + Math.random();
		var recvActing = new Ajax.Request(strUrl,{
			method:'get',
			parameters:strParams,
			onSuccess:function(transport){

				if( (transport.responseText == "1") || (transport.responseText == "3") ){
					return;
				}
				if( transport.responseText == "2"){
					showerr(fuwCode["timeout"]);
					location.href = Header_Url;
					return;
				}

				var arrRspInfo = eval("(" + transport.responseText + ")");
				if( !arrRspInfo ) return;
				var aArchiveBox = arrRspInfo.rs;
				for(var j=0;j<aArchiveBox.length;j++)
				{
					html+='<li class="fs" style="padding-left:30px;" id="'+aArchiveBox[j].id+'_num"><a href="javascript:void(0)" target="mainFrame" id="'+aArchiveBox[j].id+'" name="personal" onClick="switchFolder(this.id);operatorFolderlist(this.id);" title="'+aArchiveBox[j].name+'" onFocus="this.blur()" class="fdlist_width"><div>'+aArchiveBox[j].name+'<span id="'+aArchiveBox[j].id+'_mmm">'+(aArchiveBox[j].unread>0?"&nbsp;("+aArchiveBox[j].unread+")&nbsp;":"")+'</span></div></a></li>';
				}
				getId(id).innerHTML = html;
			},
			onFailure:function()
			{
			}
		});
	}
	else
	{
		refreshshow(id,arrFolderList);
	}
}

// 显示页面上部的提示信息
function showTopMessage()
{
	getTop().document.getElementById("showmessages").style.display='';
}

// 隐藏页面上部的提示信息
function hideTopMessage()
{
	getTop().document.getElementById("showmessages").style.display='none';
}

function showerr(message)
{
	showTopMessage();
	getTop().document.getElementById("showmessages").style.display='';
	getTop().document.getElementById("showmessages").innerHTML=message;
	getTop().setTimeout("hideTopMessage();",1500);
}

function show_dialog()
{
	getTop().document.getElementById("showdialog").style.display='';
}

function hide_dialog()
{
	getTop().document.getElementById("showdialog").style.display='none';
}

function getMailNext_moveMail(fromfid,tofid,mid,type)
{
 	try{
		var Obj = document.getElementById('mail_message_read').getElementsByTagName("table")[1].rows[0];
		var bValue = Obj.getElementsByTagName("span")[1].getElementsByTagName("b")[0].innerHTML;
		
		if(fromfid == tofid)
		{
			showerr(fuwCode["status_no_change"]);			
			return;
		}
		else
		{
			if( mid == "" || fromfid == "" ){
				return;
			}
			if(fromfid == ".&V4NXPpCuTvY-" && tofid == "new")
			{
				var whiteName = '';
				if(bValue.indexOf('&lt;') >= 0)
				{
					var str = bValue.split("&lt;"); //以"<"分割字符串 
					var m_from = str[1];
					if(m_from.indexOf("&gt") >= 0)
					{
						var str2 = m_from.split("&gt");
						whiteName = str2[0];
					}
				}else{
					whiteName = bValue;
				}
				getMailNext(fromfid,mid,'next');
				window.setTimeout("Is_addWhite('"+whiteName+"','"+fromfid+"','"+mid+"')",10);
				return;
			}

			show_dialog();
			var strUrl = "/webmail/cgijson/mailnext.php";
			var strRsp = "";
			var strParams = "";
			strParams += "checktime=" + new Date().getTime() + Math.random();
			strParams += "&fid="  + encodeURIComponent(fromfid);
			strParams += "&mid="  + encodeURIComponent(mid);
			strParams += "&optype="  + encodeURIComponent(type);
			var recvActing = new Ajax.Request(strUrl, {
				method:'get',
				parameters:strParams,
				onSuccess:function(transport){
					hide_dialog();

					if( (transport.responseText == "1") || (transport.responseText == "3") ){
						return;
					}

					if( transport.responseText == "2"){
						showerr(fuwCode["timeout"])
						top.location.href = Header_Url;
						return;
					}
					var arrRspInfo = eval("(" + transport.responseText + ")");
					if( arrRspInfo && arrRspInfo.minfo ){
						mailInfoInitComplete(arrRspInfo, mid, fromfid);
						folderListInit(arrRspInfo["folderList"]);
						//renew mail list
						changeMailReadFaceComplete(arrRspInfo,fromfid);
					}
					mailMenuInitComplete(arrRspInfo, mid, fromfid);
					moveMail(fromfid,tofid,mid);
					
				},
				onFailure:function(){ hide_dialog();}
			});
		}
	} catch(err) {hide_dialog();}
}


//让弹出来的div可以移动
var dragdrop={
 registerDragdropHandler:function(handler,target,cursor){ // 注册鼠标移动的一些事件。
  var _IsMousedown=false,_ClickLeft=0,_ClickTop=0;
  var _hDom=this.get(handler);
  var _tDom=this.get(target);
  _hDom.style.cursor=cursor||"move";

        function startDrag(evt){ // 按下鼠标左键时的事件。
   evt=window.event||evt;  // 获取当前事件对象。
   _IsMousedown=true;  // 记录已经准备开始移动了。
   _ClickLeft=evt.clientX-parseInt(_tDom.style.left); // 记录当前坐标轴。
   _ClickTop=evt.clientY-parseInt(_tDom.style.top);
  }
        function doDrag(evt){ // 鼠标开始移动时的事件。
   evt=window.event||evt; // 获取当前事件对象。
   if(!_IsMousedown)return false; // 如果_IsMousedown不等于真了返回。
   _tDom.style.left=evt.clientX-_ClickLeft+"px"; // 把鼠标当前移动的位置赋值给div
   _tDom.style.top=evt.clientY-_ClickTop+"px"; // 当前位置减去开始位置就是层当前存放的位置。
  }
        function endDrag(){ // 释放鼠标左键时的事件。
   if(_IsMousedown){ // 如果_IsMousedown还为真那么就赋值为假。
    if(this.isIE) _tDom.releaseCapture(); //该函数从当前的窗口释放鼠标捕获，并恢复通常的鼠标输入处理。
    _IsMousedown=false;
   }
  }
        _hDom.onmousedown=startDrag; // 鼠标按下事件。
  document.onmouseup=endDrag;  // 鼠标释放事件。
  document.onmousemove=doDrag; // 鼠标移动事件。
  _tDom.onselectstart=_tDom.oncontextmenu=function(){return false;}; // 禁止选择和右键菜单。
 },
 isIE:(navigator.appName=="Microsoft Internet Explorer"), // 判断是否为IE。
 get:function(element){ // 通过一串字符返回一个对象。
  if(typeof(element) == "string"){
   return document.getElementById(element);
  }
  return element;
 }
};
function group_addr(writeId)
{
	if(getId(writeId+"group_addr").className=="imgB0")
		{
			getId(writeId+"group_addr").className="imgB1";
			getId(writeId+"personGroup").style.display="none";
		}
		else
		{
			getId(writeId+"group_addr").className="imgB0"
			getId(writeId+"personGroup").style.display="";
		}
}

function business_addr()
{
	if(getId("qy_addr").className=="imgB0")
	{
		getId("qy_addr").className="imgB1";
		getId("qyaddress").style.display="none";
	}
	else
	{
		getId("qy_addr").className="imgB0"
		getId("qyaddress").style.display="";
		showAddress(this.parentNode);
	}
}


//判断密码强度
function showPwRank(pwRank)
{
	var obj = $("passwordRank");
	switch(pwRank)
        {
            case 0:
                //obj.style.display="none";
                break;
            case 1:
                obj.className = "passwordRank passwordRankLow";
                break;
            case 2:
                obj.className = "passwordRank passwordRankMiddle";
                break;
            case 3:
                obj.className = "passwordRank passwordRankHigh";
                break;
        }
	obj.style.display = (pwRank?'':"none");
}
function f_CalcPwdRank(l_Content) 
{
    var ls = 0; 
    if (l_Content.match(/[a-z]/g)){ ls++; }
    if(l_Content.match(/[A-Z]/g)){ ls++; }
    if (l_Content.match(/[0-9]/g)){ ls++; }
    if (l_Content.match(/[^a-zA-Z0-9]/g)){ ls++; }
    if (l_Content.length < 8 && ls > 1){   
        ls = 1;
    } 
	
	if(l_Content.length >= 8 && l_Content.length <= 16 && ls > 1)
    {
		var username = document.getElementById("pwd_userid").value;
		var user_domain = document.getElementById("user_domain").value;
		if(l_Content.length >= 8)
	    {
			if(l_Content.indexOf(username) != "-1" && ls > 1)//如果输入的密码中含有用户名
			{
				ls = 1;
			}
			if(l_Content.indexOf(user_domain) != "-1" && ls > 1)
			{
				ls = 1;
			}
			if(l_Content.indexOf("1234") != "-1" && ls > 1)
			{
				ls = 1;
			}
			var n = l_Content.search(/[A-Z]/)
			if ( n  < 0){ ls = 1; }
			var n = l_Content.search(/[A-Z]/)
            		if ( n  < 0){ ls = 1; }	
		}
    }
    
    if(ls > 3) 
    {
        ls = 3;
    }
    return ls;
}

function f_checkrank(obj,l_Content) //符合强度后返回true
{
	if(l_Content.length<1){showPwRank(0);return 0;}
    var ls=f_CalcPwdRank(l_Content);
		switch(ls) 
		{ 
			case 0:    //不显示
			case 1:    //弱
			case 2:    //中
			case 3:    //强 
				showPwRank(ls);
				break;
			default:
				showPwRank(3);
		}
	
		return ls;
}
function f_checkranklogin(obj,l_Content)
{
 //if(l_Content.length<6||/^[0-9]{1,8}$/.test(l_Content)) {showPwRank(0);return 0;}
	if(l_Content.length<1){showPwRank(0);return 0;}
    var ls=f_CalcPwdRank(l_Content);
	if(ls=="1"||ls=="0")
	{
		document.getElementById("lsValue").value="1";
	}
	else
	{
		/*switch(ls) 
		{ 
			case 0:  
			case 1:  
			case 2:    
			case 3:   
				showPwRank(ls);
				break;
			default:
				showPwRank(3);
		}
	
		return ls;*/
	}
}
function f_Init(iRet) 
{
   var g_ipt_pass =document.getElementById("newpasswd");//新密码
   var g_ipt_repass = document.getElementById("repasswd");
   //g_ipt_pass.onpaste=function(){return false;};
   g_ipt_pass.onfocus=function(){if(this.value.length!=0){if(g_ipt_pass.value.length==16){document.getElementById('fontdiv').style.display='';document.getElementById("passwordRank").style.display='none';}else{document.getElementById('fontdiv').style.display='none';f_checkrank(this,this.value)};};};//当对象获得焦点时触发
   g_ipt_pass.onblur =function(){if(this.value.length==0){return;};showPwRank(0);}; //在对象失去输入焦点时触发
   g_ipt_pass.onkeydown=function(){if(g_ipt_repass.value.length!=0&&g_ipt_pass.value.length==0){g_ipt_repass.value="";};};
   g_ipt_pass.onkeyup=function(){if(g_ipt_pass.value.length==16){document.getElementById('fontdiv').style.display='';document.getElementById("passwordRank").style.display='none';}else{document.getElementById('fontdiv').style.display='none';f_checkrank(this,this.value)};};
}



function operatorWriteMail(writeTypeName,w_mid,w_fid,attachBody)
{
	var writeId = 'mail' + getTop().writeMailFlag;
	var w_mid = encodeURIComponent(w_mid);
	getTop().writeMailFlag++;
	createNavWriteMail(writeId, writeTypeName);
	var _content_writeMail = window.document.createElement("div");
	_content_writeMail.id='_content_writeMail_'+writeId;
	_content_writeMail.style.height="100%";
	if(writeTypeName=='contentMail')
	{
		attachBody = encodeURIComponent(attachBody);
		_content_writeMail.innerHTML='<iframe src="index.php?action=writeMail&writeId='+writeId+'&addrcontion='+attachBody+'" frameborder="no"overflow="hidden" height="100%" frameborder="0" width="100%"  marginheight="0" marginwidth="0"/>';
	}
	else
	{
		_content_writeMail.innerHTML='<iframe id="mainFrame" src="index.php?action=writeMail&writeId='+writeId+'&mid='+w_mid+'&fid='+w_fid+'&writeTypeName='+writeTypeName+'&attachBody='+attachBody+'" frameborder="no" height="100%"overflow="hidden" frameborder="0" width="100%"  marginheight="0" marginwidth="0"/>';
	}
	getTop().getId("_content").appendChild(_content_writeMail);
	var temp_nav_content = getTop().getId('_content_writeMail_'+writeId);
	var temp_nav_label = getTop().getId('_nav_writeMail_'+writeId);
	if(temp_nav_content)
	{
		if(temp_nav_content == getTop().current_nav_content)
		return;
		getTop().current_nav_content.style.display='none';
		temp_nav_content.style.display='block';
		_nav_table_bg(temp_nav_label);
		getTop().current_nav_content=temp_nav_content;
		setCurrentNavNum();
		setCurrentNavShow();
	}
	else
	{
		getTop().current_nav_content.style.display='none';
		current_nav_label_bg_hide();	
	}
}
function operatorFolderlist(para)
{
	getTop().getId("inbox_clear").value = "0";
	getTop().getId("getUnread").value = "a_r";
	createNavReadMail(para);
	if(getTop().getId('_content_mailBox'))
	{
		getTop().getId('_content_mailBox').innerHTML='<iframe src="index.php?action=inbox&fkw='+encodeURIComponent(para)+'" frameborder="no" style="width:100%;height:100%;"/>';
	}
	else
	{
		var _content_mailBox=Window.document.createElement("div");
		_content_mailBox.id="_content_mailBox";
		_content_mailBox.style.height="100%";
		_content_mailBox.innerHTML='<iframe id="iFrame1" src="index.php?action=inbox&fkw='+encodeURIComponent(para)+'" frameborder="no" style="width:100%;height:100%" marginheight="0" marginwidth="0"/>';
		getTop().getId("_content").appendChild(_content_mailBox);	
		setCurrentNavNum();
		setCurrentNavShow();	
	}
	var temp_nav_content = getTop().getId('_content_mailBox');
	var temp_nav_label = getTop().getId('_nav_mailBox');
	if(temp_nav_content)
	{
		getTop().getId('_nav_mailBox').setAttribute('_value', para);
		if(temp_nav_content == getTop().current_nav_content)
		return;
		getTop().current_nav_content.style.display='none';
		temp_nav_content.style.display='block';
		_nav_table_bg(temp_nav_label);
		getTop().current_nav_content=temp_nav_content;
	}
	else
	{
		getTop().current_nav_content.style.display='none';
	}

}
function operatorSettings(kinds,para)//设置区
{
	//remove_content_nav('mailBox',null);
	//_nav_settingBox(para);//创建设置区上面的标签
	if(getTop().getId('_content_settingBox'))
	{ 
		if(kinds=='common')
		{
			getTop().getId('_content_settingBox').innerHTML='<iframe src="index.php?action=setCommon" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		}
		else if(kinds=='skin')
		{
			getTop().getId('_content_settingBox').innerHTML='<iframe src="index.php?action=setSkin" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		}
		else if(kinds=='myfolder')
		{
			getTop().getId('_content_settingBox').innerHTML='<iframe src="index.php?action=folderlist" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		}
		else if(kinds=='archivefolder')
		{
			getTop().getId('_content_settingBox').innerHTML='<iframe src="index.php?action=archivefolderlist" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		}
		else if(kinds=='popfolder')
		{
			getTop().getId('_content_settingBox').innerHTML='<iframe src="index.php?action=setpop" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		}
		else if(kinds=='setmsm')
		{
			getTop().getId('_content_settingBox').innerHTML='<iframe src="index.php?action=setmsm" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		}  
	}
	else
	{
		_nav_settingBox(para);//创建设置区上面的标签
		var _content_settingBox = Window.document.createElement("div");
		_content_settingBox.id="_content_settingBox";
		_content_settingBox.style.height="100%";
		if(kinds=='common')
		{
			_content_settingBox.innerHTML='<iframe src="index.php?action=setCommon" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		}
		else if(kinds=='setmsm')
		{
			_content_settingBox.innerHTML='<iframe src="index.php?action=setmsm" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		}
		else if(kinds=='skin')
		{
			_content_settingBox.innerHTML='<iframe src="index.php?action=setSkin" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		}
		else if(kinds=='myfolder')
		{
			_content_settingBox.innerHTML='<iframe src="index.php?action=folderlist" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		}
		else if(kinds=='archivefolder')
		{
			_content_settingBox.innerHTML='<iframe src="index.php?action=archivefolderlist" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		}
		else if(kinds=='popfolder')
		{
			_content_settingBox.innerHTML='<iframe src="index.php?action=setpop" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		}
		else if(kinds=='bindphone')
		{
			_content_settingBox.innerHTML='<iframe src="index.php?action=bindPhone" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		}
		else
		{

		}
		getTop().getId("_content").appendChild(_content_settingBox);
		setCurrentNavNum();//最多可以同时开6个页面
		setCurrentNavShow();//点击图片显示上一个页面和下一个页面
	}
	var temp_nav_content = getTop().getId('_content_settingBox');
	var temp_nav_label = getTop().getId('_nav_settingBox');

	if(temp_nav_content)
	{
		if(temp_nav_content == getTop().current_nav_content)
		return;
		getTop().current_nav_content.style.display='none';
		temp_nav_content.style.display='block';
		_nav_table_bg(temp_nav_label);
		getTop().current_nav_content=temp_nav_content;
	}
	else
	{
		getTop().current_nav_content.style.display='none';
	}
}

function operatorReadmail(fid,checkboxId)//读邮件
{
	//createNavReadMailLarge();

	if(getTop().getId('_content_readMail'))
	{ 
		getTop().getId('_content_readMail').innerHTML='<iframe src="index.php?action=readmail&fid='+encodeURIComponent(fid)+'&inputid='+encodeURIComponent(checkboxId)+'" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
	}
	else
	{
		createNavReadMailLarge();
		var _content_readMail=Window.document.createElement("div");
		_content_readMail.id="_content_readMail";
		_content_readMail.style.height="100%";
		_content_readMail.innerHTML='<iframe src="index.php?action=readmail&fid='+encodeURIComponent(fid)+'&inputid='+encodeURIComponent(checkboxId)+'" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		getTop().getId("_content").appendChild(_content_readMail);
		setCurrentNavNum();//最多可以同时开6个页面
		setCurrentNavShow();//点击图片显示上一个页面和下一个页面
		
	}
	var temp_nav_content = getTop().getId('_content_readMail');
	var temp_nav_label = getTop().getId('_nav_readMail');
	if(temp_nav_content)
	{
		if(temp_nav_content == getTop().current_nav_content)
			return;
		getTop().current_nav_content.style.display='none';
		temp_nav_content.style.display='block';
		_nav_table_bg(temp_nav_label);
		getTop().current_nav_content=temp_nav_content;
	}
	else
	{
		getTop().current_nav_content.style.display='none';
		current_nav_label_bg_hide();
	}
}
function operatorContact()//联系人
{
	
	if(getTop().getId('_content_contact'))
	{
		
		getTop().getId('_content_contact').innerHTML='<iframe src="index.php?action=contact" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
	}
	else
	{
		_nav_contact();
		var _content_contact=docCreate("div");
		_content_contact.id='_content_contact';
		_content_contact.style.height="100%";
		_content_contact.innerHTML='<iframe src="index.php?action=contact" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		getTop().getId('_content').appendChild(_content_contact);
		setCurrentNavNum();//最多可以同时开6个页面
		setCurrentNavShow();//点击图片显示上一个页面和下一个页面
	}	
		var temp_nav_content = getTop().getId('_content_contact');
		var temp_nav_label = getTop().getId('_nav_contact');
		if(temp_nav_content)
		{
			if(temp_nav_content == current_nav_content)
			return;
			getTop().current_nav_content.style.display='none';
			temp_nav_content.style.display='block';
			_nav_table_bg(temp_nav_label);
			getTop().current_nav_content=temp_nav_content;
		}
		else
		{
			getTop().current_nav_content.style.display='none';
		}			
	
	
}

function operatorIndex()//首页
{
	createNavindex();
	if(getTop().getId('_content_index'))
	{
		getTop().getId('_content_index').innerHTML='<iframe src="index.php?action=frame_indexV2" name="mainFrame" id="mainFrame" frameborder="no" style="height:100%;_height:100%;VISIBILITY: inherit; WIDTH: 100%; Z-INDEX: 1;margin: 0px; padding:0px; "/>';
	}
	else
	{
		var _content_index=docCreate('div');
		_content_index.id='_content_index';
		_content_index.style.height="100%";
		_content_index.innerHTML='<iframe src="index.php?action=frame_indexV2" name="mainFrame" id="mainFrame" frameborder="no" style="height:100%; VISIBILITY: inherit; WIDTH: 100%; Z-INDEX: 1;margin: 0px; padding:0px;"/>';
		getTop().getId('_content').appendChild(_content_index);
		getTop().current_nav_content=_content_index;
	}
}
function operatorSearch(searchPhrase,floder,range,advsearchmail)//搜索
{	
	//createNavAdvSearch();
	if(getTop().getId('_content_advSearch'))
	{
		if(!range)
		{
			getTop().getId('_content_advSearch').innerHTML='<iframe src="index.php?action=find_mail&_simpleSreach_text='+searchPhrase+'&fid='+floder+'" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		}
		else
		{
			getTop().getId('_content_advSearch').innerHTML='<iframe src="index.php?action=find_mail&searchPhrase='+searchPhrase+'&range='+range+'&fid='+floder+'&advsearchmail='+advsearchmail+'" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		}
	}
	else
	{
		createNavAdvSearch();
		var _content_advSearch=Window.document.createElement("div");
		_content_advSearch.id='_content_advSearch';
		_content_advSearch.style.height="100%";
		if(!range)
		{
			_content_advSearch.innerHTML='<iframe src="index.php?action=find_mail&_simpleSreach_text='+searchPhrase+'&fid='+floder+'" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		}
		else
		{
			_content_advSearch.innerHTML='<iframe src="index.php?action=find_mail&searchPhrase='+searchPhrase+'&range='+range+'&fid='+floder+'&advsearchmail='+advsearchmail+'" name="mainFrame" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		}
		getTop().getId('_content').appendChild(_content_advSearch);		
		setCurrentNavNum();//最多可以同时开6个页面
		setCurrentNavShow();//点击图片显示上一个页面和下一个页面
	}
	var temp_nav_content =getTop().getId('_content_advSearch');
	var temp_nav_label=getTop().getId('_nav_advSearch');

	if(temp_nav_content)
	{
		if(temp_nav_content == getTop().current_nav_content)
		return true;				
		getTop().current_nav_content.style.display='none';			
		temp_nav_content.style.display='block';
		_nav_table_bg(temp_nav_label);
		getTop().current_nav_content=temp_nav_content;
	}
	else
	{
		current_nav_content.style.display='none';	
	}
	//CloseTopDialog();
}



function operatorSelect()//自助查询
{
	//remove_content_nav('mailBox',null);
	if(getTop().getId('_content_select'))
	{
		
		getTop().getId('_content_select').innerHTML='<iframe src="index.php?action=loginSelect" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
	}
	else
	{
		createNavSelect();
		var _content_select=docCreate("div");
		_content_select.id='_content_select';
		_content_select.style.height="100%";
		_content_select.innerHTML='<iframe src="index.php?action=loginSelect" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		getTop().getId('_content').appendChild(_content_select);
		setCurrentNavNum();//最多可以同时开6个页面
		setCurrentNavShow();//点击图片显示上一个页面和下一个页面
	}	
		var temp_nav_content = getTop().getId('_content_select');
		var temp_nav_label = getTop().getId('_nav_select');
		if(temp_nav_content)
		{
			if(temp_nav_content == current_nav_content)
			return;
			getTop().current_nav_content.style.display='none';
			temp_nav_content.style.display='block';
			_nav_table_bg(temp_nav_label);
			getTop().current_nav_content=temp_nav_content;
		}
		else
		{
			getTop().current_nav_content.style.display='none';
		}			
	
}
function operatorAttach()
{
	
	if(getTop().getId('_content_attachBox'))
	{
		getTop().getId('_content_attachBox').innerHTML = '<iframe src="index.php?action=attachment" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';	
	}
	else
	{	
		_nav_attachBox();
		var _attachBox = Window.document.createElement("div");
		_attachBox.id="_content_attachBox";
		_attachBox.style.height="100%";
		_attachBox.innerHTML = '<iframe src="index.php?action=attachment" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		getTop().getId("_content").appendChild(_attachBox);
		setCurrentNavNum();//最多可以同时开6个页面
		setCurrentNavShow();//点击图片显示上一个页面和下一个页面
	}
	

	var temp_nav_content =getTop().getId('_content_attachBox');
	var temp_nav_label=getTop().getId('_nav_attachBox');

	if(temp_nav_content)
	{
		if(temp_nav_content == getTop().current_nav_content)
		return true;				
		getTop().current_nav_content.style.display='none';			
		temp_nav_content.style.display='block';
		_nav_table_bg(temp_nav_label);
		getTop().current_nav_content=temp_nav_content;
	}
	else
	{
		current_nav_content.style.display='none';	
	}
}

function operatorKuaipan()
{
	
	if(getTop().getId('_content_kuaipanBox'))
	{
		getTop().getId('_content_kuaipanBox').innerHTML = '<iframe src="index.php?action=kuaipan" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
	}
	else
	{	
		_nav_kuaipanBox();
		var _kuaipanBox = Window.document.createElement("div");
		_kuaipanBox.id="_content_kuaipanBox";
		_kuaipanBox.style.height="100%";
		_kuaipanBox.innerHTML = '<iframe src="index.php?action=kuaipan" id="mainFrame" frameborder="no" style="width:100%;height:100%;"/>';
		getTop().getId("_content").appendChild(_kuaipanBox);
		setCurrentNavNum();//最多可以同时开6个页面
		setCurrentNavShow();//点击图片显示上一个页面和下一个页面
	}
	

	var temp_nav_content =getTop().getId('_content_kuaipanBox');
	var temp_nav_label=getTop().getId('_nav_kuaipanBox');

	if(temp_nav_content)
	{
		if(temp_nav_content == getTop().current_nav_content)
		return true;				
		getTop().current_nav_content.style.display='none';			
		temp_nav_content.style.display='block';
		_nav_table_bg(temp_nav_label);
		getTop().current_nav_content=temp_nav_content;
	}
	else
	{
		current_nav_content.style.display='none';	
	}
}
//add gesq

function onloadInbox(type)
{
	var height = getTop().document.getElementById("_content_"+type).offsetHeight-     
			document.getElementById('inbox_nums').offsetHeight-document.getElementById('inbox_tags').offsetHeight-
			document.getElementById('inbox_title').offsetHeight;
			document.getElementById("inbox_list").style.height = height+'px';
}
function resizeInbox()
{
	var height = getTop().document.getElementById("_content_mailBox").offsetHeight-
			document.getElementById('inbox_nums').offsetHeight-document.getElementById('inbox_tags').offsetHeight-
			document.getElementById('inbox_title').offsetHeight;
			document.getElementById("inbox_list").style.height = height+'px';
}
function resizeSearch()
{
	var height = getTop().document.getElementById("_content_advSearch").offsetHeight-
			document.getElementById('inbox_nums').offsetHeight-document.getElementById('inbox_tags').offsetHeight-
			document.getElementById('inbox_title').offsetHeight-15;
			document.getElementById("inbox_list").style.height = height+'px';
}
function changeStyle(kinds)
{
	var divStyle = document.getElementById("div_"+kinds).style.display;
	
	if(divStyle == 'none')
	{
		document.getElementById("div_"+kinds).style.display = 'block';
		if(kinds == "folder")
		{
			var folderHeight = document.getElementById("div_folder").offsetHeight;
			if(document.getElementById("inbox_list") != null)
			{
				var inboxListHeight = document.getElementById("inbox_list").style.height;
			}
			else
			{
				var inboxListHeight = document.getElementById("readmailBody").style.height;
			}
			var strs= new Array();
			strs=inboxListHeight.split("p");
			if(folderHeight > strs[0])
			{
				document.getElementById("div_folder").style.height = strs[0]+"px";
			//	document.getElementById("div_folder").style.height = 200+"px";
			}
		}
	}
	else
	{
		document.getElementById("div_"+kinds).style.display = 'none';
	}
}
function hiddenDiv(style)
{
	if(style == 'isRead')
	{
		document.getElementById("div_folder").style.display = "none";
	}
	else if(style == "isFolder")
	{
		document.getElementById("div_isReaded").style.display = "none";
	}
	else
	{
		document.getElementById("div_isReaded").style.display = "none";
		document.getElementById("div_folder").style.display = "none";
	}
}
function sendAgain(fid,mid)
{
	var nCount = 0;
	if(mid == null)
	{
		mid = "";
		//for mail list
		for(var i=0; i<multiMails.length; i++)
		{
			mid = multiMails[i].id;
			nCount++;
		}
	}
	else
	{
		//for one mail
		nCount = 1;
	}
	if( mid == "" )
	{
		showerr(fuwCode["no_mail_select"]);
		return;
	}
	if( nCount > 1)
	{
		showerr(fuwCode["only_one_select"]);
		return;
	}
		getTop().operatorWriteMail('editMail',mid,fid);
}
function draftEditMail(fid,mid)
{
	var nCount = 0;
	if(mid == null)
	{
		mid = "";
		//for mail list
		for(var i=0; i<multiMails.length; i++)
		{
			mid = multiMails[i].id;
			nCount++;
		}
	}
	else
	{
		//for one mail
		nCount = 1;
	}
	if( mid == "" )
	{
		showerr(fuwCode["no_mail_select"]);
		return;
	}
	if( nCount > 1)
	{
		showerr(fuwCode["only_one_select"]);
		return;
	}
		getTop().operatorWriteMail('editMail',mid,fid);
}
function reply(fid,mid,abll)//回复和全部回复邮件
{
	var nCount = 0;
		if(mid == null){
			mid = "";
			//for mail list
			for(var i=0; i<multiMails.length; i++){
				mid = multiMails[i].id;
				nCount++;
			}
		}else{
			//for one mail
			nCount = 1;
		}
		if( mid == "" ){
			showerr(fuwCode["no_mail_select"]);
			return;
		}
		if( nCount > 1){
				showerr(fuwCode["only_one_select"]);
			return;
		}
	if(abll==false)
	{

		getTop().operatorWriteMail('replyMail',mid,fid);
	}
	else
	{
		getTop().operatorWriteMail('replyMailall',mid,fid);
	}
}
function repay(fid,mid,abll)//邮件转发
{
	var nCount = 0;
		if(mid == null){
			mid = "";
			//for mail list
			for(var i=0; i<multiMails.length; i++){
				mid = multiMails[i].id;
				nCount++;
			}
		}else{
			//for one mail
			nCount = 1;
		}
		if( mid == "" ){
			showerr(fuwCode["no_mail_select"]);
			return;
		}
		if( nCount > 1){
				showerr(fuwCode["only_one_select"]);
			return;
		}
		getTop().operatorWriteMail('relay',mid,fid);

}
//框架页mail.html中用到的方法
function onloadMail()
{		
	document.getElementById("_content").style.height = document.body.clientHeight-95;
}

function systemFolderInit()
{
	var JS=top["jsLoad"];
	var newcount = 0;
	var Draftcount = 0;
	var Outboxcount = 0;
	var tmpcount = 0;
	var tmptotal = 0;
	var myjunkcount = 0;
	var myjunktotal = 0;
	var gArrfolder=JS.gArrfolder;
	for(var i=0;i<gArrfolder.length;i++)
	{
		if(gArrfolder[i].id == "new")
		{
			newcount=gArrfolder[i].unread;
			getId("urn_inbox").innerHTML=(newcount==0)?"":"&nbsp;&nbsp;[" + newcount + "]";
			getId("unReadMail_m").value = gArrfolder[i].unread;
		}
		else if( gArrfolder[i].id == ".&g0l6Pw-")
		{
			Draftcount=gArrfolder[i].unread;
			getId("urn_draft").innerHTML=(Draftcount==0)?"":"&nbsp;&nbsp;[" + Draftcount + "]";
		}
		else if( gArrfolder[i].id == ".&XfJT0ZABkK5O9g-")
		{
			Outboxcount=gArrfolder[i].unread;
			getId("urn_sent").innerHTML=(Outboxcount==0)?"":"&nbsp;&nbsp;[" + Outboxcount + "]";
		}
		else if( gArrfolder[i].id == ".&XfJSIJZkkK5O9g-")
		{
			tmpcount=gArrfolder[i].unread;
			getId("urn_trash").innerHTML=(tmpcount==0)?"":"&nbsp;&nbsp;[" + tmpcount + "]";
			tmptotal = gArrfolder[i].num;
			getId("clearAllMail_trash").innerHTML=(tmptotal==0)?"":'['+fuwCode["clear"]+']';
		}
		else if( gArrfolder[i].id == ".&V4NXPpCuTvY-")
		{
			myjunkcount=gArrfolder[i].unread;
			getId("urn_junk").innerHTML=(myjunkcount==0)?"":"&nbsp;&nbsp;[" + myjunkcount + "]";
			myjunktotal = gArrfolder[i].num;
			getId("clearAllMail_junk").innerHTML=(myjunktotal==0)?"":'['+fuwCode["clear"]+']';
		}
	}
}
function butOnClick(evt)//回车触发邮件搜索
{
	var myEvent = evt ? evt: (window.event ? window.event : null)
	if (myEvent.keyCode == 13)
	{
		var button = document.getElementById("_simpSr_text"); //_simpSr_text 为botton按钮的id
		button.click();
		return false;
	}
}
//读信页面
function onloadRead()
{
	var height= getTop().document.getElementById("_content_readMail").offsetHeight -80;
	document.getElementById("readmailBody").style.height = height+"px";
}

//设置页面
function onloadSet()
{
	var height = getTop().document.getElementById("_content_settingBox").scrollHeight-
			document.getElementById('div_top').scrollHeight-38;
			document.getElementById("postop1").style.height = height+"px";
}

//快盘页面
function onloadKuaipan()
{
	var height = getTop().document.getElementById("_content_kuaipanBox").scrollHeight-190;
		document.getElementById("showAllFiles").style.height = height+"px";
}
function m_over(e,type)//模拟 momouseleave 
{
	 if( !e ) e = window.event;  
     var reltg = e.relatedTarget ? e.relatedTarget : e.fromElement;  
     while( reltg && reltg != this ) reltg = reltg.parentNode;  
     if( reltg != this ){  
        // 这里可以编写 onmouseenter 事件的处理代码 
		document.getElementById(type).style.display = "";
     }  

}
function m_out(e,type)
{ 
     if( !e ) e = window.event;  
     var reltg = e.relatedTarget ? e.relatedTarget : e.toElement; 
     while( reltg && reltg != this ) reltg = reltg.parentNode;  
   
     if( reltg != this ){  
        // 这里可以编写 onmouseleave 事件的处理代码   
		document.getElementById(type).style.display = "none";
		
     }  
}

function getUnreadMail(fid)//获取未读邮件数的列表
{
	getTop().getId("getUnread").value = "u_r";
	initMailList(fid);
}
