<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../../conn/conn.asp" -->
<!--#include file="../../Inc/Commoncode.asp" -->
<!--#include file="../checkvalid.asp" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>广告添加</title>
<link href="../css/style<%=sk%>.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../inc/input.js"></script>
<script type="text/javascript" src="../../Js/Calendar.js"></script>
</head>
<script language="javascript">
<!--
function opw(url,name, width, height)
{ //v2.0
	window.open(url,name,''+'width='+width+',height='+height+',scrollbars=yes'+'');
}
function checkad()
{
	if(document.adform.Ad_sitename.value=="")
	{
		alert("请输入中文站名!");
		document.adform.Ad_sitename.focus();
		return false;
	}
	if(document.adform.Ad_contactman.value=="")
	{
		alert("请输入客户姓名!");
		document.adform.Ad_contactman.focus();
		return false;
	}
	if(document.adform.Ad_siteurl.value=="")
	{
		alert("请输入链接地址!");
		document.adform.Ad_siteurl.focus();
		return false;
	}	
	if(document.adform.Ad_pic.value=="")
	{
		alert("请上传广告图片或者flash文件!");
		return false;
	}
}
function checkad1()
{
	if(document.adform1.placeid.value=="选择大类")
	{
		alert("请选择广告类别!");
		return false;
	}
	if(document.adform1.priceid.value=="选择小类")
	{
		alert("请选择广告类别!");
		return false;
	}
}
function getsort(typeid)
{
	document.frames["typeframe"].location.replace("admin_websort.asp?typeid="+typeid);
}
//-->
</script>
<%
If Not FRAdminLevel(106) Then
	Call ErrorMsg()
End If
%>
<body>
<iframe height=0 width=0 src="" id="typeframe"></iframe>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="tableBorder">
  <tr>
    <th height="25">广告管理</th>
  </tr>
  <tr>
    <td height=25><span class="bodytitle"><font color="ff6600"><b class="style1">　管理选项</b></font>：</span><a href="webad.asp" target="_self">添加广告</a> | <a href="list.asp" target="_self">正常广告</a> | <a href="list.asp?type=top" target="_self">点击最高</a> | <a href="list.asp?type=end" target="_self">点击最低</a> | <a href="list.asp?type=close" target="_self">暂停列表</a> | <a href="list.asp?type=lose" target="_self">失效列表</a> | <a href="adplace.asp" target="_self">广告管理</a></td>
  </tr>
</table>
<%
step=request.QueryString("step")
if step=2 then
	Call AddTwo()
elseif step=4 then
	Call SaveTwo()
elseif step=3 then
	Call SaveOne()
else
	Call AddOne()
end if
%>
<%
Sub AddOne()
adid=request.QueryString("adid")
if adid<>"" then
	sqlm="select Ad_priceid,Ad_placeid from JOB_Ad where Ad_id="&adid&""
	set rsm=Server.CreateObject(FR_HR_RS)
	rsm.open sqlm,conn,1,1
	if not rsm.eof then
		placeid=rsm("Ad_placeid")
		priceid=rsm("Ad_priceid")
	end if
	rsm.close
	set rsm=nothing
end if
%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="tableBorder mt6">
  <tr>
    <th>选择广告类别</th>
  </tr>
<form name="adform1" method="post" action="webad.asp?step=2&adid=<%=adid%>" onsubmit="return checkad1();">
  <tr>
    <td align="center">选择大类：
      <select name="placeid" onChange="javascript:getsort(this.options[this.selectedIndex].value);">
	  <%if adid="" then%>
		<option value="选择大类" selected>选择大类</option>
		<%else%>
		<option value="<%=placeid%>" selected><%=AdplaceNames(placeid)%></option>
		<%end if%>
	  <%
	  set rs=Server.CreateObject(FR_HR_RS)
	  sql="select adplace_id,adplace_name from JOB_Adplace where projectid="&DefaultTPID&" order by adplace_id asc"
	  rs.open sql,conn,1,1
	  if not rs.eof then
	  	for i=1 to rs.recordcount
	  %>
	  <option value="<%=rs("adplace_id")%>"><%=rs("adplace_name")%></option>
	  <%
	  	rs.movenext
		next
	  end if
	  rs.close
	  set rs=nothing
	  %>
    </select>
     &nbsp;选择小类： 
	 <span id="load200"></span><span id="producttypes"><select name="priceid">
	   <%if adid="" then%>
		<option value="选择小类" selected>选择小类</option>
		<%else%>
		<option value="<%=priceid%>" selected><%=AdpriceNames(priceid)%></option>
		<%end if%>
		</select>
	 </span>&nbsp;<input name="Submit4" type="submit" class="inputs" value="提交" /></td>
  </tr>
