<!--#include file="../../Conn.asp" -->
<!--#include file="../../Comm/Site_Class.asp" -->
<%
PagePath = "../../"

Set Qsite = New Site_Class

Qsite.SiteConfig_Master()
%>
<!--#include file="../Check_Login.asp" -->
<%
Qsite.Check_AdminFlag(arrAdminFlag(6 , 1))

Dim Rs,Sql,i
Dim FriendLinkTypeId,FriendLinkSiteName,FriendLinkSiteUrl
Dim FriendLinkLogoUrl,FriendLinkIsLogo,FriendLinkSiteNote,Px
Dim contPx

Set Rs = server.createobject("ADODB.Recordset")

If Request.Form <> "" Then
	FriendLinkTypeId = Qsite.chgStr(Trim(Request.Form("FriendLinkTypeId")))
	FriendLinkSiteName = Qsite.chgStr(Trim(Request.Form("FriendLinkSiteName")))
	FriendLinkSiteUrl = Qsite.chgStr(Trim(Request.Form("FriendLinkSiteUrl")))
	FriendLinkLogoUrl = Qsite.chgStr(Trim(Request.Form("FriendLinkLogoUrl")))
	FriendLinkIsLogo = Qsite.chgStr(Trim(Request.Form("FriendLinkIsLogo")))
	Px = Qsite.chgStr(Trim(Request.Form("Px")))
	FriendLinkSiteNote = Qsite.chgStr(Trim(Request.Form("FriendLinkSiteNote")))
	
	If FriendLinkTypeId = "" Or IsNull(FriendLinkTypeId) Or Not IsNumeric(FriendLinkTypeId) Then
		Qsite.ShowMsg "请选择分类" , ""
	End If
	If FriendLinkSiteName = "" Or IsNull(FriendLinkSiteName) Then
		Qsite.ShowMsg "请输入网站名称" , ""
	End If
	If FriendLinkSiteUrl = "" Or IsNull(FriendLinkSiteUrl) Then
		Qsite.ShowMsg "请输入网站地址" , ""
	End If
	If InStr(FriendLinkSiteUrl , "http://") <= 0 Then
		Qsite.ShowMsg "输入的网站地址不正确，请返回重新输入" , ""
	End If
	If FriendLinkSiteNote = "" Or IsNull(FriendLinkSiteNote) Then
		Qsite.ShowMsg "请输入网站说明" , ""
	End If
	If FriendLinkIsLogo <> "1" Then FriendLinkIsLogo = "0"
	If Px = "" Or IsNull(Px) Or Not IsNumeric(Px) Then Px = 1
	
	Rs.Open "select FriendLinkSiteName from FriendLinkTbl where FriendLinkSiteName = '"& FriendLinkSiteName &"'" , Conn , 1 , 1
	If Not Rs.Eof Then
		Qsite.ShowMsg "此网站已经存在，请返回重新输入" , ""
	End If
	Set Rs = Nothing
	
	Conn.Execute("update FriendLinkTbl set Px = Px + 1 where Px >= "& Px)
	
	Conn.Execute("insert into FriendLinkTbl (FriendLinkSiteName , FriendLinkSiteUrl , FriendLinkLogoUrl , FriendLinkIsLogo , FriendLinkSiteNote , FriendLinkTypeId , Px) values ('"& FriendLinkSiteName &"' , '"& FriendLinkSiteUrl &"' , '"& FriendLinkLogoUrl &"' , '"& FriendLinkIsLogo &"' , '"& FriendLinkSiteNote &"' , "& FriendLinkTypeId &" , "& Px &")")
	
	Qsite.ShowMsg "友情链接添加成功" , "FriendLink_Add.asp"
End If

Rs.Open "select top 1 * from FriendLinkTbl order by Px desc" , Conn ,1 , 1
If Rs.Eof Then
	contPx = 1
Else
	contPx = Rs("Px") + 1
