<?
session_start();
$selelag = $HTTP_SESSION_VARS["SelLanguage"];
if (empty($selelag)) header("location:../break.php");
require("../config/".$selelag);
require("../_ConnectString.php");       //--連接參數設定值
require("../_function.php");
//require("../top/top.php");
require("../_image.php");
require("../_search/_mail_search.php");
require("../_search/_datamining.php");
require("../_read_source/_webmail.php");
require("../_read_source/_attachment.php");
require_once("../cd_pos.php");

$_SearchPath = "../_search/mail_search_list.php";
$_DELETE_DIGITAL_PATH = "../remove/";
$Host_ip = $HTTP_SERVER_VARS["HTTP_HOST"];

if ((isset($HTTP_SESSION_VARS["LoginID_Sess"])) && (isset($HTTP_SESSION_VARS["OperateRole_Sess"])) && (isset($HTTP_SESSION_VARS["GroupNo_Sess"]))){

	$QUERY_IP					= $HTTP_POST_VARS["QUERY_IP"];     //--HOST IP
	$QUERY_IP_1					= $HTTP_POST_VARS["QUERY_IP_1"];
	//--SENDER search screen
	$QUERY_START_DATETIME		= $HTTP_POST_VARS["QUERY_START_DATETIME"];  
	$QUERY_END_DATETIME			= $HTTP_POST_VARS["QUERY_END_DATETIME"];
	$QUERY_SUBJECT				= $HTTP_POST_VARS["QUERY_SUBJECT"];  
	$QUERY_FROM					= $HTTP_POST_VARS["QUERY_FROM"];  
	$QUERY_TO					= $HTTP_POST_VARS["QUERY_TO"];  
	$QUERY_CC					= $HTTP_POST_VARS["QUERY_CC"];
	$QUERY_BCC					= $HTTP_POST_VARS["QUERY_BCC"];
	$QUERY_HOST					= $HTTP_POST_VARS["QUERY_HOST"];
	$QUERY_ID					= $HTTP_POST_VARS["QUERY_ID"];     //--資料庫流水號
	$QUERY_ACCOUNT				= $HTTP_POST_VARS["QUERY_ACCOUNT"];     //--資料庫流水號

	$sizepage					= $HTTP_POST_VARS["sizepage"];       //--每頁筆數
	$RunAs						= $HTTP_POST_VARS["RunAs"];			//--刪除 或 忽略
	$Checked					= $HTTP_POST_VARS["Checked"];
	$SortField					= $HTTP_POST_VARS["SortField"];      //--排序欄位
	$SortType					= $HTTP_POST_VARS["SortType"];       //--排序方式
	$strWhere					= $HTTP_POST_VARS["strWhere"];		//--search all
	$WEBMAILS					= $HTTP_POST_VARS['WEBMAILS'];		//--全文檢索 -auto 值
	$mime						= $HTTP_POST_VARS['mime'];			//--全文檢索 flag
	$digital					= $HTTP_POST_VARS['digital'];	    //--數位資產 flag


	if(strlen($HTTP_SERVER_VARS["QUERY_STRING"])>0){
		$to_page			= $HTTP_GET_VARS["to_page"];     //--HOST IP
	}else{
		$to_page			= $HTTP_POST_VARS["to_page"];    //--HOST IP
	}

	//相關變數初始化 
	if (!isset($to_page) || empty($to_page)){
		$to_page = 1;
	}//End : if (相關變數初始化)

	if (!isset($sizepage) || empty($sizepage)){
		$sizepage = $HTTP_SESSION_VARS["size_page"];
	}

	$ErrorMsg = "";
	$_Disabled = "";
	//$bgcolorCol = "bgcolor=\"#A0C6E5\"";

	//--畫面設定排序時使用
	if ($SortField == "") $SortField = $DB_WEBMAIL_AUTO;
	include($_SORT_PATH);

	//判斷每頁秀的資料筆數
	if ($RunAs == 'UpdatePageSize'){
		if ($sizepage){ 
			$HTTP_SESSION_VARS["size_page"] = $sizepage;
		}//End : if()
	}//End : if(判斷每頁秀的資料筆數)


	//--刪除資料
	if($RunAs == "Delete"){
		$_FILE = "WEBMAILS_".date("Y-m-d")."_".date("H:i:s");
		$TMP_FILE = "/tmp/".$_FILE;
		if ((fn_digital_asset()==1)||(fn_data_mining()==1)) $fp = fopen($TMP_FILE,"w+");
		$flag = 0;
		for($i=0; $i<count($chkbox); $i++){
			//Delete the mail(send)
			$strSQL = "Select * From ".$DB_WEBMAIL." where ".$DB_WEBMAIL_AUTO."='".$chkbox[$i]."'";
			$intSQL = mysql_query($strSQL);
			$rowSQL = mysql_fetch_array($intSQL);
			$DelFilePath = $DATAS_PATH_WEBMAILS.$rowSQL[$DB_WEBMAIL_DBTAG]."/".$rowSQL[$DB_WEBMAIL_FILE_BODY];

			if (file_exists($DelFilePath)){
				system("echo rm -f $DelFilePath >> /tmp/dc.cmd");
			}

			$strDEL = "Delete From ".$DB_WEBMAIL." where ".$DB_WEBMAIL_AUTO."='".$chkbox[$i]."'";
			$intDEL = mysql_query($strDEL);
			if ((fn_digital_asset()==1)||(fn_data_mining()==1)) fputs($fp,"WEBMAIL.".$chkbox[$i]."\n");
			if (!$intDEL) $flag = 1;

			//Delete the attachment 
			$strDEL = "Select * From ".$DB_ATTACHMENT." where ".$DB_ATTACHMENT_NEWIDX."='".$chkbox[$i]."' and ".$DB_ATTACHMENT_TYPE."='3'";
			$intSQL = mysql_query($strDEL);
			while($rowSQL = mysql_fetch_array($intSQL)){							 $DelAttPath=$DATAS_PATH_WEBMAILS.$rowSQL[$DB_ATTACHMENT_DBTAG]."/".$rowSQL[$DB_ATTACHMENT_DB_NAME];
					if (file_exists($DelAttPath)){
						system("echo rm -f $DelAttPath >> /tmp/dc.cmd");
					}
			}

			$strDEL = "Delete From ".$DB_ATTACHMENT." where ".$DB_ATTACHMENT_NEWIDX."='".$chkbox[$i]."' and ".$DB_ATTACHMENT_TYPE."='3'";
			$intDEL = mysql_query($strDEL);
			//if ((fn_digital_asset()==1)||(fn_data_mining()==1)) fputs($fp,"ATTACHMENT.".$chkbox[$i]."\n");
			if (!$intDEL) $flag = 1;
		}
		if ((fn_digital_asset()==1)||(fn_data_mining()==1)) fclose($fp);

		if ($flag){
			$ErrorMsg = $WEBMAILSM_DELFAIL;
			if ((fn_digital_asset()==1)||(fn_data_mining()==1)) unlink($TMP_FILE);
		}
		else{
			mysql_query("OPTIMIZE TABLE WEBMAIL");
			mysql_query("OPTIMIZE TABLE ATTACHMENT");
			$ErrorMsg = $WEBMAILSM_DELSUCCESS;
			if ((fn_digital_asset()==1)||(fn_data_mining()==1)){
				copy($TMP_FILE,$_DELETE_DIGITAL_PATH.$_FILE);
				unlink($TMP_FILE);
			}
		}
	}
    
	
	//-- System super user(PROGRAM ENTRY PLACE)
	$strSQL = "Select count(*) From ".$DB_WEBMAIL;
	if ($mime == 1)
	{
		$strSQL = $strSQL." Where ".$DB_WEBMAIL_AUTO." in (".$WEBMAILS.")";
	}
	else{
		if(fn_NotShowIP()!="''")$strSQL = $strSQL." Where ".$DB_WEBMAIL_IP." not in (".fn_NotShowIP().")";
		else $strSQL = $strSQL." Where 1=1 ";

		if ($HTTP_SESSION_VARS['GroupNo_Sess']!=0){
			$strSQL = $strSQL." and ".$DB_WEBMAIL_IP." in (".fn_IPcontrol($HTTP_SESSION_VARS['GroupNo_Sess']).")";
		}//End : if()
		if($strWhere["WEBMAILS"] != "") $strSQL = $strSQL.stripcslashes($strWhere["WEBMAILS"]);
	}
	$condition= fn_SearchMail($QUERY_START_DATETIME,$QUERY_END_DATETIME,urldecode($QUERY_FROM),urldecode($QUERY_TO),urldecode($QUERY_CC),urldecode($QUERY_BCC),$QUERY_SUBJECT,$QUERY_HOST,$QUERY_IP,$QUERY_IP_1,$QUERY_ID,$QUERY_ACCOUNT,'webmails');
	$strSQL = $strSQL.$condition;
	//print $strSQL."<br>";
	//計算符合文章總數 & 初始化分頁變數
    include($_PAGE_PATH);
   
	//為了畫面排序的sql語法
	$strSQL = "Select ".$DB_WEBMAIL_AUTO.",".$DB_WEBMAIL_SENDER.",".$DB_WEBMAIL_TO.",".$DB_WEBMAIL_CC.",".$DB_WEBMAIL_BCC.",".$DB_WEBMAIL_SUBJECT.",".$DB_WEBMAIL_UTF_SUBJECT.",".$DB_WEBMAIL_HOST.",".$DB_WEBMAIL_DBTAG.",".$DB_WEBMAIL_FILE_BODY.",".$DB_WEBMAIL_ATTACH_NUM.",".$DB_WEBMAIL_DATETIME.",".$DB_WEBMAIL_IP.",".$DB_WEBMAIL_ACCOUNT;
	$strSQL = $strSQL."	From ".$DB_WEBMAIL;
	if ($mime == 1)
	{
		$strSQL = $strSQL.fn_Datamining($WEBMAILS,$DB_WEBMAIL_AUTO,$m,$n,$to_page);
		$m = 0;
	}
	else{
		if(fn_NotShowIP()!="''")$strSQL = $strSQL." Where ".$DB_WEBMAIL_IP." not in (".fn_NotShowIP().")";
		else $strSQL = $strSQL." Where 1=1 ";
		if ($HTTP_SESSION_VARS['GroupNo_Sess']!=0){
			$strSQL = $strSQL." and ".$DB_WEBMAIL_IP." in (".fn_IPcontrol($HTTP_SESSION_VARS['GroupNo_Sess']).")";
		}//End : if()
		if($strWhere["WEBMAILS"] != "") $strSQL = $strSQL.stripcslashes($strWhere["WEBMAILS"]);
	}

	$strSQL = $strSQL.$condition;
	$strSQL = $strSQL." Order by ".$SortField." ".$SortType." limit ".$m.", ".$n;
	//print $strSQL;
	$intResult = mysql_query($strSQL);
	
	//<--組show畫面字串
	if (mysql_num_rows($intResult) == 0){
		$WebmailsList = "<tr height=\"30\" class=\"NoData\"><td colspan=\"";
		if (($HTTP_SESSION_VARS["OperateRole_Sess"]=="Super")&&($HTTP_SESSION_VARS["GroupNo_Sess"]=='0')){
			if(fn_ad()) $WebmailsList = $WebmailsList."11"; else $WebmailsList = $WebmailsList."10";
		}else{
			if(fn_ad()) $WebmailsList = $WebmailsList."10"; else $WebmailsList = $WebmailsList."9";
		}
		include("../no_data.php");
		$WebmailsList = $WebmailsList."\"".$NoDataList;
		$_Disabled = "disabled";
	}
	else{
		$WebmailsList = "";
		$chkCount = ($to_page-1)*$sizepage+1; 
		while ($row=mysql_fetch_array($intResult)){
			$_SUBJECT  =   $row[$DB_WEBMAIL_SUBJECT];
			if (ereg("\n$",$_SUBJECT)){
				if (strlen($_SUBJECT)>3){
					$CUT_SUBJECT = $_SUBJECT = substr($_SUBJECT,0,strlen($_SUBJECT)-2);
				}
				elseif (strlen($_SUBJECT==2)){
					$CUT_SUBJECT = $WEBMAILS_NONE;
					$_SUBJECT = $WEBMAILS_NONE;
				}//End : if()
			}//End : if()

			if ((trim($_SUBJECT)=='(null)')||(trim($_SUBJECT)=='')||(empty($_SUBJECT))){
				$CUT_SUBJECT = $WEBMAILS_NONE;
			}
			elseif (strlen($_SUBJECT)>70){    
				$CUT_SUBJECT=substr($_SUBJECT,0,70)."..."; 
			}
			else {
				$CUT_SUBJECT = $_SUBJECT;

			}//End : if()

			$_UTF_SUBJECT  =   $row[$DB_WEBMAIL_UTF_SUBJECT];
			if (ereg("\n$",$_UTF_SUBJECT)){
				if (strlen($_UTF_SUBJECT)>3){
					$CUT_UTF_SUBJECT = $_UTF_SUBJECT = substr($_UTF_SUBJECT,0,strlen($_UTF_SUBJECT)-2);
				}
				elseif (strlen($_UTF_SUBJECT==2)){
					$CUT_UTF_SUBJECT = $WEBMAILS_NONE;
					$_UTF_SUBJECT = $WEBMAILS_NONE;
				}
			}

			if ((trim($_UTF_SUBJECT)=='(null)')||(trim($_UTF_SUBJECT)=='')||(empty($_UTF_SUBJECT))){
				$CUT_UTF_SUBJECT = $WEBMAILS_NONE;
			}
			elseif (strlen($_UTF_SUBJECT)>20){    
				$CUT_UTF_SUBJECT=substr($_UTF_SUBJECT,0,20)."..."; 
			}
			else {
				$CUT_UTF_SUBJECT = $_UTF_SUBJECT;
			}


			$_SENDER  =   convert($row[$DB_WEBMAIL_SENDER]);
			if (ereg("\n$",$_SENDER)){
				if (strlen($_SENDER)>3){
					$CUT_SENDER = $_SENDER = substr($_SENDER,0,strlen($_SENDER)-2);
				}
				elseif (strlen($_SENDER)==2){
					$CUT_SENDER = "&nbsp;";
					$_SENDER ="&nbsp;";
				}//End : if()
			}//End : if()

			if ((trim($_SENDER)=='(null)')||(trim($_SENDER)=='')||(empty($_SENDER))){
				$CUT_SENDER = "&nbsp;";
			}
			elseif (strlen($_SENDER)>17){    
				$CUT_SENDER=substr($_SENDER,0,17)."..."; 
			}
			else {
				$CUT_SENDER = $_SENDER;
			}//End : if()
			$_TO      =   convert($row[$DB_WEBMAIL_TO]);
			if (ereg("\n$",$_TO)){
				if (strlen($_TO)>3){
					$CUT_TO = $_TO = substr($_TO,0,strlen($_TO)-2);
				}
				elseif (strlen($_TO)==2){
					$CUT_TO = "&nbsp;";
					$_TO ="&nbsp;";
				}//End : if()
			}//End : if()

			if ((trim($_TO)=='(null)')||(trim($_TO)=='')||(empty($_TO))){
				$CUT_TO = "&nbsp;";
			}
			elseif (strlen($_TO)>17){    
				$CUT_TO=substr($_TO,0,17)."..."; 
			}
			else {
				$CUT_TO = $_TO;
			}//End : if()

			$_CC      =   convert($row[$DB_WEBMAIL_CC]);
			if (ereg("\n$",$_CC)){
				if (strlen($_CC)>3){
					$CUT_CC = $_CC = substr($_CC,0,strlen($_CC)-2);
				}
				elseif (strlen($_CC)==2){
					$CUT_CC = "&nbsp;";
					$_CC ="&nbsp;";
				}//End : if()
			}//End : if()

			//如果_CC無值，塞none
			if ((trim($_CC)=='(null)')||(trim($_CC)=='')||(empty($_CC))){
				$CUT_CC = "&nbsp;";
			}
			elseif (strlen($_CC)>8){    
				$CUT_CC=substr($_CC,0,10)."..."; 
			}
			else {
				$CUT_CC = $_CC;
			}//End : if(如果_CC無值，塞none)

			$_BCC      =   convert($row[$DB_WEBMAIL_BCC]);
			if (ereg("\n$",$_BCC)){
				if (strlen($_BCC)>3){
					$CUT_BCC = $_BCC = substr($_BCC,0,strlen($_BCC)-2);
				}
				elseif (strlen($_BCC)==2){
					$CUT_BCC = "&nbsp;";
					$_BCC ="&nbsp;";
				}//End : if()
			}//End : if()

			//如果_BCC無值，塞none
			if ((trim($_BCC)=='(null)')||(trim($_BCC)=='')||(empty($_BCC))){
				$CUT_BCC = "&nbsp;";
			}
			elseif (strlen($_BCC)>8){    
				$CUT_BCC=substr($_BCC,0,10)."..."; 
			}
			else {
				$CUT_BCC = $_BCC;
			}//End : if(如果_BCC無值，塞none)

			$_HOST				= $row[$DB_WEBMAIL_HOST]; 
			$_DBTAG				= $row[$DB_WEBMAIL_DBTAG]; 
			$_BODY_NAME			= $row[$DB_WEBMAIL_BODY_NAME]; 
			
			if ($chkCount%2 == 1){
				$WebmailsList = $WebmailsList."<tr  class=\"Tr_Do\" onmouseover=\"this.className='Tr_Do_Out'\" onmouseout=\"this.className='Tr_Do_Over'\">";
			}else{
				$WebmailsList = $WebmailsList."<tr class=\"Tr_De\" onmouseover=\"this.className='Tr_De_Out'\" onmouseout=\"this.className='Tr_De_Over'\">";
			}

			$WebmailsList = $WebmailsList."<td align=\"center\" title=\"".$row[_AUTO]."\">".$chkCount.".</td>\n";

			//--attachement
			$WebmailsList = $WebmailsList."<td align=\"center\">\n";
			if($row[$DB_WEBMAIL_ATTACH_NUM] == 0){
				$WebmailsList = $WebmailsList."&nbsp;</td>\n";
			}
			else {
				$WebmailsList = $WebmailsList."<img  src=\"../".$DIR_IMAGE.$WEBMAILSP_ATTACH."\"></td>\n";
			}//End : if(attachement)

			//--datetime 
			$WebmailsList = $WebmailsList."<td align=\"center\"><a href=\"#\" onClick=\"ChangeCondition('_DATETIME','".$row[$DB_WEBMAIL_DATETIME]."')\">".fn_DateTime($row[$DB_WEBMAIL_DATETIME])."</a></td>\n";

			//--SENDER
			$Q_SENDER=rawurlencode($row[$DB_WEBMAIL_SENDER]);
			$WebmailsList = $WebmailsList."<td>";
			$WebmailsList = $WebmailsList."<p title=\"".$_SENDER."\"><img src=\"../".$DIR_IMAGE.$WEBMAILSP_IP."\" alt=\"".$row[$DB_WEBMAIL_IP]."\"><br>";
			$WebmailsList = $WebmailsList."<a href=\"#\" onClick=\"ChangeCondition('_FROM','".$Q_SENDER."')\">".$CUT_SENDER."</a></p></td>\n";

			//--TO
			$WebmailsList = $WebmailsList."<span title=\"".$_TO."\"><td >\n";
			$Q_TO=rawurlencode($row[$DB_WEBMAIL_TO]);
			$WebmailsList = $WebmailsList."<a href=\"#\" onClick=\"ChangeCondition('_TO','".$Q_TO."')\">".$CUT_TO."</a></span></td>\n";

			$Q_CC=rawurlencode($row[$DB_WEBMAIL_CC]);
			$WebmailsList = $WebmailsList."<td align=\"center\"><p title=\"".$_CC."\"><a href=\"#\" onClick=\"ChangeCondition('_CC','".$Q_CC."')\">".$CUT_CC."</a></p></td>\n";

			$Q_BCC=rawurlencode($row[$DB_WEBMAIL_BCC]);
			$WebmailsList = $WebmailsList."<td align=\"center\"><p title=\"".$_BCC."\"><a href=\"#\" onClick=\"ChangeCondition('_BCC','".$Q_BCC."')\">".$CUT_BCC."</a></p></td>\n";
			//--轉換 DBTAG 的格式
			$_DBTAG ='';
			$_DBTAG =str_replace("-","_",$row[$DB_WEBMAIL_DBTAG]);
			$_DBTAG =str_replace(":","_",$_DBTAG);

			//--檢查subject是否有檔，有檔才有連結

			if (file_exists($CD_DIR.":\\".$_DBTAG."\\".$row[$DB_WEBMAIL_FILE_BODY])){

				$WebmailsList = $WebmailsList."<td nowrap >\n";

				//Subject
				$WebmailsList = $WebmailsList."<span title=\"".$_UTF_SUBJECT."\" ><a href=\"#\" onClick=\"MM_openBrWindow('openweb.php?_TYPE=3&_AUTO=".$row[$DB_WEBMAIL_AUTO]."','OpenWeb','left=200,top=80,scrollbars=no,resizable=yes,width=660,height=550')\" class=\"A_U\">".$CUT_UTF_SUBJECT."</a></span></td>\n";
			}
			else{
				$WebmailsList = $WebmailsList."<td>\n";
				$WebmailsList = $WebmailsList."<p title=\"".$_UTF_SUBJECT."\">".$CUT_UTF_SUBJECT."</p></td>\n";		
			}//End : if(檢查subject是否有檔，有檔才有連結)

			if (fn_ad()){
				$WebmailsList = $WebmailsList."<td align=\"center\"><a href=\"#\" onClick=\"ChangeCondition('_ACCOUNT','".$row[$DB_WEBMAIL_ACCOUNT]."')\">".$row[$DB_WEBMAIL_ACCOUNT]."</a></td>\n";
            }

			$WebmailsList = $WebmailsList."<td align=\"center\"><a href=\"#\" onClick=\"ChangeCondition('_HOST','".$row[$DB_WEBMAIL_HOST]."')\">".$row[$DB_WEBMAIL_HOST]."</a></td>\n";
			$chkCount++;
		}//End : while(組show畫面字串)
	}
}
else{
	include("../no_privilege.php");
}
?>
<html><head><title></title>
<link href="../Display/display.css" type="text/css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<SCRIPT language=JavaScript src="../inc/fun.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
function get_nva(auto){
	 var objnav=window.navigator;
	 var nav=objnav.browserLanguage;
	 var value   = new Array("GB18030","GB2312","HZ","BIG5","ISO-8859-1");
	 var display =new Array("zh-ch","zh-sg","zh-hk","zh-tw","en");
	 for (var i=0;i< value.length;i++){
		 if(display[i]==nav){
			 var nav_post=value[i];
		 }
	 }	 fn_OpenWin('convert_subject.php?TYPE=WEBMAILS&_CHARSET='+nav_post+'&_AUTO='+auto,'','width=550,height=200,left=225,top=200,menubar=no,toolbar=no,location=no,directories=no,scrollbars=yes,status=no,resizable=yes,fullscreen=no');
}