</form>
</table>
<%
End Sub
%>
<%
Sub AddTwo()
adid=request.QueryString("adid")
placeid=request("placeid")
priceid=request("priceid")
if adid<>"" then
	sqlm="select * from JOB_Ad where Ad_id="&adid&""
	set rsm=Server.CreateObject(FR_HR_RS)
	rsm.open sqlm,conn,1,1
	if not rsm.eof then
		Ad_sitename=rsm("Ad_sitename")
		Ad_siteurl=rsm("Ad_siteurl")
		Ad_contactman=rsm("Ad_contactman")
		Ad_tel=rsm("Ad_tel")
		adwidth=rsm("Ad_width")
		Ad_pic=rsm("Ad_pic")
		Ad_target=rsm("Ad_target")
		Ad_type=rsm("Ad_type")
		Ad_act=rsm("Ad_act")
		Ad_enddate=rsm("Ad_enddate")
		Ad_click=rsm("Ad_click")
		Ad_show=rsm("Ad_show")
		Ad_other=rsm("Ad_other")
	end if
	rsm.close
	set rsm=nothing
else
	sql="select Adsplace_width from JOB_Adsplace where Adsplace_id="&priceid&""
	set rs=server.CreateObject(FR_HR_RS)
	rs.open sql,conn,1,1
	if not rs.eof then
		adwidth=rs("Adsplace_width")
	end if
	rs.close
	set rs=nothing
end if
%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="tableBorder" style="margin-top:6px;">
  <tr>
    <th colspan="2">添加广告</th>
  </tr>
