<% Option Explicit %>
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312" />
<TITLE>编辑友情链接</TITLE>
<link rel="stylesheet" href="../Images/CssAdmin.css">
<script language="javascript" src="../inc/Admin.js"></script>
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
</style>
</HEAD>
<!--#include file="../../Include/Const.asp" -->
<!--#include file="../../Include/Conn1.asp" -->
<!--#include file="../CheckAdmin.asp"-->
<BODY>
<% 
dim Result
Result=request.QueryString("Result")
dim ID,SiteName,ViewFlag,LinkType,SiteFace,Remark,Angel_languageid,n,showm,mLid,rs,sql
ID=request.QueryString("ID")
call LinkEdit() 
%>
<%If Result = "Add" then%>
<div id="Language">
<div style="height:37px;background:#ffffff;border:1px #628ae1 solid;padding-top:5px; width:100%; padding-left:10px;clear:both;">
<h2>简体中文</h2>
</div>
<%end if%>
<br />
<%
  set rs = server.createobject("adodb.recordset")
  sql="select * from Angel_Language order by Lorder desc"
  rs.open sql,conn,1,3
  n=0
  do while not rs.eof
  if request("m")<>"" then
  showm=request("m")
  else
  showm=n
  end if
  if Result = "Add" then
  mLid=rs("id")
  Angel_languageid=rs("id")
  else
  mLid=Angel_languageid
  end if
%>
<ul>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#628AE1">
  <tr>
    <td height="24" nowrap><font color="#FFFFFF"><img src="../Images/Explain.gif" width="18" height="18" border="0" align="absmiddle">&nbsp;<strong>友情链接：添加，修改友情链接信息</strong></font></td>
  </tr>
  <tr>
    <td height="24" align="center" nowrap  bgcolor="#FFFFFF"><a href="LinkEdit.asp?Result=Add&m=<%=showm%>" >添加友情链接</a><font color="#0000FF">&nbsp;|&nbsp;</font><a href="LinkList.asp" >查看友情链接</a></td>
  </tr>
</table>
<br>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#628AE1">
  <form name="editForm<%=mLid%>" method="post" action="LinkEdit.asp?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>&m=<%=showm%>">
  <tr>
    <td height="24" nowrap bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="0" cellspacing="0" id=editProduct idth="100%">

      <tr>
        <td width="160" height="20" align="right">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td height="20" align="right">站点名称：</td>
        <td><input name="SiteName" type="text" class="textfield" id="SiteName" style="WIDTH: 240;" value="<%=SiteName%>">&nbsp;*&nbsp;不少于3个字符</td>
      </tr>
      <tr>
        <td height="20" align="right">发　　布：</td>
        <td><input name="ViewFlag" type="checkbox" style='HEIGHT: 13px;WIDTH: 13px;' value="1" checked <%if ViewFlag then response.write ("checked")%>></td>
      </tr>
      <tr>
        <td height="20" align="right">推荐：</td>
        <td><input name="LinkType" type="radio" value="1" <%if LinkType then response.write ("checked=checked")%>/>
          是&nbsp;
          <input name="LinkType" type="radio" value="0" <%if not LinkType then response.write ("checked=checked")%>/>否</td></tr>
      <tr style="display:none">
        <td height="20" align="right">前台显示：</td>
        <td><input name="SiteFace" type="text" class="textfield" id="SiteFace" style="WIDTH: 240;" value="<%=SiteFace%>">&nbsp;*&nbsp;<a href="javaScript:OpenScript('../inc/UpFileForm.asp?Result=SiteFace',460,180)"><img src="../Images/Upload.gif" width="30" height="16" border="0" align="absmiddle"></a>&nbsp;&nbsp;图片110×34&nbsp;&nbsp;文字≤8个汉字</td>
      </tr>
      <tr>
        <td height="20" align="right">链接网址：</td>
        <td><input name="SiteUrl" type="text" class="textfield" id="SiteUrl" style="WIDTH: 490;" value="<%=SiteUrl%>">&nbsp;*</td>
      </tr>
      <tr>
        <td height="20" align="right" valign="top">备注说明：
        <td><textarea name="Remark" rows="6" class="textfield" id="Remark" style="WIDTH: 490;"><%=Remark%></textarea></td>
      </tr>

      <tr>
        <td height="30" align="right">&nbsp;<input name="Angel_languageid" type="hidden" value="<%=Angel_languageid%>" /></td>
        <td valign="bottom"><input name="submitSaveEdit" type="submit" class="button"  id="submitSaveEdit" value="保存" style="WIDTH: 80;" ></td>
      </tr>
      <tr>
        <td height="20" align="right">&nbsp;</td>
        <td valign="bottom">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  </form>
