<!--#include file="../../p_inc/Include_func.asp"-->
<!--#include file="../inc/public.asp"-->
<!--#include file="../inc/openconn.asp"-->
<!--#include file="config.asp"-->
<%
	'=============================通用全局变量设置开始==============================
	GG_Title				=	"名站导航管理" '标题
	GG_Table				=	"qingtiandy_tool"
	
	
	'=============================通用全局变量设置结束==============================
	
	sID = Trim(request("Id")):IF sID="" Then sID=0
	Action=Trim(request.QueryString("Action"))
	ref=Request.ServerVariables("HTTP_REFERER")
	f=Trim(request.QueryString("f"))
	ref=IIf(Instr(ref,"left.asp")>0,"index.asp",ref)
	ref=IIf(f<>"",f,ref)
	IF Action="Del" And sID<>"" Then
		fId=FormatNumSerial(sID)
		fId2=split(fId,",")
		For id0=Lbound(fId2) To Ubound(fId2)
			conn.Execute("Delete From qingtiandy_tool Where ID="&fId2(id0))	
		Next
		response.Redirect request.ServerVariables("HTTP_REFERER")
		response.End()
	End IF	
	IF Action="l_look" And sID<>"" Then
		fId=FormatNumSerial(sID)
		l_look=StayNub(request("m_look"))
		IF l_look<>"" Then
			Conn.execute("update  "&GG_Table&" Set m_look="&l_look&" where id In("&fId&")")
		End IF
		response.Redirect request.ServerVariables("HTTP_REFERER")
		response.End()
	End IF	
	If isPostBack And Request.Form("editInfo")="editInfo" Then
		sID = Bint(sID)
		sm_type1=Bint(Request.Form("m_type1"))
		sm_type2=Bint(Request.Form("m_type2"))
		sm_look=Bint(Request.Form("m_look"))
		sm_name=Replace_Text_2008(Request.Form("m_name"))
		sm_name2=Replace_Text_2008(Request.Form("m_name2"))
		sm_no=Bint(Request.Form("m_no"))'权重		
		sm_color=Replace_Text_2008(Request.Form("m_color"))		
		sm_url=Replace_Text_2008(Request.Form("m_url"))		
		sm_pic=Replace_Text_2008(Request.Form("m_pic"))	
		sm_content=Replace_Text_Html(ReplaceTextArea(Request.Form("m_content")))
		sm_time=Replace_Text_2008(Request.Form("m_time"))
		sm_start=Replace_Text_2008(Request.Form("m_start"))
		sm_end=Replace_Text_2008(Request.Form("m_end"))
		sm_province=Bint(Request.Form("m_province"))
		sm_city=Bint(Request.Form("m_city"))
		Set rsObj = Server.CreateObject(G_RS)
		With rsObj
			.Source = "SELECT * FROM "&GG_Table&" WHERE id=" & sID
			.ActiveConnection = conn
			.CursorType = 1
			.LockType = 3
			.Open()
			If .Eof Then 
				.AddNew()
				Set Rs1 = Conn.Execute("Select id from "&GG_Table&" where m_name = '"& sm_name &"' And m_type1="&sm_type1&" And m_type2="&sm_type2)
				If Not Rs1.Eof Then
					doAlert "该网站已经存在！" , "javascript:history.back(-1);"
					Response.End()
				End If
				Rs1.Close : Set Rs1 = Nothing
			Else
				Set Rs1 = Conn.Execute("Select id from "&GG_Table&" where m_name = '"& sm_name &"' And id<>"&sID&" And m_type1="&sm_type1&" And m_type2="&sm_type2)
				If Not Rs1.Eof Then
					doAlert "该网站已经存在！" , "javascript:history.back(-1);"
					Response.End()
				End If
				Rs1.Close : Set Rs1 = Nothing			
			End IF		
			.Fields.Item("m_type1").Value				= sm_type1
			.Fields.Item("m_type2").Value				= sm_type2
			.Fields.Item("m_look").Value				= sm_look
			.Fields.Item("m_name").Value				= sm_name
			.Fields.Item("m_name2").Value				= sm_name2
			.Fields.Item("m_no").Value					= sm_no
			.Fields.Item("m_color").Value				= sm_color			
			.Fields.Item("m_url").Value					= sm_url
			.Fields.Item("m_pic").Value					= sm_pic
			.Fields.Item("m_content").Value				= sm_content			
			IF sm_time<>"" Then
				.Fields.Item("m_time").Value			= ForMatDate(sm_time,55)
			End IF	
			IF sm_start<>"" Then
				.Fields.Item("m_start").Value			= ForMatDate(sm_start,55)
			End IF					
			IF sm_end<>"" Then
				.Fields.Item("m_end").Value				= ForMatDate(sm_end,55)
			End IF				
			.Fields.Item("m_province").Value			= sm_province
			.Fields.Item("m_city").Value				= sm_city
			.Update()
			'Response.Redirect st_str&server.URLEncode("?id="&.Fields.Item("id").Value&"&r_l_type1="&sl_type1&"&r_l_group="&sl_group&"&r_l_list="&sl_list)
			IF ref="" Then ref=	"index.asp?m_type1="&sm_type1
			doAlert "" , TurnBackPage(Request.Form("Ref"),"index.asp?m_type1="&sm_type1)
			Response.End()				
		End With			
	End IF	
	
	am_type1=Bint(Request("m_type1"))
	am_type2=Bint(Request("m_type2"))
	am_province=Bint(Request("m_province"))
	am_city=Bint(Request("m_city"))
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Content-Language" content="zh-cn">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<LINK href="../css/style.css" rel=stylesheet type=text/css>
<title><%=G_WebName%> - <%=GG_Title%>添加/编辑</title>
<script language="javascript" src="../js/p_js.js"></script>
<script language="javascript" src="../js/calendar.js"></script>
<script>
function checkadd(){
	if($("m_type1").value.Trim()=="0"){
		alert("请选择一级类别！")
		$("m_type1").focus()
		return false
	}
	if($("m_name").value.Trim()==""){
		alert("请填写网站名称！")
		$("m_name").focus()
		return false
	}	
	if($("m_url").value.Trim()==""){
		alert("请填写网站地址！")
		$("m_url").focus()
		return false
	}	
		
}
//颜色选择
function SelectColorcmdt(what,backit){
   var dEL = document.all(what);
   var sEL = document.all(backit);
   var url = "../js/color/selcolor.htm?color="+encodeURIComponent(dEL.value);
   var arr = showModalDialog(url,window,"dialogWidth:280px;dialogHeight:250px;help:no;scroll:no;status:no");
   if (arr) {
    dEL.value=arr;
    sEL.style.backgroundColor=arr;
    dEL.style.backgroundColor=arr;
   }
}
function change_m_type2(v){
	for(var i=0;i<=3;i++){
		var s="tr_m_"+i
		if($(s))
			$(s).style.display="none"
	}
	if($("tr_m_"+v))
		$("tr_m_"+v).style.display=""		
}
</script>
</head>
<body>
<iframe name="check_id_1" id="check_id_1" width="0" height="0" src="_blank" style="display:none"></iframe>
<TABLE width="100%" border="0" align=center cellpadding="0" cellspacing="1" class="tableBorder"> 
	<tr> 
	  	<th height=25 colspan="2" class="tableHeaderText"><%=GetDhType1(a_arrmz,am_type1,"2")%>添加/编辑</th> 
	</tr> 
	<form method="POST" action="" name="myform" onSubmit="return checkadd()">
	<input type="hidden" name="ref" value="<%=ref%>">
	<TR> 
		<TD align="left" class="Forumrow" width="200" height="25"><b></b></TD> 
		<TD class="Forumrow">
		<a href="edit_f.asp?m_type1=<%=am_type1%>&m_type2=<%=am_type2%>&m_province=<%=am_province%>&m_city=<%=am_city%>&f=index_0.asp"><font color="#FF0000">添加速度太慢？？点这里批量添加</font></a>
		</TD> 
	</TR>		
	<TR> 
		<TD align="left" class="Forumrow" width="200"><b>显示状态： </b></TD> 
		<TD class="Forumrow">
		<input type="radio" name="m_look" value="1"  checked="checked"/>是
		<input type="radio" name="m_look" value="0"/>否
		</TD> 
	</TR>	
	<TR> 
		<TD align="left" class="Forumrow" ><b>网址类型： <font color="#FF0000">*</font></b></TD> 
		<TD class="Forumrow">			 
			<Select name="m_type1" id="m_type1" onChange="Get_typen2(this.value,'tr_m_r')">
			<%
				Response.Write GetDhType1(a_arrmz,am_type1,1)
			%>
			</Select>
			<span id="tr_m_r">
			<Select name="m_type2" id="m_type2">
			<%
				Response.Write GetDhType1(a_arrmz_1,0,1)
			%>
			</Select>			
			</span>
		</TD> 
	</TR>	
	<script>Get_typen2('<%=am_type1%>','tr_m_r','<%=am_type2%>')</script>
	<TR <%IF am_type1="9" Then Response.Write "Style='display:none'"%>> 
		<TD align="left" class="Forumrow" ><b>省份： <font color="#FF0000">*</font></b></TD> 
		<TD class="Forumrow">			 
			<Select name="m_province" id="m_province" onChange="Get_typen1(this.value,'div_m_type2')">
				<Option value="0">全国</Option>
				<%
					Set oRsip=connip.Execute("Select  province,pid From city_py Group By province,pid")
					Do While Not oRsip.Eof
						s1=oRsip("province")
						s2=oRsip("pid")
						IF Cstr(am_province)=Cstr(s2) Then
							kS1=" Selected"
						Else
							kS1=""
						End IF						
						Response.Write "<option value='"&s2&"'"&kS1&">"&s1&"</option>"
						oRsip.Movenext
					Loop
				%>
			</Select>
		</TD> 
	</TR>
	<TR <%IF am_type1="9" Then Response.Write "Style='display:none'"%>> 
		<TD align="left" class="Forumrow" ><b>城市： <font color="#FF0000">*</font></b></TD> 
		<TD class="Forumrow">			 
			<div id="div_m_type2">			 
				<Select name="m_city" id="m_city">
					<Option value="0">所有城市</Option>
				<%
					Set oRs_t=Server.CreateObject(G_RS)
					oRs_t.open "Select * from city_py where pid="&am_province&" order by id asc",connip,1,1
					Do While Not oRs_t.Eof 
						kId=oRs_t("id")
						kG_name=oRs_t("city")
						IF Cstr(am_city)=Cstr(kId) Then
							kS1=" Selected"
						Else
							kS1=""
						End IF
						
				%>
						<Option value="<%=kId%>"<%=kS1%>><%=kG_name%></Option>
				<%		
						oRs_t.MoveNext
					Loop
					oRs_t.close:Set oRs_t=Nothing
				%>
				</Select>	
				</div>
		</TD> 
	</TR>	
	<TR> 
		<TD align="left" class="Forumrow"><b>网站名称： <font color="#FF0000">*</font></b></TD> 
		<TD class="Forumrow">
			<input type="text" name="m_name" class="smallInput" size="20"  id="m_name">
			<span id="m_name_1"></span>
			别名：
			<input type="text" name="m_name2" class="smallInput" size="20"  id="m_name2">
			权重：<input type="text" name="m_no" class="smallInput" size="10"  id="m_no" value="0" title="权重越大，显示越前面">
			颜色：
		  <input name="m_color" type=text id="A1"  size=8  >
		  <img border=0 src="../js/color/rect.gif" width=18 style="cursor:hand" id=As_1 onClick="SelectColorcmdt('A1','As_1')">			
		</TD> 
	</TR>
	<TR> 
		<TD align="left" class="Forumrow"><b>网站地址： <font color="#FF0000">*</font></b></TD> 
		<TD class="Forumrow">
			<input type="text" name="m_url" class="smallInput" size="50"  id="m_url"> <br>
			本站连接，请用$开头，比如$Ztool/wnl.html<br>
			本站二级类别的标签连接，比如 {qt:typeurl2 30}
		</TD> 
	</TR>
	<tr>
		<td align="left" class="Forumrow"><b> 图片地址：</b> </td>
	  <td  class="Forumrow">
		  <input type="text" name="m_pic" id="m_pic" size="60"  onFocus="$('t_hide').style.display=''" value=""> 
	    		</td>
	 </tr>
	<tr align="right" id="t_hide" style="display:none">
		<td align="left" class="forumRowHighlight"><b>上传图片：</b></td>
		<td align="left" class="forumRowHighlight">
		<iframe src="Uploadpicture.asp" scrolling="no" topmargin="0" width="340" height="20" marginwidth="0" marginheight="0" frameborder="0" align="left"></iframe> 允许类型：<%=UpFileType%>|最大：<%=MaxFileSize%>KB</td>
	<tr>	
	<TR> 
		<TD align="left" class="Forumrow" width="200"><b>描述： </b></TD> 
		<TD class="Forumrow">
			<textarea cols="70" rows="8" name="m_content" id="m_content"></textarea>
		</TD> 
	</TR>	
	<TR> 
		<TD align="left" class="Forumrow" width="200"><b>更新时间： </b></TD> 
		<TD class="Forumrow">
			<input type="text" name="m_time" class="smallInput" size="30"  id="m_time" value="<%=ForMatDate(now(),55)%>"> 
			格式：2008-08-08 08:08:08
		</TD> 
	</TR>	
	<TR> 
		<TD align="left" class="Forumrow" width="200"><b>开始时间： </b></TD> 
		<TD class="Forumrow">
			<input type="text" name="m_start" class="smallInput" size="30"  id="m_start" value="<%=ForMatDate(now(),55)%>"> 
			格式：网址开始显示的时间
		</TD> 
	</TR>	
	<TR> 
		<TD align="left" class="Forumrow" width="200"><b>结束时间： </b></TD> 
		<TD class="Forumrow">
			<input type="text" name="m_end" class="smallInput" size="30"  id="m_end" value="<%=ForMatDate(now()+5000,55)%>"> 
			格式：网址结束显示的时间
		</TD> 
	</TR>				
	<TR> 
		<TD align="left" class="Forumrow" width="200"></TD> 
		<TD class="Forumrow">
		  <input type="hidden" name="editInfo" value="editInfo">
		  <input type="submit" value="提交" name="submit_b" id="submit_b">
		  <input type="button" value="返回列表页" name="submit_c" id="submit_c" onClick="window.location='./index.asp?m_type1=<%=am_type1%>'">		</TD> 
	</TR>		
	</form>
