<% Option Explicit %>
<!--#include file="../../Inc/Function.asp" -->
<!--#include file="../../Inc/Const.asp" -->
<!--#include file="../../Inc/Cls_DB.asp" -->
<%
Dim DBC,Conn
Set DBC = New DataBaseClass
Set Conn = DBC.OpenConnection()
Set DBC = Nothing
%>
<!--#include file="../../Inc/Session.asp" -->
<!--#include file="../../Inc/CheckPopedom.asp" -->
<%
if Not JudgePopedomTF(Session("Name"),""&Request("ClassID")&"") then Call ReturnError1()
Dim NewsSql,RsNewsObj,RsClassObj,ClassID,ClassCName,NewsType,NewsTypeStr,PicStr,SunNumAsp,RikerTempObj,TempKeyWord,TempKeyWord1
ClassID = Request("ClassID")
if Not JudgePopedomTF(Session("Name"),""&ClassID&"") then Call ReturnError1()
TempKeyWord = Request("Keywords")
If Request.Form("Keywords")<>"" and Cstr(Request.Form("Keywords"))<>Cstr(TempKeyWord) then
	TempKeyWord = Request.Form("Keywords")
	TempKeyWord1 = "and Title like '%"&Request.Form("Keywords")&"%'"
End If
NewsSql = "Select * from News where  DelTF=0 "&TempKeyWord1&"  order by AddDate desc"
Set RsNewsObj = Server.CreateObject("Adodb.RecordSet")
	RsNewsObj.Open NewsSql,Conn,3,3
	SunNumAsp = RsNewsObj.RecordCount
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新闻列表</title>
</head>
<link href="../../CSS/css.css" rel="stylesheet">
<script src="../JS/PublicJS.js" language="JavaScript"></script>
<body topmargin="0" leftmargin="0" ondragstart="return false;" onselectstart="return false;" oncontextmenu="ClickClassOrNews(true);showMenu(MouseRightMenu);return false;">
<table id="MainTable" onclick="ClickClassOrNews(false);" width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="1">
        <tr> 
          <td width="43%" class="ButtonList"><div align="center">新闻标题</div></td>
          <td width="12%" class="ButtonList"><div align="center">审核状态</div></td>
          <td width="22%" class="ButtonList"><div align="center">所属栏目</div></td>
          <td width="23%" class="ButtonList"><div align="center">更新时间</div></td>
        </tr>
<%
if not  RsNewsObj.Bof And not RsNewsObj.Eof  then 
	Dim Page_Size,Page_No,Page_Total,Record_All
	Page_Size=20
	Page_No = Request.Querystring("Page_No")
    if Page_No <= 1 or Page_No = "" then Page_No = 1
	If Request.QueryString("Page_No") = "" then
		Page_No = 1
	end if
	RsNewsObj.PageSize = Page_Size
	page_total=RsNewsObj.PageCount
	if (Cint(Page_No)>Page_Total) then Page_No = Page_Total
	RsNewsObj.AbsolutePage = Page_No
	Record_All = RsNewsObj.RecordCount
	Dim i
  	for i=1 to RsNewsObj.PageSize
    	if RsNewsObj.eof then exit for

	if RsNewsObj("HeadNewsTF")<>"1" and RsNewsObj("PicNewsTF")<>"1" then
	   NewsType = 1
	   NewsTypeStr = "文字新闻"
	   PicStr = "../Images/WordNews.gif"
	elseif RsNewsObj("HeadNewsTF")="1" then
	   NewsType = 2
	   NewsTypeStr = "标题新闻"
	   PicStr = "../Images/TitleNews.gif"
	else
	   NewsType = 3
	   NewsTypeStr = "图片新闻"
	   PicStr = "../Images/PicNews.gif"
	end if
	if RsNewsObj("FileExtName") = "asp" then
	   PicStr = "../Images/asp.gif"
	end If