function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

//--Check input pagesize num	
function ChangePageSize(){
	var flag = "";
	switch(CheckNum(document.frm.sizepage)){
		case "1":
			alert("<?echo $NUMBERM_INPUTISNULL;?>");
			flag = "1";
		break;
		case "2":
			alert("<?echo $NUMBERM_INPUTISZERO;?>");
			flag = "1";
		break;
		case "3":
			alert("<?echo $NUMBERM_INPUTBIG100;?>");
			flag = "1";
		break;
		case "4":
			alert("<?echo $NUMBERM_INPUTNOTNUM;?>");
			flag = "1";
		break;
	}
	
	if (flag == 1){
		document.frm.sizepage.focus();
		return;
	}
	document.frm.RunAs.value = "UpdatePageSize";
	document.frm.submit();

}


//--DELETE DATA
function checkDEL(){
<?if ($_Disabled == ""){?>
	if (!MainCheck()){
		alert("<?echo $WEBMAILSM_NOTSELECT;?>");
		return;
	}

	if (confirm("<?echo $WEBMAILSM_CHECKDEL;?>")){
		document.frm.RunAs.value = "Delete";
		document.frm.submit();
	}
<?}?>
}

<?if ($ErrorMsg != ""){?>
	fn_ErrorMsg('<?echo $ErrorMsg?>')
<?}?>