</table>
</ul>
<%
rs.movenext
n=n+1
If Result = "Modify" then
if n>0 then exit do
end if
loop
rs.close%>
<%If Result = "Add" then%>
</div>
<%dim m
m=request.QueryString("m")
if m="" then m=0
%>
<script>
function $(id){return document.getElementById(id);}
function $tag(id,tagName){return $(id).getElementsByTagName(tagName)}
var onum=<%=m%>;//用于控制默认打开的标签
var Ds=$tag("Language","ul");
var Ts=$tag("Language","h2");
for(var i=0; i<Ds.length;i++){
if(i==onum){
Ds[i].style.display="block";
Ts[i].className = "title_current";
}
else{
Ds[i].style.display="none";
Ts[i].className = "title_normal";
}
Ts[i].value=i;
Ts[i].onmousedown=function(){
if(onum==this.value){return false;};
Ts[onum].className="title_normal";
Ts[this.value].className="title_current";
Ds[onum].style.display="none";
Ds[this.value].style.display="block";
onum=this.value;
}
}
</script>
<%end If%>
</BODY>
</HTML>
<%
sub LinkEdit()
  dim Action,rsCheckAdd,rs,sql
  Action=request.QueryString("Action")
  if Action="SaveEdit" then '保存编辑管理员信息
    set rs = server.createobject("adodb.recordset")
    if len(trim(request.Form("SiteName")))<2 then
      response.write ("<script language=javascript> alert('网站名称为必填项目且不少于2个字符！');history.back(-1);</script>")
      response.end
    end if

    if request.Form("LinkType")=0 then
      if StrLen(trim(request.Form("SiteFace")))>16 then
      response.write ("<script language=javascript> alert('您选择的""文字""链接，因此前台显示不得超过8个汉字！');history.back(-1);</script>")
      response.end
      end if
    end if
    if len(trim(request.Form("SiteUrl")))<6 then
      response.write ("<script language=javascript> alert('链接网址为必填项目且不少于6个字符！');history.back(-1);</script>")
      response.end
    end if
    if Result="Add" then '创建网站管理员
	  sql="select * from Angel_Link"
      rs.open sql,conn,1,3
      rs.addnew
      rs("SiteName")=trim(Request.Form("SiteName"))
	  if Request.Form("ViewFlag")=1 then
        rs("ViewFlag")=Request.Form("ViewFlag")
	  else
        rs("ViewFlag")=0
	  end if
      rs("SiteFace")=trim(Request.Form("SiteFace"))
      rs("SiteUrl")=trim(Request.Form("SiteUrl"))
	  if Request.Form("LinkType")=1 then
        rs("LinkType")=Request.Form("LinkType")
	  else
        rs("LinkType")=0
	  end if	  
	  rs("Remark")=trim(Request.Form("Remark"))
	  rs("AddTime")=now()
	end if  
	if Result="Modify" then '修改网站管理员
      sql="select * from Angel_Link where ID="&ID
      rs.open sql,conn,1,3
      rs("SiteName")=trim(Request.Form("SiteName"))
	  if Request.Form("ViewFlag")=1 then
        rs("ViewFlag")=Request.Form("ViewFlag")
	  else
        rs("ViewFlag")=0
	  end if
      rs("SiteFace")=trim(Request.Form("SiteFace"))
      rs("SiteUrl")=trim(Request.Form("SiteUrl"))
	  if Request.Form("LinkType")=1 then
        rs("LinkType")=Request.Form("LinkType")
	  else
        rs("LinkType")=0
	  end if	  
	  rs("Remark")=trim(Request.Form("Remark"))
	end If
	rs("Angel_languageid")=trim(request.Form("Angel_languageid"))
	rs.update
	rs.close
    set rs=nothing 
    response.write "<script language=javascript> alert('成功编辑友情链接！');location.replace('LinkList.asp?m="&request("m")&"');</script>"
  else '提取信息
	if Result="Modify" then
      set rs = server.createobject("adodb.recordset")
      sql="select * from Angel_Link where ID="& ID
      rs.open sql,conn,1,1
	  SiteName=rs("SiteName")
	  ViewFlag=rs("ViewFlag")
	  LinkType=rs("LinkType")
	  SiteFace=rs("SiteFace")
      SiteUrl=rs("SiteUrl")
      Remark=rs("Remark")
	  Angel_languageid=rs("Angel_languageid")
	  rs.close
      set rs=nothing 
	end if
  end if
end sub
%>