</TABLE>

<SCRIPT language="VBSCRIPT" RUNAT="SERVER">
	Function ShowInfo(sId)
		WriteLn("<S"&"CRIPT LANGUAGE=JAVASCRIPT>")
		WriteLn("	var oForm = myform;")
		WriteLn("	with(oForm){")
		Set rsObj = Server.CreateObject(G_RS)
		rsObj.open "SELECT * FROM "&GG_Table&" WHERE id=" & sId,conn,1,1
		If not rsObj.Eof Then 
			WriteLn("		m_type1.value='" & Str4Js(rsObj.Fields.Item("m_type1").Value) & "';")
			WriteLn("		if($('m_type2'))")
			WriteLn("		m_type2.value='" & Str4Js(rsObj.Fields.Item("m_type2").Value) & "';")
			WriteLn("		m_name.value='" & Str4Js(rsObj.Fields.Item("m_name").Value) & "';")
			WriteLn("		m_name2.value='" & Str4Js(rsObj.Fields.Item("m_name2").Value) & "';")
			WriteLn("		m_no.value='" & Str4Js(rsObj.Fields.Item("m_no").Value) & "';")			
			WriteLn("		m_color.value='" & Str4Js(rsObj.Fields.Item("m_color").Value) & "';")
			WriteLn("		m_url.value='" & Str4Js(rsObj.Fields.Item("m_url").Value) & "';")
			WriteLn("		m_pic.value='" & Str4Js(rsObj.Fields.Item("m_pic").Value) & "';")
			WriteLn("		m_content.value='" & Str4Js(HTMLDecodeTextArea(HTMLDecode(rsObj.Fields.Item("m_content").Value))) & "';")
			WriteLn("		m_time.value='" & Str4Js(rsObj.Fields.Item("m_time").Value) & "';")
			WriteLn("		m_start.value='" & Str4Js(rsObj.Fields.Item("m_start").Value) & "';")
			WriteLn("		m_end.value='" & Str4Js(rsObj.Fields.Item("m_end").Value) & "';")
			m_look = Str4Js(rsObj.Fields.Item("m_look").Value)
			
		End If
		WriteLn("	}")
		WriteLn("</S"&"CRIPT>")
		
		WriteLn(CheckBoxScript("oForm.m_look",m_look))
	End Function
</SCRIPT>	

<%
	If CLng(sId)>0 Then
		ShowInfo sId
	End If

	
	CloseConn()
%>
</body>
</html>