//Expand
function fn_expand(){
	<?if ($_Disabled == ""){?>
		if (!MainCheck()){
			alert("<?echo $WEBMAILRM_NOTSELECT;?>");
			return;
		}
		var str_id = '';
		var flag = 0;
		for(var i=0;i<document.frm.elements['chkbox[]'].length;i++){
			if (document.frm.elements['chkbox[]'][i].checked){
				str_id += document.frm.elements['chkbox[]'][i].value+'/';
				flag = 1;
			}
		}
		if (flag == 1)
			window.open('expand.php?str_id='+str_id,'expand','width=900,height=650,left=50,top=25,menubar=no,toolbar=no,location=no,directories=no,scrollbars=yes,status=no,resizable=yes,fullscreen=no');
	<?}?>
}
</SCRIPT>
</head>
<body onLoad="fix();" onScroll="fix();" onResize="fix();">
<!-- <body>   -->
<!-- search result-->
<form name="frm" action="webmails.php" method="post">
<input type="hidden" name="strWhere[WEBMAILS]" value="<?echo stripcslashes($strWhere["WEBMAILS"]);?>">
<input type="hidden" name="RunAs" value="">
<input type="hidden" name="SortField" value="<? echo $SortField ?>"><!--sort column-->
<input type="hidden" name="SortType" value="<? echo  $SortType ?>"><!--sort type-->
<input type="hidden" name="Checked" value="<? echo $Checked?>"><!--set checkbox checked or no-->
<input type="hidden" name="QUERY_START_DATETIME" value="<?echo $QUERY_START_DATETIME;?>">
<input type="hidden" name="QUERY_END_DATETIME" value="<?echo $QUERY_END_DATETIME;?>">
<input type="hidden" name="QUERY_FROM" value='<?echo ($QUERY_FROM);?>'>
<input type="hidden" name="QUERY_TO" value="<?echo $QUERY_TO;?>">
<input type="hidden" name="QUERY_CC" value="<?echo $QUERY_CC;?>">
<input type="hidden" name="QUERY_BCC" value="<?echo $QUERY_BCC;?>">
<input type="hidden" name="QUERY_HOST" value="<?echo $QUERY_HOST;?>">
<input type="hidden" name="QUERY_IP" value="<?echo $QUERY_IP;?>">
<input type="hidden" name="QUERY_IP_1" value="<?echo $QUERY_IP_1;?>">
<input type="hidden" name="QUERY_ACCOUNT" value="<?echo $QUERY_ACCOUNT;?>">
<input type="hidden" name="to_page" value="<?echo $to_page;?>"><!--current page-->
<input type="hidden" name="mime" value="<?echo $mime;?>">
<input type="hidden" name="WEBMAILS" value="<?echo $WEBMAILS;?>">
<input type="hidden" name="digital" value="<?echo $digital;?>">
<input type="hidden" name="nav_Language" value="">

