<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="java.sql.*,gbase.db.*" %>
<%@ include file="../checkLogin.jsp" %>
<SCRIPT language="JavaScript" src="../js/util.js"></SCRIPT>
<LINK href="../css/css.css" rel=stylesheet>
<%
DBOperation theDBOperation = new DBOperation();

String id = request.getParameter("id") == null ? "" :request.getParameter("id");
String action = request.getParameter("action") == null ? "" :request.getParameter("action");
String title="";
String filename="";
String content="";

if(action.equals("update") || action.equals("view"))
{
String sql = "select * from web_label  where id="+id+" and web_account='"+web_account+"'";
ResultSet rs =theDBOperation.getResultSet(sql);
if(rs.next())
{
title=rs.getString("title")==null?"":rs.getString("title");
filename=rs.getString("filename")==null?"":rs.getString("filename");
content=rs.getString("content")==null?"":rs.getString("content");
}
}
%>
<html>
<head>
<title>
自定义标签管理
</title>
</head>
<body leftmargin="0" topmargin="0">

<!--导航-->
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
       <tr>
		<td width="100%" height="20"  bgcolor="#eeeeee" class="p2">您当前所在的位置>>自定义标签管理</td>
	   </tr>
       <tr>
          <td width="100%" height="2"> <img border="0" src="../images/spacer.gif" width="1" height="3"></td>
       </tr>
    </table>
<!--标题-->
  <div align="center">
   <table border="0" width="100%" cellspacing="0" cellpadding="0" height="34">
	<tr>
		<td width="159" background="../images/back_board2.gif" nowrap valign="bottom"><span class="title01">&nbsp;<span class="style1">新增/修改自定义标签</span></span></td>
		<td valign="bottom" align="right" width="642"></td>
	</tr>
	<tr>
		<td bgcolor="#2C9CC4" colspan="2"><img border="0" src="../images/bline_3.gif" width="1" height="2"></td>
	</tr>
</table>
</div><br>
<form name="main" method="post" action="web_label_save.jsp">
<input name="action" type="hidden" value="<%=action%>">
<input name="id" type="hidden" value="<%=id%>">
<div align="center">
<table width="90%" class="p1" border="0" cellSpacing="1" cellPadding="3" align="center" bgColor="#cccccc">
        
	<tr>
		<td align="right"  bgColor=#e9f0f4 width=13%">标签名称：</td>
		<td onmouseover='vbscript:me.bgcolor="#F5F5F5"'	onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>&nbsp;
	            <input name="title" type="text" size="50" maxlength="25" value="<%=title%>">&nbsp;
                </td>
	</tr>
	<tr>
		<td align="right"  bgColor=#e9f0f4 width=13%">标签文件名：</td>
		<td onmouseover='vbscript:me.bgcolor="#F5F5F5"'	onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>&nbsp;
	            <input name="filename" type="text" size="50" maxlength="50" value="<%=filename%>">&nbsp;
                </td>
	</tr>
	<%if(action.equals("update")){%>
	<tr>
		<td align="right"  bgColor=#e9f0f4>标签使用方式：</td>
		<td onmouseover='vbscript:me.bgcolor="#F5F5F5"'	onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>&nbsp;
			<%=("&lt;jsp:include page='/"+web_account+"/label/"+filename+".jsp'/&gt;")%>
		</td>
	</tr>
	<%}%>
	<tr>
	    <td colspan="2" align="left"  bgColor=#e9f0f4>&nbsp;&nbsp;&nbsp;&nbsp;标签内容</td>
	</tr>
	<tr>
	   <td colspan="2">
	   <textarea name="content" rows=20 cols=110><%=content%></textarea>
           </td>
	</tr>
	
</table>

<table border="0" cellpadding="3" class="p1" width="90%" bordercolor="#D7D7D7" style="border-collapse: collapse" cellspacing="0">
	<tr>
		
		<td  height="0" align="center">
		        <input border="0" type="button" value="保  存" onclick = "javascript: if(check_validate(main)){main.submit();}">
		        &nbsp;&nbsp;&nbsp;&nbsp;<input border="0" type="button" value="重  填" onclick = "document.main.reset();">
		        &nbsp;&nbsp;&nbsp;&nbsp;<input border="0" type="button" value="返  回" onclick = "javascript:history.back();">
		        &nbsp;&nbsp;&nbsp;&nbsp;<input border="0" type="button" value="标签自测" onclick = "window.location='web_label_test.jsp?id=<%=id%>&filename=<%=filename%>'">
		</td>
	</tr>
</table>
</div>
</form>
</body>
<Script Language="javaScript">
    function  checkmystring(str){   
      var myReg=/^[a-zA-Z0-9_-]{1,50}$/;
      if(myReg.exec(str))
      {return true;}
      else{     
      return false;
      }   
    }   
    function  check_validate(theForm) {
        if (isSpace(theForm.title.value)) {
            alert("标签名称不能为空！");
            theForm.title.focus();
            return false;
        }
        if (isSpace(theForm.filename.value)) {
            alert("标签文件名不能为空！");
            theForm.filename.focus();
            return false;
        }
         if (!checkmystring(theForm.filename.value)) {
            alert("标签文件名只能由字母a-z,数字0-9\n\n下划线_ 和 连接符号- 组成！");
            theForm.filename.focus();
            return false;
        }
        return true;
    }
    
</Script>
</html>
