<%@ page contentType="text/html;charset=UTF-8" errorPage="../error.jsp"%>
<%@ page import="com.hongshee.ejforum.util.PageUtils"%>
<%@ page import="com.hongshee.ejforum.common.CacheManager"%>
<%@ page import="com.hongshee.ejforum.data.UserDAO.UserInfo"%>
<%@ page import="com.hongshee.ejforum.data.SectionDAO.SectionVO"%>
<%
	UserInfo userinfo = PageUtils.getAdminUser(request, response);
	if (userinfo == null) return;
	String fromPath = request.getContextPath() + "/admin/forums/forum_edit.jsp";
	
	int sectionID = PageUtils.getIntParam(request,"sid");
	CacheManager cache = CacheManager.getInstance();
	SectionVO aSection = cache.getSection(sectionID);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="../style/admin.css" type=text/css rel=stylesheet>
<SCRIPT src="../../js/common.js" type=text/javascript></SCRIPT>
<SCRIPT src="../js/admin.js" type=text/javascript></SCRIPT>
</HEAD>
<BODY topMargin=10>
<TABLE cellSpacing=6 cellPadding=2 width="100%" border=0>
  <TBODY>
  <TR>
    <TD>
      <TABLE class=guide cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD>
		    <A onclick="parent.location='../index.htm';return false;" href="#">后台管理首页</A>&nbsp;&raquo;&nbsp;编辑分区
		  </TD></TR></TBODY></TABLE><BR>
      <TABLE class=info_tb cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR class=header>
          <TD>
            <DIV style="FLOAT: left; MARGIN-LEFT: 0px; PADDING-TOP: 8px"><A 
            onclick="collapse_change('tip','../images')" href="#">技巧提示</A></DIV>
            <DIV style="FLOAT: right; PADDING-BOTTOM: 9px; MARGIN-RIGHT: 4px"><A 
            onclick="collapse_change('tip','../images')" href="#">
			<IMG id=menuimg_tip src="../images/menu_reduce.gif" border=0></A></DIV></TD></TR>
        <TBODY id=menu_tip>
        <TR>
          <TD>
            <UL><LI><%= PageUtils.getString("section_edit_tip_1") %></LI></UL></TD></TR></TBODY></TABLE><BR>
      <FORM id=settings name=settings onSubmit="checkfields(this); return false;" action="../perform.jsp" method=post>
	  <INPUT type=hidden name="act" value="forums_section_edit">
	  <INPUT type=hidden name="sectionID" value="<%= aSection.sectionID %>">
	  <INPUT type=hidden name="fromPath" value="<%= fromPath %>">
	  <A name=tb01></A>
      <TABLE class=info_tb cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR class=header>
          <TD colSpan=2>分区基本设置<A onclick="collapse_change('tb01','../images')" href="#">
 		    <IMG id=menuimg_tb01 style="MARGIN-TOP: -12px; FLOAT: right; MARGIN-RIGHT: 8px" 
             src="../images/menu_reduce.gif" border=0></A> </TD></TR>
        <TBODY id=menu_tb01>
        <TR>
          <TD class=altbg1 width="45%"><B>分区名称:</B></TD>
          <TD class=altbg2><INPUT size=50 value="<%= aSection.sectionName %>" name="sectionName"> </TD></TR>
        <TR>
          <TD class=altbg1 width="45%"><B>下级子版块横排:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("section_edit_1") %></SPAN></TD>
          <TD class=altbg2><INPUT size=50 value="<%= String.valueOf(aSection.cols) %>" name="cols"> </TD></TR>
	  </TBODY></TABLE><BR>
		<A name=tb03></A>
      <TABLE class=info_tb cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR class=header>
          <TD colSpan=2>扩展设置<A onClick="collapse_change('tb03','../images')" href="#">
		    <IMG id=menuimg_tb03 style="MARGIN-TOP: -12px; FLOAT: right; MARGIN-RIGHT: 4px" 
             src="../images/menu_reduce.gif" border=0></A></TD></TR>
        <TBODY id=menu_tb03>
		<TR>
			<TD width="45%" class="altbg1" valign="top"><b>分区 logo:</b><br/>
			<span class="smalltxt"><%= PageUtils.getString("section_edit_2") %></span></TD>
			<TD class="altbg2"><input type="text" size="50" name="logo"></TD>
		</TR>
        <TR>
          <TD class=altbg1 width="45%" valign="top"><B>页首广告代码:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("section_edit_3") %></SPAN></TD>
          <TD class=altbg2>
		    <IMG onmouseover="this.style.cursor='pointer'" onclick="zoomtextarea('headAdCode', 1)" src="../images/zoomin.gif"> 
			<IMG onmouseover="this.style.cursor='pointer'" onclick="zoomtextarea('headAdCode', 0)" src="../images/zoomout.gif">
            <BR><TEXTAREA id="headAdCode" name="headAdCode" rows=6 cols=50 
				 style="width:278px"><%= aSection.headAdCode==null?"":aSection.headAdCode.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;") %></TEXTAREA></TD></TR>
        <TR>
          <TD class=altbg1 width="45%" valign="top"><B>页脚广告代码:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("section_edit_4") %></SPAN></TD>
          <TD class=altbg2>
		    <IMG onmouseover="this.style.cursor='pointer'" onclick="zoomtextarea('footAdCode', 1)" src="../images/zoomin.gif"> 
			<IMG onmouseover="this.style.cursor='pointer'" onclick="zoomtextarea('footAdCode', 0)" src="../images/zoomout.gif">
            <BR><TEXTAREA id="footAdCode" name="footAdCode" rows=6 cols=50 
				 style="width:278px"><%= aSection.footAdCode==null?"":aSection.footAdCode.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;")  %></TEXTAREA> </TD></TR>
        <TR>
          <TD class=altbg1 width="45%" valign="top"><B>子版块主题列表标签:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("section_edit_5") %></SPAN></TD>
          <TD class=altbg2>
			<INPUT class=checkbox type=checkbox checked value="H" name="filter" id="filter[H]"> 
			热门主题 &nbsp;
			<INPUT class=checkbox type=checkbox checked value="I" name="filter" id="filter[I]"> 
			图片主题 &nbsp;
			<INPUT class=checkbox type=checkbox checked value="V" name="filter" id="filter[V]"> 
			投票主题 &nbsp;
			<INPUT class=checkbox type=checkbox checked value="R" name="filter" id="filter[R]"> 
			悬赏主题</TD></TR>
        <TR>
          <TD class=altbg1 width="45%" valign="top"><B>子版块版规显示位置:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("section_edit_6") %></SPAN></TD>
          <TD class=altbg2>
			<INPUT class=radio type=radio checked value="T" name="ruleon" id="ruleon[T]"> 
			在主题列表的上方 &nbsp;
			<INPUT class=radio type=radio value="B" name="ruleon" id="ruleon[B]"> 
			在主题列表的下方</TD></TR>
        <TR>
          <TD class=altbg1 width="45%" valign="top"><B>子版块主题分类显示位置:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("section_edit_7") %></SPAN></TD>
          <TD class=altbg2>
			<INPUT class=radio type=radio checked value="T" name="caton" id="caton[T]"> 
			在主题列表的上方 &nbsp;
			<INPUT class=radio type=radio value="R" name="caton" id="caton[R]"> 
			在版块标题的右侧</TD></TR>
		 <TR>
		 	<TD width="45%" class="altbg1"><b>显示主题推介区</b><br/>
				<span class="smalltxt"><%= PageUtils.getString("section_edit_8") %></span></TD>
			<TD class="altbg2">
		<input class="checkbox" type="checkbox" name="[chk]showHotlinks" value="I" id="showHotlinks[I]" 
			   onclick="clickImageLinks()"> 最新图片
		<input class="checkbox" type="checkbox" name="[chk]showHotlinks" value="N" id="showHotlinks[N]"> 最新发表
		<input class="checkbox" type="checkbox" name="[chk]showHotlinks" value="D" id="showHotlinks[D]"> 最新精华 <br/>
		<input class="checkbox" type="checkbox" name="[chk]showHotlinks" value="C" id="showHotlinks[C]"> 热门分类 
		<input class="checkbox" type="checkbox" name="[chk]showHotlinks" value="H" id="showHotlinks[H]"> 最新热门主题 
		<input class="checkbox" type="checkbox" name="[chk]showHotlinks" value="R" id="showHotlinks[R]"> 最新人气主题 
		<input type="hidden" name="[chk]showHotlinks" value="" id="showHotlinks[]">
			</TD></TR>
        <TR>
          <TD class=altbg1 width="45%"><B>主题推介区主题数:</B><BR><SPAN 
              class=smalltxt><%= PageUtils.getString("section_edit_9") %></SPAN></TD>
          <TD class=altbg2><INPUT size=50 value=10 name="hotlinkRows"> </TD></TR>
        <TR>
          <TD class=altbg1 width="45%"><B>在版块主题列表页显示推介区:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("section_edit_10") %></SPAN></TD>
          <TD class=altbg2>
	  	<INPUT class=radio type=radio value="T" name="isOnBoard" id="isOnBoard[T]"> 是 &nbsp;&nbsp; 
		<INPUT class=radio type=radio value="F" name="isOnBoard" id="isOnBoard[F]" checked> 否 </TD></TR>
		  </TD></TR>
        <TBODY id=advanceoption style="DISPLAY: none">
        <TR>
          <TD class=altbg1 width="45%"><B>图片样式:</B><BR><SPAN 
            class=smalltxt><%= PageUtils.getString("section_edit_11") %></SPAN></TD>
          <TD class=altbg2>
	  	<INPUT class=radio type=radio value="P" name="imageMode" id="imageMode[P]" checked> 单一图片 &nbsp;&nbsp; 
		<INPUT class=radio type=radio value="S" name="imageMode" id="imageMode[S]"> 图片幻灯片 </TD></TR>
		<TR>
			<TD width="45%" class="altbg1" ><b>最新图片:</b><br/>
			<span class="smalltxt"><%= PageUtils.getString("section_edit_12") %></span></TD>
			<TD class="altbg2"><input type="text" size="50" name="imageFile" value="" ></TD></TR>
		<TR>
			<TD width="45%" class="altbg1" ><b>最新图片的目标链接:</b><br/>
			<span class="smalltxt"><%= PageUtils.getString("section_edit_13") %></span></TD>
			<TD class="altbg2"><input type="text" size="50" name="imageLink" value="" ></TD></TR>
		<TR>
			<TD width="45%" class="altbg1" ><b>最新图片的文字说明:</b><br/>
			<span class="smalltxt"><%= PageUtils.getString("section_edit_14") %></span></TD>
			<TD class="altbg2"><input type="text" size="50" name="imageTitle" value="" ></TD></TR>
        </TBODY></TABLE><BR>
      <CENTER><INPUT class=button type=submit value="提 交"></CENTER></FORM>
	  </TD></TR></TBODY></TABLE><BR><BR>
