<%@ 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 parent_id = request.getParameter("parent_id") == null ? "" :request.getParameter("parent_id");
String menu_level = request.getParameter("menu_level") == null ? "" :request.getParameter("menu_level");
if(menu_level.equals("0"))
menu_level="1";
else if(menu_level.equals("1"))
menu_level="2";
else if(menu_level.equals("2"))
menu_level="3";

%>
<html>
<head>
<title>
</title>
</head>
<LINK href="../css/css.css" rel=stylesheet>
<body leftmargin="0" topmargin="0">
<BR>
<form name="form1" method="post" action="barmenu_add_save.jsp">
<input name="parent_id" type="hidden" value="<%=parent_id%>">
<input name="menu_level" type="hidden" value="<%=menu_level%>">
<input name="web_template_id" type="hidden" value="">
<input name="web_template_id2" type="hidden" value="">
<div align="center">
<table border="0" width="80%" cellspacing="0" cellpadding="0" height="29">
	<tr>
		<td align="left"><B>>>新增子栏目</B></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;
			<input name="name" type="text" size="40" maxlength="25">&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(!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>
                </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="3">&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="20">&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")%>" selected>在栏目"<%=select_rs.getString("name")%>"后</option>
	                <%}%>
	             </select>
                </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">
			<img border="0" src="../images/btn/confirm.gif"  onclick = "check_validate(document.form1)" style="cursor:hand">
			<A href="javascript:document.form1.reset();"><IMG src="../images/btn/reset.gif" border=0></A>
			<A href="javascript:history.back();"><IMG src="../images/btn/back.gif"  border=0></A>
		</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=='2' || theForm.content_type.value=='3')
        {
          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 = ""; 
       document.form1.page_size.value=20;
       if(content_type=='3')
        {
        document.all.dis_row_size.style.display = "";
        document.form1.page_size.value=5;
        } 
       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"; 
      }
    }
</Script>
</html>