%>
        <tr> 
          <td height="22"> <table border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td><img src="<% = PicStr %>" width="18" height="18"></td>
                <td><span NewsType="<% = NewsType %>" AuditTF="<%=RsNewsObj("AuditTF")%>" class="TempletItem" NewsID="<% = RsNewsObj("NewsID") %>" align="center"> 
                  <% = GotTopic(RsNewsObj("Title"),40) %>
                  </span> </td>
              </tr>
            </table>
          </td>
          <td height="22"> <div align="center" class="TempletItem"> 
              <% if RsNewsObj("AuditTF")=1 then
				  response.Write("<font color=blue>已审</font>")
			  else
				  response.Write("<font color=red>未审</font>")
			  end if
			  %>
            </div></td>
          <td height="22"> <div align="center" class="TempletItem"> 
              <%
			  Set RikerTempObj = Conn.Execute("Select ClassCName from NewsClass where ClassID='"&RsNewsObj("ClassID")&"'")
			   if RikerTempObj.eof then
				  response.Write("--")
			  else
				  response.Write(RikerTempObj("ClassCName"))
			  end if
			  RikerTempObj.Close
			  Set RikerTempObj = Nothing
			  %>
            </div></td>
          <td height="22"> <div align="center" class="TempletItem"> 
              <% = RsNewsObj("AddDate") %>
            </div></td>
        </tr>
        <%
	RsNewsObj.MoveNext
next
end if
%>
</table>
</td>
  </tr>
  <tr><td height="10" valign="bottom">
     <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ButtonList">
	  <tr height="1">
		  <td width="62%" height="18"><table width="99%" border="0" cellspacing="0" cellpadding="0">
			  <tr><form name="PGNum" method="post" action="">
				<td width="38%" valign="middle">   
				  <div align="right">新闻标题
				    <input name="Keywords" type="text" id="Keywords" size="10" value="">
				  </div></td>  
				<td width="11%" valign="bottom"><div align="center">
				  <input name="imageField" type="image" onclick="KeyWord();" src="../Images/Search.gif" width="57" height="21" border="0">
				</div></td>
				</form>
			  </tr>
		   </table> </td>
		
		<td height="25" valign="middle"> <div align="right">
			<% =  "NO.<b>"& page_no &"</b>,&nbsp;&nbsp;" %>
			<% = "Totel:<b>"& page_total &"</b>,&nbsp;RecordCounts:<b>" & record_all &"</b>&nbsp;&nbsp;&nbsp;"%>
			<%
				if Page_Total=1 then
						response.Write "&nbsp;<img src=../images/First1.gif border=0 alt=首页></img>&nbsp;"
						response.Write "&nbsp;<img src=../images/prePage.gif border=0 alt=上一页></img>&nbsp;"
						response.Write "&nbsp;<img src=../images/nextPage.gif border=0 alt=下一页></img>&nbsp;"
						response.Write "&nbsp;<img src=../images/endPage.gif border=0 alt=尾页></img>&nbsp;"
				else
					if cint(Page_No)<>1 and cint(Page_No)<>Page_Total then
						response.Write "&nbsp;<a href=?page_no=1&Keywords="&TempKeyWord&"><img src=../images/First1.gif border=0 alt=首页></img></a>&nbsp;"
						response.Write "&nbsp;<a href=?page_no="&cstr(cint(Page_No)-1)&"&Keywords="&TempKeyWord&"><img src=../images/prePage.gif border=0 alt=上一页></img></a>&nbsp;"
						response.Write "&nbsp;<a href=?page_no="&cstr(cint(Page_No)+1)&"&Keywords="&TempKeyWord&"><img src=../images/nextPage.gif border=0 alt=下一页></img></a>&nbsp;"
						response.Write "&nbsp;<a href=?page_no="& Page_Total &"&Keywords="&TempKeyWord&"><img src=../images/endPage.gif border=0 alt=尾页></img></a>&nbsp;"
					elseif cint(Page_No)=1 then
						response.Write "&nbsp;<img src=../images/First1.gif border=0 alt=首页></img></a>&nbsp;"
						response.Write "&nbsp;<img src=../images/prePage.gif border=0 alt=上一页></img>&nbsp;"
						response.Write "&nbsp;<a href=?page_no="&cstr(cint(Page_No)+1)&"&Keywords="&TempKeyWord&"><img src=../images/nextPage.gif border=0 alt=下一页></img></a>&nbsp;"
						response.Write "&nbsp;<a href=?page_no="& Page_Total &"&Keywords="&TempKeyWord&"><img src=../images/endpage.gif border=0 alt=尾页></img></a>&nbsp;"
					else
						response.Write "&nbsp;<a href=?page_no=1&Keywords="&TempKeyWord&"><img src=../images/First1.gif border=0 alt=首页></img>&nbsp;"
						response.Write "&nbsp;<a href=?page_no="&cstr(cint(Page_No)-1)&"&Keywords="&TempKeyWord&"><img src=../images/prePage.gif border=0 alt=上一页></img></a>&nbsp;"
						response.Write "&nbsp;<img src=../images/nextPage.gif border=0 alt=下一页></img></a>&nbsp;"
						response.Write "&nbsp;<img src=../images/endpage.gif border=0 alt=尾页></img>&nbsp;"
					end if
				end if
				%>
			<select onChange="ChangePage(this.value);" style="width:50;" name="select">
			  <% for i=1 to Page_Total %>
			  <option <% if cint(Page_No) = i then Response.Write("selected")%> value="<% = i %>"> 
			  <% = i %>
			  </option>
			  <% next %>
			</select>
		</div></td>
	  </tr>
	</table>
	  </td></tr>