<form name="adform" method="post" action="webad.asp?step=4&placeid=<%=placeid%>&priceid=<%=priceid%>&adid=<%=adid%>&oldpic=<%=Ad_pic%>" onsubmit="return checkad();">
  <tr>
    <td width="19%" align="right">广告类型：</td>
    <td width="81%"><input name="adtype" type="radio" class="checkbox" value="pic" checked="checked" /> 图片 <input name="adtype" type="radio" class="checkbox" value="flash" <%if Ad_type="flash" then%>checked="checked"<%end if%> /> flash</td>
  </tr>
  <tr>
    <td align="right">广告位置：</td>
    <td>&nbsp;<font color="#0000FF"><%=AdplaceNames(placeid)%>--<%=AdpriceNames(priceid)%></font></td>
  </tr>
  <tr>
    <td align="right">中文站名：</td>
    <td><input name="Ad_sitename" type="text" size="40" value="<%=Ad_sitename%>" /> <span class="f00">*</span> 不超过15个中文或30个字母数字</td>
  </tr>
  <tr>
    <td align="right">客户姓名：</td>
    <td><input name="Ad_contactman" type="text" size="40" value="<%=Ad_contactman%>" /> <span class="f00">*</span> 不超过15个中文或30个字母数字</td>
  </tr>
  <tr>
    <td align="right">联系方式：</td>
    <td><input name="Ad_tel" type="text" size="40" value="<%=Ad_tel%>" /></td>
  </tr>
  <tr>
    <td align="right">链接地址：</td>
    <td><input name="Ad_siteurl" type="text" size="40" value="<%=Ad_siteurl%>" /> <span class="f00">*</span> </td>
  </tr>
  <tr>
    <td align="right">广告图片或flash：</td>
    <td><input name="Ad_pic" type="text" size="40" value="<%=Ad_pic%>" readonly onClick="javascript:opw('../inc/job_up.asp?fromForm=adform&fromEdit=Ad_pic&saveTo=../../Adpic/<%=TemplateDir%>/&showPath=','adpic',420,165)" /> <span class="f00">*</span> <input name="Submit" type="button" class="inputs" value="上传图片" onClick="javascript:opw('../inc/job_up.asp?fromForm=adform&fromEdit=Ad_pic&saveTo=../../Adpic/<%=TemplateDir%>/&showPath=','adpic',420,165)" /> </td>
  </tr>
  <tr>
    <td align="right">广告大小：</td>
    <td><input name="ad_width" type="text" value="<%=adwidth%>" size="8" readonly /> 如需修改请直接修改广告位的大小即同时修改</td>
  </tr>
  <tr>
    <td align="right">打开方式：</td>
    <td><select name="Ad_target">
      <option value="_blank" selected="selected">新窗口</option>
      <option value="_self" <%if Ad_target="_self" then%>selected="selected"<%end if%>>原窗口</option>
    </select>    </td>
  </tr>
  <tr>
    <td align="right">播放条件：</td>
    <td>受多个条件限制的广告，只要有一个条件满足，该广告便自动进入休眠状态，你可以修改限制条件并激活广告。</td>
  </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td><input name="class" type="radio" class="checkbox" value="0" checked="checked"> 无限制循环</td>
  </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td><input name="class" type="radio" class="checkbox" value="1" <%if Ad_act=1 then%>checked="checked"<%end if%>> 点击数不超过 <input type="text" name="Ad_click1" size="8" <%if Ad_act=1 then%>value="<%=Ad_click%>"<%end if%>>
      &nbsp;&nbsp;&nbsp; * 请填写数字 </td>
  </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td><input name="class" type="radio" class="checkbox" value="2" <%if Ad_act=2 then%>checked="checked"<%end if%>> 显示数不超过 <input type="text" name="Ad_show1" size="8" <%if Ad_act=2 then%>value="<%=Ad_show%>"<%end if%>>
&nbsp;&nbsp;&nbsp; * 请填写数字</td>
  </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td><input name="class" type="radio" class="checkbox" value="3" <%if Ad_act=3 then%>checked="checked"<%end if%>> 显示截止期为 <input type="text" name="Ad_enddate1" onClick="ShowCalendar(this.id)" <%if Ad_act=3 then%>value="<%=Ad_enddate%>"<%end if%> size="10" readonly />
&nbsp; * 请选择日期</td>
  </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabnoboder">
      <tr>
        <td width="4%" align="left"><input name="class" type="radio" class="checkbox" value="4" <%if Ad_act=4 then%>checked="checked"<%end if%>></td>
        <td width="96%">点击数不超过 <input type="text" name="Ad_click2" <%if Ad_act=4 then%>value="<%=Ad_click%>"<%end if%> size="8" />
&nbsp;&nbsp;&nbsp; * 请填写数字</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>显示数不超过 <input type="text" name="Ad_show2" <%if Ad_act=4 then%>value="<%=Ad_show%>"<%end if%> size="8">
&nbsp;&nbsp;&nbsp; * 请填写数字</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabnoboder">
      <tr>
        <td width="4%" align="left"><input name="class" type="radio" class="checkbox" value="5" <%if Ad_act=5 then%>checked="checked"<%end if%>></td>
        <td width="96%">点击数不超过 <input type="text" name="Ad_click3" <%if Ad_act=5 then%>value="<%=Ad_click%>"<%end if%> size="8" />
&nbsp;&nbsp;&nbsp; * 请填写数字</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>显示截止期为 <input type="text" name="Ad_enddate2" <%if Ad_act=5 then%>value="<%=Ad_enddate%>"<%end if%> onClick="ShowCalendar(this.id)" size="10" readonly />
          &nbsp; * 请选择日期</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabnoboder">
      <tr>
        <td width="4%" align="left"><input name="class" type="radio" class="checkbox" value="6" <%if Ad_act=6 then%>checked="checked"<%end if%>></td>
        <td width="96%">显示数不超过 <input type="text" name="Ad_show3" <%if Ad_act=6 then%>value="<%=Ad_show%>"<%end if%> size="8">