End If
Rs.Close
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>友情链接管理</title>
<link href="../skins/css/main.css" rel="stylesheet" type="text/css">
<script language="javascript">
function CheckForm()
{
	if(PosForm.FriendLinkTypeId.value == "")
	{
		alert("请选择分类");
		return false;
	}
	if(PosForm.FriendLinkSiteName.value == "")
	{
		alert("请输入网站名称");
		PosForm.FriendLinkSiteName.focus();
		return false;
	}
	if(PosForm.FriendLinkSiteUrl.value == "")
	{
		alert("请输入网站地址");
		PosForm.FriendLinkSiteUrl.focus();
		return false;
	}
	if(PosForm.FriendLinkSiteNote.value == "")
	{
		alert("请输入网站说明");
		PosForm.FriendLinkSiteNote.focus();
		return false;
	}
	return true;
}

function UploadLogo()
{
	window.open('Upload_Logo.asp','Upload','width=380px,height=90px,left=300,top=300');
} 
</script>
</head>

<body>
<form name="PosForm" method="post" action="FriendLink_Add.asp" style="margin:0" onSubmit="return CheckForm();">
	<table width="100%" border="0" cellspacing="1" cellpadding="5">
		<tr>
			<td height="25" colspan="2" class="td_title">友情链接添加</td>
		</tr>
		<tr>
			<td width="18%" height="23" class="td_content">友情链接分类：</td>
			<td width="82%" height="23" class="td_content"><select name="FriendLinkTypeId" class="input_1" id="FriendLinkTypeId">
				<option value="">请选择分类</option>
				<%
				Rs.Open "select * from FriendLinkTypeTbl order by Px asc" , Conn , 1 , 1
				Do While Not Rs.Eof
					Response.Write("<option value="""& Rs("FriendLinkTypeId") &""">"& Rs("FriendLinkTypeName") &"</option>")
				Rs.MoveNext
				Loop
				Rs.Close
				%>
			</select>			</td>
		</tr>
		<tr>
			<td height="23" class="td_content">网站名称：</td>
			<td height="23" class="td_content"><input name="FriendLinkSiteName" type="text" class="input_1" id="FriendLinkSiteName" size="40"></td>
		</tr>
		<tr>
			<td height="23" class="td_content">网站地址：</td>
			<td height="23" class="td_content"><input name="FriendLinkSiteUrl" type="text" class="input_1" id="FriendLinkSiteUrl" value="http://" size="60"></td>
		</tr>
		<tr>
			<td height="23" class="td_content">Logo地址：</td>
			<td height="23" class="td_content"><input name="FriendLinkLogoUrl" type="text" class="input_1" id="FriendLinkLogoUrl" size="60">
			<input name="Btn" type="button" class="input_1" id="Btn" value="上传Logo" onClick="UploadLogo();"></td>
		</tr>
		<tr>
			<td height="23" class="td_content">Logo显示：</td>
			<td height="23" class="td_content"><input name="FriendLinkIsLogo" type="checkbox" id="FriendLinkIsLogo" value="1"></td>
		</tr>
		<tr>
			<td height="23" class="td_content">排序：</td>
			<td height="23" class="td_content"><input name="Px" type="text" class="input_1" id="Px" value="<%=contPx%>" size="5"></td>
		</tr>
		<tr>
			<td height="23" class="td_content">网站说明：</td>
			<td height="23" class="td_content"><textarea name="FriendLinkSiteNote" cols="60" rows="8" class="input_1" id="FriendLinkSiteNote"></textarea></td>
		</tr>
		<tr>
			<td height="23" class="td_content">&nbsp;</td>
			<td height="23" class="td_content"><input name="Submit" type="submit" class="input_1" value=" 添  加 "> &nbsp;
			<input name="Submit" type="reset" class="input_1" value=" 重  置 "></td>
		</tr>
	</table>
</form>
</body>
</html>