</table>
</body>
</html>
<!-- 鼠标右键菜单 -->
<div id=MouseRightMenu onclick="ClickMenu(this);" onmouseover="MouseOverRightMenu();" onmouseout="MouseOverRightMenu();" class="menu"> 
  <div class="MouseRightItem" id="Edit" ExeFunction="EditNews();">修改</div>
  <div class="MouseRightItem" id="Del" ExeFunction="DelNewsClass();">删除</div>
  <hr id="HR1">
  <div class="MouseRightItem" id="ToSpecial" ExeFunction="OpenWindow('Frame.asp?FileName=NewsToSpecial.asp&Titles=添加到新闻专题&NewsID='+NewsID,350,120,window);">加入专题</div>
  <div class="MouseRightItem" id="ToJs" HaveChild="true">加入JS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt;
    <div id="ChildMenu2" class="childmenu"> 
      <div class="MouseRightItem" id="ChildPicJS" ExeFunction="OpenWindow('../FreeJs/JsTip.asp?FileName=NewsToJs.asp&Types=PicJs&Title=添加到图片JS&NewsID='+NewsID,350,135,window);">图片JS</div>
      <div class="MouseRightItem" id="ChildWordJS" ExeFunction="OpenWindow('../FreeJs/JsTip.asp?FileName=NewsToJs.asp&Types=WordJs&Title=添加到文字JS&NewsID='+NewsID,350,115,window);">文字JS</div>
    </div>
  </div>
  <hr id="HR3">
  <div class="MouseRightItem" id="Check" ExeFunction="OpenWindow('Frame.asp?FileName=ReCheckNews.asp&OperateType=Check&Titles=审核新闻&NewsID='+NewsID,220,105,window);">审核</div>
  <div class="MouseRightItem" id="ReCheck" ExeFunction="OpenWindow('Frame.asp?FileName=ReCheckNews.asp&OperateType=UnCheck&Titles=撤消审核&NewsID='+NewsID,220,105,window);">撤消审核</div>
  <hr id="HR5">
  <div class="MouseRightItem" id="Read1" ExeFunction="Read();">预览</div>
  <div class="MouseRightItem" id="Refresh" ExeFunction="window.location.reload();">刷新</div>