<script language="javascript">
function checkfields(theform) {
	if (trim(theform.sectionName.value) == '') {
		alert('分区名称不可以为空');
      	theform.sectionName.focus();
		return;
	}
    var filter = /^\d+$/;
    if (!filter.test(trim(theform.hotlinkRows.value))) {
    	alert('主题推介区主题数必须为整数');
      	theform.hotlinkRows.focus();
		return;
    }
    if (!filter.test(trim(theform.cols.value))) {
    	alert('下级子版块横排数必须为整数');
      	theform.cols.focus();
		return;
    }
	theform.submit();
}
function clickImageLinks() 
{
	$('advanceoption').style.display = $('showHotlinks[I]').checked ? '' : 'none';
}
<%
	if (aSection.filter != null && aSection.filter.indexOf("H")<0)
		out.write("$('filter[H]').checked = false;\n");
	if (aSection.filter != null && aSection.filter.indexOf("I")<0)
		out.write("$('filter[I]').checked = false;\n");
	if (aSection.filter != null && aSection.filter.indexOf("V")<0)
		out.write("$('filter[V]').checked = false;\n");
	if (aSection.filter != null && aSection.filter.indexOf("R")<0)
		out.write("$('filter[R]').checked = false;\n");
	
	String showHotlinks = aSection.showHotlinks;
	if (showHotlinks == null)
		showHotlinks = "";
	else
		showHotlinks = showHotlinks.trim();

	for (int i=0; i<showHotlinks.length(); i++)
	{
%>
$('showHotlinks[<%= showHotlinks.charAt(i) %>]').checked = true;
<%
	}
%>
$('caton[<%= aSection.caton %>]').checked = true;
$('ruleon[<%= aSection.ruleon %>]').checked = true;
$('settings').logo.value = "<%= aSection.logo==null?"":aSection.logo %>";
$('isOnBoard[<%= aSection.isOnBoard %>]').checked = true;
$('imageMode[<%= aSection.imageMode %>]').checked = true;
$('settings').imageFile.value = '<%= aSection.imageFile==null?"":aSection.imageFile.replace("'","\\'") %>';
$('settings').imageLink.value = '<%= aSection.imageLink==null?"":aSection.imageLink.replace("'","\\'") %>';
$('settings').imageTitle.value = '<%= aSection.imageTitle==null?"":aSection.imageTitle.replace("'","\\'") %>';
$('settings').hotlinkRows.value = "<%= aSection.hotlinkRows %>";

if ($('showHotlinks[I]').checked)
	$('advanceoption').style.display = "";
else
	$('advanceoption').style.display = "none";
</script>	  
<%= PageUtils.getAdminFooter(request) %>
</BODY></HTML>
