<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="java.sql.*,gbase.db.*" %>
<%@ include file="../checkLogin.jsp" %>
<SCRIPT language="JavaScript" src="../js/util.js"></SCRIPT>
<%
DBOperation theDBOperation = new DBOperation();
String id = request.getParameter("id") == null ? "" :request.getParameter("id");
String sql = "select * from bar_menu where id="+id+" and web_account='"+web_account+"'";
ResultSet rs =theDBOperation.getResultSet(sql);
String name="";
String parent_id=request.getParameter("parent_id") == null ? "" :request.getParameter("parent_id");
String menu_type=request.getParameter("menu_type") == null ? "" :request.getParameter("menu_type");
String content_type=request.getParameter("content_type") == null ? "" :request.getParameter("content_type");
String web_template_id=request.getParameter("web_template_id") == null ? "" :request.getParameter("web_template_id");
String web_template_id2=request.getParameter("web_template_id2") == null ? "" :request.getParameter("web_template_id2");
String menu_level=request.getParameter("menu_level") == null ? "" :request.getParameter("menu_level");
String page_size="";
String row_size="";
String order_id="";
if(rs.next())
{
  name=rs.getString("name");
  parent_id=rs.getString("parent_id");
  menu_type=rs.getString("menu_type");
  content_type=rs.getString("content_type");
  web_template_id=rs.getString("web_template_id");
  web_template_id2=rs.getString("web_template_id2");
  menu_level=rs.getString("menu_level");
  page_size=rs.getString("page_size");
  row_size=rs.getString("row_size");
  order_id=rs.getString("order_id");
}
%>
<html>
<head>
<title>
</title>
<LINK href="../css/css.css" rel=stylesheet>
</head>
<body leftmargin="0" topmargin="0">
<BR>
<form name="form1" method="post" action="barmenu_modify_save.jsp">
<input name="id" type="hidden" value="<%=id%>">
<input name="menu_level" type="hidden" value="<%=menu_level%>">
<input name="parent_id" type="hidden" value="<%=parent_id%>">
<input name="web_template_id" type="hidden" value="<%=web_template_id%>">
<input name="web_template_id2" type="hidden" value="<%=web_template_id2%>">
<input name="old_order_id" type="hidden" value="<%=order_id%>">
<div align="center">
<table border="0" width="80%" cellspacing="0" cellpadding="0" height="29">
	<tr>
		<td align="left"><B>>>修改栏目</B></td>
		<td align="right">
		<%if((!menu_level.equals("2")) && (!menu_type.equals("1")) && (!menu_type.equals("1"))){%>
		<input name="add" type="button" value="新增子栏目" onclick="window.location='barmenu_add.jsp?parent_id=<%=id%>&menu_level=<%=menu_level%>'">
		<%}%> 
		&nbsp;&nbsp;<input name="delete" type="button" value="删除本栏目" onclick="window.location='barmenu_delete.jsp?id=<%=id%>&parent_id=<%=parent_id%>'"></td> 
	</tr>