</div>
<%
Set RsNewsObj = Nothing
Set RsClassObj = Nothing
Set Conn = Nothing
%>
<script language="javascript">
var ClassID='';
var NewsID='';
var NewsType='';
var AuditTF='';
var TempKeyWords = '<% = TempKeyWord %>';
var BigClassID='<% = ClassID %>';
var ListObjArray=new Array();
Edit.className='MenuItemDisable';
Del.className='MenuItemDisable';
ToJs.className='MenuItemDisable';
ToSpecial.className='MenuItemDisable';
Read1.className='MenuItemDisable';
ReCheck.className='MenuItemDisable';
Check.className='MenuItemDisable';
IntialListObjArray();
function IntialListObjArray()
{
	var CurrObj=null,j=1;
	for (var i=0;i<document.all.length;i++)
	{
		CurrObj=document.all(i);
		if ((CurrObj.NewsID!=null)||(CurrObj.ClassID!=null))
		{
			if (CurrObj.NewsID!=null)
			{
				ListObjArray[ListObjArray.length]=new ListObj(CurrObj,0,j,false);
				j++;
			}
			if (CurrObj.ClassID!=null)
			{
				ListObjArray[ListObjArray.length]=new ListObj(CurrObj,1,j,false);
				j++;
			}
		}
	}
}
function ListObj(Obj,Type,Index,Selected)
{
	this.Obj=Obj;
	this.Index=Index;
	this.Type=Type;
	this.Selected=Selected;
}
function ClickClassOrNews(MouseRight)
{
	var el=event.srcElement;
	var i=0;
	if (!MouseRight)
	{
		if ((event.ctrlKey==true)||(event.shiftKey==true))
		{
			if (event.ctrlKey==true)
			{
				for (i=0;i<ListObjArray.length;i++)
				{
					if (el==ListObjArray[i].Obj)
					{
						if (ListObjArray[i].Selected==false)
						{
							ListObjArray[i].Obj.className='TempletSelectItem';
							ListObjArray[i].Selected=true;
						}
						else
						{
							ListObjArray[i].Obj.className='TempletItem';
							ListObjArray[i].Selected=false;
						}
					}
				}
			}
			if (event.shiftKey==true)
			{
				var MaxIndex=0,ObjInArray=false,EndIndex=0,ElIndex=-1;
				for (i=0;i<ListObjArray.length;i++)
				{
					if (ListObjArray[i].Selected==true)
					{
						if (ListObjArray[i].Index>=MaxIndex) MaxIndex=ListObjArray[i].Index;
					}
					if (el==ListObjArray[i].Obj)
					{
						ObjInArray=true;
						ElIndex=i;
						EndIndex=ListObjArray[i].Index;
					}
				}
				if (MaxIndex!=0)
				{
					for (i=MaxIndex-1;i<EndIndex;i++)
					{
						ListObjArray[i].Obj.className='TempletSelectItem';
						ListObjArray[i].Selected=true;
					}
				}
				else
				{
					if (ElIndex!=-1)
					{
						ListObjArray[ElIndex].Obj.className='TempletSelectItem';
						ListObjArray[ElIndex].Selected=true;
					}
				}
			}
		}
		else
		{
			for (i=0;i<ListObjArray.length;i++)
			{
				if (el==ListObjArray[i].Obj)
				{
					ListObjArray[i].Obj.className='TempletSelectItem';
					ListObjArray[i].Selected=true;
				}
				else
				{
					ListObjArray[i].Obj.className='TempletItem';
					ListObjArray[i].Selected=false;
				}
			}
		}
	}
	else
	{
		var elInSelectArray=false;
		for (i=0;i<ListObjArray.length;i++)
		{
			if (el==ListObjArray[i].Obj)
			{
				if (ListObjArray[i].Selected==true)
				{
					elInSelectArray=true;
				}
			}
		}
		if (!elInSelectArray)
		{
			for (i=0;i<ListObjArray.length;i++)
			{
				if (el==ListObjArray[i].Obj)
				{
					ListObjArray[i].Obj.className='TempletSelectItem';
					ListObjArray[i].Selected=true;
				}
				else
				{
					ListObjArray[i].Obj.className='TempletItem';
					ListObjArray[i].Selected=false;
				}
			}
		}
		GetID();
		var NewsFlag,ClassFlag,SelectIDType=-1;
		ClassFlag=(ClassID!='')?1:0;
		NewsFlag=(NewsID!='')?1:0;
		SelectIDType=(ClassFlag&&NewsFlag)?0:SelectIDType;  //栏目ID和新闻ID都不为空------0
		SelectIDType=(!ClassFlag&&!NewsFlag)?1:SelectIDType;  //栏目ID和新闻ID都为空--------1
		SelectIDType=(ClassFlag&&!NewsFlag)?2:SelectIDType;  //栏目ID不为空，新闻ID为空----2
		SelectIDType=(!ClassFlag&&NewsFlag)?3:SelectIDType;  //栏目ID为空，新闻ID不为空----3
		if (SelectIDType==2) SelectIDType=(ClassID.indexOf(',')==-1)?4:SelectIDType;  //只选择了一个栏目----4 
		if (SelectIDType==3) SelectIDType=(NewsID.indexOf(',')==-1)?5:SelectIDType;  //只选择了一个新闻----5
		//alert(SelectIDType);
		switch (SelectIDType)
		{
			case 0:
				Edit.className='MenuItemDisable';
				Del.className='MenuItemDisable';
				ToJs.className='MenuItemDisable';
				ToSpecial.className='MenuItemDisable';
				Read1.className='MenuItemDisable';
				ReCheck.className='MenuItemDisable';
				Check.className='MenuItemDisable';
				break;
			case 1:
				Edit.className='MenuItemDisable';
				Del.className='MenuItemDisable';
				ToJs.className='MenuItemDisable';
				ToSpecial.className='MenuItemDisable';
				Read1.className='MenuItemDisable';
				ReCheck.className='MenuItemDisable';
				Check.className='MenuItemDisable';
				break;
			case 2:
				Edit.className='MenuItemDisable';
				Del.className='MouseRightItem';
				ToJs.className='MenuItemDisable';
				ToSpecial.className='MenuItemDisable';
				Read1.className='MenuItemDisable';
				ReCheck.className='MenuItemDisable';
				Check.className='MenuItemDisable';
				break;
			case 3:
				Edit.className='MenuItemDisable';
				Del.className='MouseRightItem';
				ToJs.className='MouseRightItem';
				ToSpecial.className='MouseRightItem';
				Read1.className='MenuItemDisable';
				ReCheck.className='MouseRightItem';
				Check.className='MouseRightItem';
				break;
			case 4:
				Edit.className='MouseRightItem';
				Del.className='MouseRightItem';
				ToJs.className='MenuItemDisable';
				ToSpecial.className='MenuItemDisable';
				Read1.className='MenuItemDisable';
				ReCheck.className='MenuItemDisable';
				Check.className='MenuItemDisable';
				break;
			case 5:
				Edit.className='MouseRightItem';
				Del.className='MouseRightItem';
				ToJs.className='MouseRightItem';
				ToSpecial.className='MouseRightItem';
				Read1.className='MouseRightItem';
				if (AuditTF=='1')
				{
				ReCheck.className='MouseRightItem';
				Check.className='MenuItemDisable';
				}
				else 
				{
				ReCheck.className='MenuItemDisable';
				Check.className='MouseRightItem';
				}
				break;
			default:
			
		}
	}
}
function GetID()
{
	NewsID='';
	ClassID='';
	for (i=0;i<ListObjArray.length;i++)
	{
		if (ListObjArray[i].Selected==true)
		{
			if (ListObjArray[i].Type==0)
			{
				if (NewsID=='') NewsID=ListObjArray[i].Obj.NewsID;
				else NewsID=NewsID+','+ListObjArray[i].Obj.NewsID;
				NewsType=ListObjArray[i].Obj.NewsType;
				AuditTF=ListObjArray[i].Obj.AuditTF;
			}
			else
			{
				if (ClassID=='') ClassID=ListObjArray[i].Obj.ClassID;
				else ClassID=ClassID+','+ListObjArray[i].Obj.ClassID;
			}
		}
	}
}
function CutOperation()
{
	parent.MoveTF=true;
	if (ClassID!='')
	{
		parent.MoveOrCopySourceClass=ClassID;
		parent.MoveOrCopySourceNews='';
		parent.OperationType='Class';
	}
	if (NewsID!='')
	{
		parent.MoveOrCopySourceClass='';
		parent.MoveOrCopySourceNews=NewsID;
		parent.OperationType='News';
	}
}