&nbsp;&nbsp;&nbsp; * 请填写数字</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>显示截止期为 <input type="text" name="Ad_enddate3" <%if Ad_act=6 then%>value="<%=Ad_enddate%>"<%end if%> onClick="ShowCalendar(this.id)" size="10" readonly />
        &nbsp; * 请选择日期</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabnoboder">
      <tr>
        <td width="4%" align="left"><input name="class" type="radio" class="checkbox" value="7" <%if Ad_act=7 then%>checked="checked"<%end if%>></td>
        <td width="96%">点击数不超过 <input type="Ad_click4" <%if Ad_act=7 then%>value="<%=Ad_click%>"<%end if%> name="clicks4" size="8" />
&nbsp;&nbsp;&nbsp; * 请填写数字</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>显示数不超过 <input type="text" name="Ad_show4" <%if Ad_act=7 then%>value="<%=Ad_show%>"<%end if%> size="8">
&nbsp;&nbsp;&nbsp; * 请填写数字</td>
      </tr>
	  <tr>
        <td>&nbsp;</td>
        <td>显示截止期为 <input type="text" name="Ad_enddate4" <%if Ad_act=7 then%>value="<%=Ad_enddate%>"<%end if%> onClick="ShowCalendar(this.id)" size="10" readonly />
        &nbsp; * 请选择日期</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td align="right">备&nbsp;&nbsp;&nbsp; 注：</td>
    <td><textarea name="Ad_other" cols="60" rows="4"><%=Ad_other%></textarea></td>
  </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td> &nbsp;
      <input name="Submit2" type="submit" class="inputs" value="提交" /> 
     &nbsp; <input name="Submit3" type="reset" class="inputs" value="重置" /></td>
  </tr>
