<!--#include file="../../p_inc/Include_func.asp"-->
<!--#include file="../inc/public.asp"-->
<!--#include file="../inc/openconn.asp"-->
<%
	'=============================通用全局变量设置开始==============================
	GG_Title				=	"网址" '标题
	GG_Table				=	"qingtiandh_List2"
	
	'=============================通用全局变量设置结束==============================
	
	sID = Trim(request("Id")):IF sID="" Then sID=0
	Action=Trim(request.QueryString("Action"))
	ref=Request.ServerVariables("HTTP_REFERER")
	ref=IIf(Instr(ref,"left.asp")>0,"index.asp",ref)
	IF Action="Del" And sID<>"" Then
		fId=FormatNumSerial(sID)
		fId2=split(fId,",")
		For id0=Lbound(fId2) To Ubound(fId2)
			conn.Execute("Delete From qingtiandh_List2 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_type3=Bint(Request.Form("m_type3"))
		sm_name=Replace_Text_2008(Request.Form("m_name"))
		sm_color=Replace_Text_2008(Request.Form("m_color"))
		sm_url=Replace_Text_2008(Request.Form("m_url"))
		sm_look=Bint(Request.Form("m_look"))
		sm_content=Replace_Text_Html(ReplaceTextArea(Request.Form("m_content")))
		sm_time=Replace_Text_2008(Request.Form("m_time"))
		sm_no=Bint(Request.Form("m_no"))'权重
		sm_pic=Replace_Text_2008(Request.Form("m_pic"))
		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)
				If Not Rs1.Eof Then
					doAlert "该网站已经存在！" , "javascript:history.back(-1);"
					'Response.Redirect "../TurnPage.asp?t=7_error&r=qingtiandh_List2/edit.asp&n=返回重新添加"
					Response.End()
				Else
					st_str="../TurnPage.asp?t=7&n=返回编辑&r=qingtiandh_List2/edit.asp"
				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)
				If Not Rs1.Eof Then
					doAlert "该网站已经存在！" , "javascript:history.back(-1);"
					'Response.Redirect "../TurnPage.asp?t=7_error&r=qingtiandh_List2/edit.asp?id="&sID&"&n=返回重新编辑"
					Response.End()
				Else
					'st_str="../TurnPage.asp?t=7&n=返回继续编辑&r=qingtiandh_List2/edit.asp"
				End If
				Rs1.Close : Set Rs1 = Nothing			
			End IF		
			.Fields.Item("m_type1").Value				= sm_type1
			.Fields.Item("m_name").Value				= sm_name
			.Fields.Item("m_color").Value				= sm_color
			.Fields.Item("m_look").Value				= sm_look
			.Fields.Item("m_url").Value					= sm_url
			.Fields.Item("m_content").Value				= sm_content
			IF sm_time<>"" Then
				.Fields.Item("m_time").Value			= ForMatDate(sm_time,55)
			End IF			
			.Fields.Item("m_no").Value					= sm_no
			.Fields.Item("m_pic").Value					= sm_pic
			.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"
			doAlert "" , TurnBackPage(Request.Form("Ref"),"index.asp")
			Response.End()				
		End With			
	End IF	
	
	am_type1=Bint(Request("m_type1"))
	am_type2=Bint(Request("m_type2"))
	am_type3=Bint(Request("m_type3"))
%>
<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;
   }
}
</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"><%=GG_Title%>添加/编辑</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">
				<Option value="0">选择类别</Option>
			<%
				Set oRs_t=Server.CreateObject(G_RS)
				oRs_t.open "Select * from qingtiandh_ltype1 order by typehide asc,typeno asc,typeid asc",conn,1,1
				Do While Not oRs_t.Eof 
					kTypeid=oRs_t("typeid")
					kTypename=oRs_t("typename")
					IF Cstr(am_type1)=Cstr(kTypeid) Then
						kS1=" Selected"
					Else
						kS1=""
					End IF
					
			%>
					<Option value="<%=kTypeid%>"<%=kS1%>><%=kTypename%></Option>
			<%		
					oRs_t.MoveNext
				Loop
				oRs_t.close:Set oRs_t=Nothing
			%>
			</Select>
		</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="50" onChange="check_music2()" id="m_name">
			<span id="m_name_1"></span>
			颜色：
		  <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">
		</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)%>"> 
			格式：<b>2008-08-08 08:08:08</b>
		</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"></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'">		</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("		m_name.value='" & Str4Js(rsObj.Fields.Item("m_name").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_no.value='" & Str4Js(rsObj.Fields.Item("m_no").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>