</table>
<table width="85%" class="p1" border="0" cellSpacing="1" cellPadding="3" align="center" bgColor="#cccccc">
        <tr>
		<td align="right"  bgColor=#e9f0f4 width="30%">栏目编号：</td>
		<td onmouseover='vbscript:me.bgcolor="#F5F5F5"'	onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>&nbsp; 
			<%=id%>
		</td>
	</tr>
	<%
	String top_url="";
        if(menu_type.equals("3"))
          top_url="/";
        else if(content_type.equals("1") || content_type.equals("4")  || content_type.equals("5")  || content_type.equals("6"))
          top_url="/bar"+id+"/";
        else
          top_url="/bar"+id+"_1/";
        %>
	
	<tr>
		<td align="right"  bgColor=#e9f0f4 width="30%">栏目链接：</td>
		<td onmouseover='vbscript:me.bgcolor="#F5F5F5"'	onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>&nbsp; 
			<%=top_url%>
		</td>
	</tr>
        <tr>
		<td align="right"  bgColor=#e9f0f4 width="30%">栏目名称：</td>
		<td onmouseover='vbscript:me.bgcolor="#F5F5F5"'	onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>&nbsp; 
			<input name="name" type="text" size="40" maxlength="25" value="<%=name%>">&nbsp;
		</td>
	</tr>
	<tr>
		<td align="right"  bgColor=#e9f0f4  width="30%">栏目类型：</td>
		<td onmouseover='vbscript:me.bgcolor="#F5F5F5"'	onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>&nbsp; 
		    <%if(parent_id.equals("0")){%>
		    <!--<input type="radio" value="3"  name="menu_type">网站首页&nbsp;&nbsp;&nbsp;&nbsp;-->
		    <%}%>
		    <%if(!menu_level.equals("2")){%>
		    <input type="radio" value="0"  name="menu_type">非子栏目&nbsp;&nbsp;&nbsp;&nbsp;
		    <%}%>
		    <input type="radio" value="1"  name="menu_type">子栏目	
		</td>
	</tr>
	
	<tr>
		<td align="right"  bgColor=#e9f0f4  width="30%">栏目显示属性：</td>
		<td onmouseover='vbscript:me.bgcolor="#F5F5F5"'	onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>&nbsp; 
	             <select name="content_type" onclick="javaScript:onChange_content_type(this.value);">
                        <option value="">--请选择--</option>
                        <option value="4">分栏目页</option>
                        <option value="1">栏目介绍</option>
                        <option value="2">标题列表</option>
                        <option value="3">图片列表</option>
                        <option value="5">在线留言</option>
                     </select>
                     <script>form1.content_type.value='<%=content_type%>';</script>
		</td>
	</tr>
	<tr  id="dis_row_size" style="display:none">
		<td align="right"  bgColor=#e9f0f4 width="30%">每行图片数：</td>
		<td onmouseover='vbscript:me.bgcolor="#F5F5F5"'	onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>&nbsp;
			<input name="row_size" type="text" size="5" maxlength="25" value="<%=row_size%>">&nbsp;
		</td>
	</tr>
	<tr  id="dis_page_size" style="display:none">
		<td align="right"  bgColor=#e9f0f4 width="30%">每页行数：</td>
		<td onmouseover='vbscript:me.bgcolor="#F5F5F5"'	onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>&nbsp;
			<input name="page_size" type="text" size="5" maxlength="25" value="<%=page_size%>">&nbsp;
		</td>
	</tr>
	<tr>
		<td align="right"  bgColor=#e9f0f4 width="30%">位置：</td>
		<td onmouseover='vbscript:me.bgcolor="#F5F5F5"'	onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>&nbsp;
		     <%
	               DBOperation theSelectDBOperation = new DBOperation();
	               String select_sql = "select order_id+1 as new_order_id,name from bar_menu where parent_id='"+parent_id+"' and web_account='"+web_account+"' order by order_id asc ";
                       ResultSet select_rs =theSelectDBOperation.getResultSet(select_sql);
	             %>
	             <select name="order_id">
                        <option value="1">首先</option>
                        <%while(select_rs.next()){%>
	                <option value="<%=select_rs.getString("new_order_id")%>">在栏目"<%=select_rs.getString("name")%>"后</option>
	                <%}%>
	             </select>
	             <script>form1.order_id.value='<%=order_id%>';</script>
                </td>
	</tr>
</table>
<BR>
<table border="0" cellpadding="3" class="p1" width="80%" bordercolor="#D7D7D7" align="center" style="border-collapse: collapse" cellspacing="0">
	<tr>
		<td  height="0" align="center">
		        <input border="0" type="button" value="保  存" onclick = "check_validate(document.form1)">
		        &nbsp;&nbsp;&nbsp;&nbsp;<input border="0" type="button" value="重  填" onclick = "document.form1.reset();"><BR><BR>
		        &nbsp;&nbsp;&nbsp;&nbsp;<input border="0" type="button" value="栏目页预览" onclick = "window.open('barmenu_preview.jsp?id=<%=id%>&content_type=<%=content_type%>&web_template_id=<%=web_template_id%>&web_template_id2=<%=web_template_id2%>&menu_type=<%=menu_type%>&name=<%=name.replaceAll("#", "%23")%>&page_size=<%=page_size%>&row_size=<%=row_size%>','');">
		        &nbsp;&nbsp;&nbsp;&nbsp;<input border="0" type="button" value="生成栏目页Html" onclick = "window.location='barmenu_html.jsp?id=<%=id%>&content_type=<%=content_type%>&web_template_id=<%=web_template_id%>&web_template_id2=<%=web_template_id2%>&menu_type=<%=menu_type%>&name=<%=name.replaceAll("#", "%23")%>&page_size=<%=page_size%>&row_size=<%=row_size%>';">
		      <%if(content_type.equals("2") || content_type.equals("3")){%>  
		        &nbsp;&nbsp;&nbsp;&nbsp;<input border="0" type="button" value="生成内容页Html" onclick = "window.location='barmenu_content_html.jsp?id=<%=id%>&content_type=<%=content_type%>&web_template_id=<%=web_template_id%>&web_template_id2=<%=web_template_id2%>&menu_type=<%=menu_type%>&name=<%=name.replaceAll("#", "%23")%>&page_size=<%=page_size%>&row_size=<%=row_size%>';">
		      <%}%>
			
		</td>
	</tr>