</form>
</table>
<%
End Sub
%>
<%
Sub SaveTwo()
	adid=request.QueryString("adid")
	Ad_sitename=request.Form("Ad_sitename")
	Ad_siteurl=request.Form("Ad_siteurl")
	Ad_contactman=request.Form("Ad_contactman")
	Ad_tel=request.Form("Ad_tel")
	Ad_width=request.Form("Ad_width")
	Ad_pic=request.Form("Ad_pic")
	Ad_type=request.Form("adtype")
	Ad_act=request.Form("class")
	Ad_target=request.Form("Ad_target")
	Ad_enddate1=request.Form("Ad_enddate1")
	Ad_enddate2=request.Form("Ad_enddate2")
	Ad_enddate3=request.Form("Ad_enddate3")
	Ad_enddate4=request.Form("Ad_enddate4")
	Ad_click1=request.Form("Ad_click1")
	Ad_click2=request.Form("Ad_click2")
	Ad_click3=request.Form("Ad_click3")
	Ad_click4=request.Form("Ad_click4")
	Ad_show1=request.Form("Ad_show1")
	Ad_show2=request.Form("Ad_show2")
	Ad_show3=request.Form("Ad_show3")
	Ad_show4=request.Form("Ad_show4")
	Ad_other=request.Form("Ad_other")	
	Ad_placeid=request.QueryString("placeid")
	Ad_priceid=request.QueryString("priceid")
	oldpic=request.QueryString("oldpic")
	projectid=DefaultTPID
	
	'添加广告
	if adid="" then
		sql1="Insert into JOB_Ad(Ad_sitename,Ad_siteurl,Ad_contactman,Ad_tel,Ad_width,Ad_pic,Ad_target,Ad_type,Ad_act,Ad_other,projectid,Ad_placeid,Ad_priceid,Ad_addtime"
		sql2="values('"&Ad_sitename&"','"&Ad_siteurl&"','"&Ad_contactman&"','"&Ad_tel&"','"&Ad_width&"','"&Ad_pic&"','"&Ad_target&"','"&Ad_type&"','"&Ad_act&"','"&Ad_other&"','"&projectid&"','"&Ad_placeid&"','"&Ad_priceid&"','"&now()&"'"
		select case Ad_act
			'播放条件为无限制循环
			case "0"			
				sql=sql1&") "&sql2&")"
			'播放条件为点击数不超过
			case "1"
				sql=sql1&",Ad_click) "&sql2&",'"&Ad_click1&"')"				
			'播放条件为显示数不超过	
			case "2"
				sql=sql1&",Ad_show) "&sql2&",'"&Ad_show1&"')"			
			'播放条件为显示截止期为	
			case "3"
				sql=sql1&",Ad_enddate) "&sql2&",'"&Ad_enddate1&"')"			
			'播放条件为点击数不超过,显示数不超过	
			case "4"
				sql=sql1&",Ad_click,Ad_show) "&sql2&",'"&Ad_click2&"','"&Ad_show2&"')"			
			'播放条件为点击数不超过,显示截止期为
			case "5"
				sql=sql1&",Ad_click,Ad_enddate) "&sql2&",'"&Ad_click3&"','"&Ad_enddate2&"')"			
			'播放条件为显示数不超过,显示截止期为
			case "6"
				sql=sql1&",Ad_show,Ad_enddate) "&sql2&",'"&Ad_show3&"','"&Ad_enddate3&"')"			
			'播放条件为点击数不超过,显示数不超过,显示截止期为
			case "7"
				sql=sql1&",Ad_click,Ad_show,Ad_enddate) "&sql2&",'"&Ad_click4&"','"&Ad_show4&"','"&Ad_enddate4&"')"			
		end select
	else
	'修改广告
		'先判断图片是否修改了，修改则删除原来的图片
		if StrComp(Ad_pic,oldpic)<>0 then
			oldpicpath="../../adpic/"&TemplateDir&"/"&oldpic
			call DoDelFile(oldpicpath)
		end if
		
		sql1="update JOB_Ad set Ad_sitename='"&Ad_sitename&"',Ad_siteurl='"&Ad_siteurl&"',Ad_contactman='"&Ad_contactman&"',Ad_tel='"&Ad_tel&"',Ad_width='"&Ad_width&"',Ad_pic='"&Ad_pic&"',Ad_target='"&Ad_target&"',Ad_type='"&Ad_type&"',Ad_act='"&Ad_act&"',Ad_other='"&Ad_other&"',Ad_placeid='"&Ad_placeid&"',Ad_priceid='"&Ad_priceid&"'"
		sql2=" where Ad_id="&adid&" and projectid="&DefaultTPID&""
		select case Ad_act
			'播放条件为无限制循环
			case "0"			
				sql=sql1&sql2
			'播放条件为点击数不超过
			case "1"
				sql=sql1&",Ad_click='"&Ad_click1&"'"&sql2
			'播放条件为显示数不超过	
			case "2"
				sql=sql1&",Ad_show='"&Ad_show1&"'"&sql2	
			'播放条件为显示截止期为	
			case "3"
				sql=sql1&",Ad_enddate='"&Ad_enddate1&"'"&sql2	
			'播放条件为点击数不超过,显示数不超过	
			case "4"
				sql=sql1&",Ad_click='"&Ad_click2&"',Ad_show='"&Ad_show2&"'"&sql2	
			'播放条件为点击数不超过,显示截止期为
			case "5"
				sql=sql1&",Ad_click='"&Ad_click3&"',Ad_enddate='"&Ad_enddate2&"'"&sql2			
			'播放条件为显示数不超过,显示截止期为
			case "6"				
				sql=sql1&",Ad_show='"&Ad_show3&"',Ad_enddate=,'"&Ad_enddate3&"'"&sql2		
			'播放条件为点击数不超过,显示数不超过,显示截止期为
			case "7"				
				sql=sql1&",Ad_click='"&Ad_click4&"',Ad_show='"&Ad_show4&"',Ad_enddate='"&Ad_enddate4&"'"&sql2	
		end select		
	end if
	conn.execute(sql)
	if adid="" then
		response.Write("<script>alert(""添加广告成功!"");location.href=""list.asp"";</script>")
	else
		response.Write("<script>alert(""修改广告成功!"");location.href=""list.asp"";</script>")
	end if
	response.End()	
End Sub
%>
<!--#include file="../inc/copy.asp"-->
</body>
</html>