function CopyOperation()
{
	parent.MoveTF=false;
	if (ClassID!='')
	{
		parent.MoveOrCopySourceClass=ClassID;
		parent.MoveOrCopySourceNews='';
		parent.OperationType='Class';
	}
	if (NewsID!='')
	{
		parent.MoveOrCopySourceClass='';
		parent.MoveOrCopySourceNews=NewsID;
		parent.OperationType='News';
	}
}

function PasteOperation()
{
	if (ClassID=='') parent.MoveOrCopyObjectClass=BigClassID;
	else  parent.MoveOrCopyObjectClass=ClassID;
	var MoveOrCopyClassPara='OperationType:'+parent.OperationType+';MoveTF:'+parent.MoveTF+';SourceClass:'+parent.MoveOrCopySourceClass+';SourceNews:'+parent.MoveOrCopySourceNews+';ObjectClass:'+parent.MoveOrCopyObjectClass+';';
	OpenWindow('Frame.asp?FileName=MoveOrCopyNewsClass.asp&Titles=新闻栏目移动复制&MoveOrCopyClassPara='+MoveOrCopyClassPara,260,100,window);
}

function HeadNews()
{
	if (ClassID!='') OpenWindow('Frame.asp?FileName=HeadNewsEdit.asp&ClassID='+ClassID,350,180,window);
	else OpenWindow('Frame.asp?FileName=HeadNewsEdit.asp&ClassID='+BigClassID,350,180,window);
}