<span id="bar" style="position:absolute;z-index:2;  width:100%; height:100%" align="center">
<table width="100%" cellSpacing="0" cellPadding="0" border="0" >
  <tr id="Tr_F">
    <td>
	  &nbsp;&nbsp;<a href="webmails.php"  title="<?echo $WEBMAILS_WEBMAILS;?>"><img src="../<?echo $DIR_IMAGE.$WEBMAILSP_WEBMAILS;?>" border="0" align="top"> <?echo $WEBMAILS_WEBMAILS_SHOW;?></a> | 

	  <a href="javascript:fn_OpenWin('<?echo $_SearchPath;?>?Status=webmails&digital=<?echo $digital;?>','NewWin','width=420,height=390,left=320,top=200,menubar=no,toolbar=no,location=no,directories=no,scrollbars=yes,status=no,resizable=yes,fullscreen=no');"  title="<?echo $WEBMAILS_SEARCH;?>"><img src="../<?echo $DIR_IMAGE.$WEBMAILSP_SEARCH;?>" align="top" border="0"> <?echo $WEBMAILS_SEARCH_SHOW;?></a>
	</td>
	<td class="EveryPage"> 
	  <span title="<?echo $WEBMAILS_PAGEVIEW;?>"><?echo $WEBMAILS_PAGEVIEW_SHOW;?> </span><input type="text" size="1" name="sizepage" value="<?echo $sizepage?>"  class="Text_P" > <input type="button" name="bntPageSize" value="<?echo $WEBMAILSB_OK_SHOW;?>" onClick="ChangePageSize();" class="Btn_C" title="<?echo $WEBMAILSB_OK;?>">&nbsp;
	</td>
  </tr>