</table>
<BR><BR>
<table border="0" cellpadding="3" class="p1" width="80%" bordercolor="#D7D7D7"  style="border-collapse: collapse" cellspacing="0">
	<tr>
	  <td  height="0">
	    信息说明：<BR>
	      1、<B>栏目的修改或删除要对应修改首页模板的栏目名称以及栏目链接.</B><BR>
	      2、标题列表可以修改每页显示的记录数，<BR>
	      &nbsp;&nbsp;&nbsp;在info.jsp中修改后面的数字即可thePageManager.setPageSize(10);<BR>
	      3、图片列表可以修改每行显示的图片个数和显示的图片行数，<BR>
	        &nbsp;&nbsp;&nbsp;int column_count=3;  //每行显示的图片数，修改左边的数字即可;<BR> 
                &nbsp;&nbsp;&nbsp;int row_count=3;     //每页显示的行数，修改左边的数字即可; <BR>   
              
	          
	  </td>
	</tr>
</table>
</div>
</form>
</body>
<Script Language="javaScript">
    function  get_menu_type()
    {   
        var doc_menu_type=document.getElementsByName("menu_type"); 
        var menu_type="";
        for(var i=0;i<doc_menu_type.length;i++) 
          { 
          if(doc_menu_type[i].checked==true) 
            { 
             menu_type=doc_menu_type[i].value; 
             break; 
            } 
          } 
        return menu_type;
    }
    function  check_validate(theForm) {
        var menu_type=get_menu_type();
        if(isSpace(menu_type)) {
            alert("请选择相应的栏目类型！");
            theForm.menu_type.focus();
            return false;
        }
        if(isSpace(theForm.content_type.value)) {
            alert("请选择相应的栏目显示属性！");
            theForm.content_type.focus();
            return false;
        }
        if(menu_type=='0' || menu_type=='3' )
        {
          if(theForm.content_type.value!='4')
          {
           alert("非子栏目不能选择'分栏目页'！");
           return false;
          }
        }
        else if(menu_type=='1')
        {
          if(theForm.content_type.value=='4')
          {
           alert("子栏目只能选择'分栏目页'！");
           return false;
          }
        }
        if(theForm.content_type.value=='3')
          {
            if(isSpace(theForm.row_size.value) || (!(isNum(theForm.row_size.value))))
           {
            alert("每行图片数不能为空,并且只能为整数！");
            theForm.row_size.focus();
            return false;
           }
          }
          if(isSpace(theForm.page_size.value) || (!(isNum(theForm.page_size.value))))
          {
            alert("每页行数不能为空,并且只能为整数！");
            theForm.page_size.focus();
            return false;
          }
          
        var content_type=theForm.content_type.value;
        if(menu_type=='3')
          theForm.web_template_id.value="index";
        else if(menu_type=='0')
          theForm.web_template_id.value="sum_bar";
        else if(menu_type=='1')
        {
          if(content_type=='1')
            theForm.web_template_id.value="bar_content";
          else if(content_type=='2')
            {
            theForm.web_template_id.value="bar_title_list";
            theForm.web_template_id2.value="bar_title_content";
            }
          else if(content_type=='3')
            {
            theForm.web_template_id.value="bar_image_list";
            theForm.web_template_id2.value="bar_image_content";
            }
          else if(content_type=='5')
            {
            theForm.web_template_id.value="bar_liuyan";
            }
          else if(content_type=='6')
            {
            theForm.web_template_id.value="bar_member_register";
            }  
        }
        theForm.submit();
    }
    
    function  onChange_content_type(content_type)
    { 
      if(content_type=='2' || content_type=='3')
      {
       document.all.dis_page_size.style.display = ""; 
       if(content_type=='3')
        {
        document.all.dis_row_size.style.display = "";
        } 
       else
        document.all.dis_row_size.style.display = "none"; 
      }
      else
      {
       document.all.dis_page_size.style.display = "none"; 
       document.all.dis_row_size.style.display = "none"; 
      }
    }
    function  modify_init(menu_type,content_type)
    { 
        var doc_menu_type=document.getElementsByName("menu_type"); 
        for(var i=0;i<doc_menu_type.length;i++) 
          { 
          if(doc_menu_type[i].value==menu_type) 
            {
             doc_menu_type[i].checked=true
             break; 
            } 
          }
        onChange_content_type(content_type);
    }      
   modify_init('<%=menu_type%>','<%=content_type%>')
</Script>
</html>