function Read()
{
  if (NewsID!='') window.open('Read.asp?NewsID='+NewsID);
  else alert(错误的参数);
 }

function UnCheck()
{
  if (ClassID!='') parent.frames['OpreateWindow'].location='CheckNewsList.asp?ClassID='+ClassID ;
  else parent.frames['OpreateWindow'].location='CheckNewsList.asp?ClassID='+BigClassID;
 }

function CreateWordNews()
{
	OpenWindow('Frame.asp?FileName=NewsAddWords.asp&Titles=新闻添加--文字新闻&ClassID='+BigClassID,620,500,window);
 }

function CreateTitleNews()
{
	OpenWindow('Frame.asp?FileName=NewsAddTitle.asp&Titles=新闻添加--标题新闻&ClassID='+BigClassID,420,320,window);
 }

function CreatePicNews()
{
	OpenWindow('Frame.asp?FileName=NewsAddPic.asp&Titles=新闻添加--图片新闻&ClassID='+BigClassID,620,530,window);
 }

function EditNews()
{
	if (NewsID!='')
	{
		switch (NewsType)
		{
			case '1':
				OpenWindow('NewsModify.asp?NewsID='+NewsID,620,500,window);
				break;
			case '2':
				OpenWindow('NewsModify.asp?NewsID='+NewsID,620,190,window);
				break;
			case '3':
				OpenWindow('NewsModify.asp?NewsID='+NewsID,620,530,window);
				break;
			default:
				return;
		}
	}
	if (ClassID!='')
	{
		OpenWindow('Frame.asp?FileName=ClassEdit.asp&Titles=修改栏目&ClassID='+ClassID,350,255,window);
	}
}
function DelNewsClass()
{
	if (ClassID!='') OpenWindow('Frame.asp?FileName=DelNewsClass.asp&Titles=删除栏目&ClassID='+ClassID,300,101,window);
	if (NewsID!='') OpenWindow('Frame.asp?FileName=DelNewsClass.asp&Titles=删除新闻&NewsID='+NewsID,300,101,window);
}

function KeyWord()
{
	TempKeyWords = document.PGNum.Keywords.value;
}

function ChangePage(PageNum)
{
	window.location.href='?page_no='+PageNum+'&KeyWords='+TempKeyWords;
}
function AddClassFun()
{
	 OpenWindow('Frame.asp?FileName=ClassAdd.asp&Titles=添加栏目&ParentID='+BigClassID,350,260,window);
}
</script>