</table>
<!--  blank TABLE-->
<table width="100%" class="BlankTb">
	<tr  height="24">
		<td ></td>
	</tr>
</table>
<table class="TitleTb">
  <tr id="Tr_T">
    <td width="3%"><span title="<?echo $WEBMAILS_NO;?>"><?echo $WEBMAILS_NO_SHOW;?></span></td>

    <td width="2%"><img src="../<?echo $DIR_IMAGE.$WEBMAILSP_ATTACH;?>" alt="<?echo $WEBMAILSA_ATTACH;?>"></td>
    <td width="8%" <?echo $colDate;?>>
	  <a href="javascript:ChangeSort('_DATETIME','<? echo $sortDate;?>');"  title="<?echo $WEBMAILS_DATETIME?>"><?echo $WEBMAILS_DATETIME_SHOW?><?echo $imgDate;?></a>
	</td>
    <td width="13%" <?echo $colSENDER;?>>
	  <a href="javascript:ChangeSort('_SENDER', '<?echo $sortSENDER;?>');"  title="<?echo $WEBMAILS_SENDER?>"><?echo $WEBMAILS_SENDER_SHOW?><?echo $imgSENDER;?>
	</td>
    <td width="13%" <?echo $colTO;?>>
	  <a href="javascript:ChangeSort('_TO', '<?echo $sortTO;?>');"  title="<?echo $WEBMAILS_TO?>"><?echo $WEBMAILS_TO_SHOW?><?echo $imgTO;?>
	</td>
    <td width="10%" <?echo $colCC;?>>
	  <a href="javascript:ChangeSort('_CC', '<?echo $sortCC;?>');"  title="<?echo $WEBMAILS_CC?>"><?echo $WEBMAILS_CC_SHOW?><?echo $imgCC;?>
	</td>
	<td width="10%" <?echo $colBCC;?>>
	  <a href="javascript:ChangeSort('_BCC', '<?echo $sortBCC;?>');"  title="<?echo $WEBMAILS_BCC?>"><?echo $WEBMAILS_BCC_SHOW?><?echo $imgBCC;?>
	</td>
    <td><span title="<?echo $WEBMAILS_SUBJECT;?>"><?echo $WEBMAILS_SUBJECT_SHOW;?></span></td>
    <? if (fn_ad()){?>
		<td width="7%" <?echo $colAccount;?>>
			<a href="javascript:ChangeSort('_ACCOUNT', '<?echo $sortAccount;?>');"  title="<?echo $WEBMAILS_ACCOUNT;?>"><?echo $WEBMAILS_ACCOUNT_SHOW;?><?echo $imgAccount;?>
		</td>		
    <?}?>
    <td width="8%" align="center" <?echo $colHost;?>>
	  <a href="javascript:ChangeSort('_HOST','<? echo $sortHost;?>');"  title="<?echo $WEBMAILS_WEBSERVER;?>"><? echo $imgHost;?><?echo $WEBMAILS_WEBSERVER_SHOW;?></a>
	</td>
  </tr>
  </table>
</span>

<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr id="Tr_F" ><td></td></tr>
</table>

<table class="DataTb" >
  <tr class="Tr_Do">
    <td width="3%" height="32" ></td>

    <td width="2%"></td>
    <td width="8%"></td>
    <td width="13%"></td>
    <td width="13%"></td>
    <td width="10%"></td>
	<td width="10%"></td>
    <td></td>
    <? if (fn_ad()){?>
		<td width="7%">
		</td>		
    <?}?>
    <td width="8%" align="center"></td>
  </tr>
 <!--show screen-->
  <? echo $WebmailsList;?>
  <tr bgcolor="<?echo $titletrbgcol;?>">
	<td colSpan="
	<?
		if (($HTTP_SESSION_VARS["OperateRole_Sess"]=="Super")&&($HTTP_SESSION_VARS["GroupNo_Sess"]=='0')){
			if(fn_ad()) echo "11"; else echo "10";
		}else{
			if(fn_ad()) echo "10"; else echo "9";
		}
	?>
	" align="center">
	  <table width="100%"  border="0" cellspacing="0" cellpadding="0">
        <tr id="Tr_P"><? include("../list_page.php");?></tr>
      </table>
	</td>
 </tr>
</table>
</form>
</body>	
</html>