<!--#include file="../../p_inc/Include_func.asp"-->
<!--#include file="../inc/public.asp"-->
<!--#include file="../inc/openconn.asp"-->
<!--#include file="config.asp"-->
<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>
<%
	'=============================通用全局变量设置开始==============================
	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"))
		
		sm_content=Request.Form("m_content")
		all_str=qt_Url_Biaoti(sm_content,"$qingtiandy$")			
		all_str_a=Split(all_str,"$qingtiandy$")
		pi=Ubound(all_str_a)		
		For ai=0 To Ubound(all_str_a)
			sm_name_1=all_str_a(pi)
			sm_name_1_a=Split(sm_name_1,"{##}")
			sm_name=sm_name_1_a(1)
			sm_url=sm_name_1_a(0)
			IF sm_name<>"" And Not IsNull(sm_name) Then sm_name=LoseeHtml(sm_name)
			IF sm_name<>"" And sm_url<>"" And Instr(sm_url,"http://")>0 Then


				Set oRs_ps=Server.CreateObject(G_RS)
				oRs_ps.open "Select * from "&GG_Table&" where m_name = '"& sm_name &"' And m_type1="&sm_type1&" And m_type2="&sm_type2,conn,1,3
				IF oRs_ps.Eof Then
					oRs_ps.AddNew()
					oRs_ps("m_type1")			= sm_type1
					oRs_ps("m_type2")			= sm_type2
					oRs_ps("m_name")			= sm_name
					oRs_ps("m_name2")			= ""
					oRs_ps("m_color")			= ""
					oRs_ps("m_look")			= 1
					oRs_ps("m_url")				= sm_url
					oRs_ps("m_content")			= ""
					oRs_ps("m_time")			= ForMatDate(now(),55)
					oRs_ps("m_no")				= sm_no		
					oRs_ps("m_pic")				= ""	
					IF sm_time<>"" Then
						oRs_ps("m_time")		= ForMatDate(sm_time,55)
					End IF	
					IF sm_start<>"" Then
						oRs_ps("m_start")		= ForMatDate(sm_start,55)
					End IF					
					IF sm_end<>"" Then
						oRs_ps("m_end")			= ForMatDate(sm_end,55)
					End IF				
					oRs_ps("m_province")		= sm_province
					oRs_ps("m_city")			= sm_city					
					oRs_ps.Update()
					Response.Write sm_name&"--"&sm_url&"<font color=blue>导入成功</font><br>"
					Response.Flush()
				Else
					Response.Write sm_name&"--"&sm_url&"<font color=red>已经存在</font><br>"
					Response.Flush()				
				End IF
			Else
				Response.Write sm_name&"--"&sm_url&"<font color=red>不是http地址</font><br>"
				Response.Flush()				
			End IF
			pi=pi-1
		Next
		'Response.Write sm_type1
		'Response.End()
		'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
		IF sm_type1<>10 Then
			doAlert "" , TurnBackPage(Request.Form("Ref"),"index.asp?m_type1="&sm_type1)
		Else
			doAlert "" , "index_10.asp?m_type1="&sm_type1
		End IF
		Response.End()				
					
	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"))
%>

<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
	}
	
		
}
//颜色选择
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>
<script src="citys.js"></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"><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>
	<script>
		function f_m_province(v,value){
			str="";
			var s="";
			for(var ii=1;ii<CityArr.length;ii++){
				var k1=CityArr[ii][1]; //1 父id
				var k2=CityArr[ii][0]; //1 名字
				var k3=CityArr[ii][2]; //1 id
				var k0=CityArr[ii];
				if(k1==v){
					if(k3==value){
						s=" Selected"
					}else{
						s=""
					}
					str+="<option value='"+k3+"'"+s+">"+k2+"</option>";
				}
			}
			document.getElementById("div_m_type2").innerHTML='<Select name="m_city" id="m_city"><Option value="0">所有城市</Option>'+str+'</Select>';	
		}
	</script>	
	<TR> 
		<TD align="left" class="Forumrow" ><b>省份： <font color="#FF0000">*</font></b></TD> 
		<TD class="Forumrow">			 
			<Select name="m_province" id="m_province" onChange="f_m_province(this.value,0)">
				<Option value="0">全国</Option>
				<script>
				str="";
				for(var ii=1;ii<CityArr.length;ii++){
					var k1=CityArr[ii][1]; //1 父id
					var k2=CityArr[ii][0]; //1 名字
					var k3=CityArr[ii][2]; //1 id
					var k0=CityArr[ii];
					if(k0.length==3&&k1!="0"){
						str+="<option value='"+k3+"'>"+k2+"</option>";
					}
				}
				document.write(str);
				</script>
			</Select>
		</TD> 
	</TR>
	<TR> 
		<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" width="200"><b>复制HTML语言到这里： <font color="#FF0000">*</font></b></TD> 
		<TD class="Forumrow">
			<textarea cols="70" rows="12" 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_no" class="smallInput" size="30"  id="m_no" value="0"> 
			权重越大排在越前面
		</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_no.value='" & Str4Js(rsObj.Fields.Item("m_no").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>