<!--#include file="../conn.asp"-->
<!--#include file="../config.asp"-->
<!--#include file=cookies.asp-->
<%
'=====================================
'天天供求信息网站管理系统
'天天网络科技工作室出品
'客服中心:http://www.ip126.com
'微信公众号:ip126com
'QQ:530051328 mail:bbfhq@163.com
'=====================================
%>
<%call checkmanage("13")%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>COAD System</title>
<link href="../css/style.css" rel="stylesheet" type="text/css">
<script language=javascript src=../Include/mouse_on_title.js></script>
<SCRIPT LANGUAGE="JavaScript" src="images/js.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" src="images/Time_selector.js"></SCRIPT>
<style type="text/css">
<!--
body {
	background-color: #F7F3F7;
}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
//网站logo上传
function JM_wu(ob){
 ob.style.display="none";
}
function JM_you(ob){
 ob.style.display="";
}
function uppic(model,frmname) {
//确定上传文件名，可选用下面与表单结合判断编号并以编号命名
id=document.form.ADID.value;
id1=document.form.city_one.value;
id2=document.form.city_two.value;
id3=document.form.city_three.value;
if (id1=='') id1=0
if (id2=='') id2=0
if (id3=='') id3=0
if (id=='') {
 alert("请先填写广告ID号！");
 document.form.ADID.focus();
return false;}
window.open("../ads/DNJY_upload_ad.asp?ttup=adv&fupname="+id+model+"_"+id1+"_"+id2+"_"+id3+"&frmname="+frmname,"blank_","scrollbars=yes,resizable=no,top=40,left=150,width=500,height=150")
}

function CheckAll(form) {
 for (var i=0;i<form.elements.length;i++) {
 var e = form.elements[i];
 if (e.name != 'chkall') e.checked = form.chkall.checked; 
 }
 }
</script>
<style type="text/css">
<!--
.style1 {color: #FFFFFF;
	font-weight: bold;
}
-->
</style>

</head>

<body>
<%Set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * FROM [DNJY_ad]"
rs.open sql,conn,1,1
If rs.bof or rs.eof Then
Response.Write "默认代码方式广告不存在不能添加新广告，请先<a href=""../ads/Leading_in_out.asp"" TARGET=right><font color=""#0000ff"">导入默认代码方式广告</FONT></a>！"
set rs=nothing
conn.Close
set conn=nothing
Response.End
End If

Dim ADLink
ADLink=DangerEncode(Request.Form("ADLink"))
If Left(ADLink,7)<>"http://" Then ADLink="http://"+ADLink
if Request.Form("AddAD")<> "" Then
Dim city_oneid,city_twoid,city_threeid
city_oneid=TRIM(Request.Form("city_one"))
city_twoid=TRIM(Request.Form("city_two"))
city_threeid=TRIM(Request.Form("city_three"))
If city_oneid="" Then city_oneid=0
If city_twoid="" Then city_twoid=0
If city_threeid="" Then city_threeid=0
Call OpenConn
'加入数据
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from [DNJY_ad] where ADID='"&DangerEncode(Request.Form("ADID"))&"' and city_oneid="&city_oneid&" and city_twoid="&city_twoid&" and city_threeid="&city_threeid&""
rs.Open sql,conn,1,3
If not rs.eof Then
	Response.Write ("<script>alert(' 操作错误! \n\n 本地区广告ID重复,请使用其他ID!');history.back();</script>")
	Call CloseRs(rs)
	Call CloseDB(conn)
	Response.end
End iF
rs.AddNew 
rs("ADID")=DangerEncode(Request.Form("ADID"))
rs("ADType")=TRIM(Request.Form("ADType"))
rs("ADSrc")=DangerEncode(Request.Form("ADSrc"))
If TRIM(Request.Form("ADHeight"))<>"" Then rs("ADHeight")=TRIM(Request.Form("ADHeight"))
If TRIM(Request.Form("ADWidth"))<>"" Then rs("ADWidth")=TRIM(Request.Form("ADWidth"))
rs("ADLink")=ADLink
rs("ADAlt")=DangerEncode(Request.Form("ADAlt"))
rs("ADStopViews")=TRIM(Request.Form("ADStopViews"))
rs("ADStopHits")=TRIM(Request.Form("ADStopHits"))
rs("ADStopDate")=TRIM(Request.Form("ADStopDate"))
rs("ADNote")=TRIM(Request.Form("ADNote"))
rs("ADjs")=TRIM(Request.Form("ADjs"))
rs("ADkg")=TRIM(Request.Form("ADkg"))
rs("city_oneid")=city_oneid
rs("city_twoid")=city_twoid
rs("city_threeid")=city_threeid
rs("adsjs")=""&DangerEncode(Request.Form("ADID"))&"_"&city_oneid&"_"&city_twoid&"_"&city_threeid&".js"
rs("Advertisement_host")=Request.Form("ADhost1")&"|"&Request.Form("ADhost2")&"|"&Request.Form("ADhost3")&"|"&Request.Form("ADhost4")&"|"&Request.Form("ADhost5")&"|"&Request.Form("ADhost6")&"|"&Request.Form("ADhost7")&"|"&Request.Form("ADhost8")&"|"&Request.Form("ADhost9")
rs.Update
rs.Close

set rs=nothing
conn.Close
set conn=nothing
'Response.Write "<script language=JavaScript>" & chr(13) & "alert('添加广告成功！');" & "window.location='list.asp'" & "</script>"
Response.Write "<script language=javascript>setTimeout(""alert('添加广告成功！');" &"location.replace('createjs.asp?page="&request("page")&"&ADID="&DangerEncode(Request.Form("ADID"))&"&city_oneid="&city_oneid&"&city_twoid="&city_twoid&"&city_threeid="&city_threeid&"')"",0)</script>"
end if

Rem 过滤可能出错误的符号
Function DangerEncode(fString)
If not isnull(fString) Then
    fString = Replace(fString, CHR(13), "")
    fString = Replace(fString, CHR(10), "")
	fString = replace(fString, "'", """")
    fString = Trim(fString)
    DangerEncode = fString
End If
End Function
%>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#6699cc">
  <form name=form action=add.asp  method=post onsubmit="return chkinput()">
     <tr align="center" bgcolor="#6699cc">
      <td height="28" colspan="2"><div align="center" ><font color="#FFFFFF"><b>添加新广告</b></font></div></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td width="15%" align="right" bgcolor="#FAFAFA"><div align="center">所属地区：</div></td>
      <td width="500">
<%Call OpenConn
set rs=conn.execute("select * from DNJY_city where id>0 and twoid>0 and threeid=0")%>
          <SCRIPT language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
        <%
	dim count5:count5 = 0
        do while not rs.eof 
        %>
subcat[<%=count5%>] = new Array("<%=rs("city")%>","<%=rs("id")%>","<%=rs("twoid")%>");
        <%
        count5 = count5 + 1
        rs.movenext
        loop
Call CloseRs(rs)
        %>
onecount=<%=count5%>;
          </SCRIPT>
          <%
set rs=conn.execute("select * from DNJY_city where id>0 and twoid>0 and threeid>0")
%>
          <SCRIPT language = "JavaScript">
var onecount4;
onecount4=0;
subcat4 = new Array();
        <%
		dim count4:count4 = 0
        do while not rs.eof 
        %>
subcat4[<%=count4%>] = new Array("<%=rs("city")%>","<%=rs("id")%>","<%=rs("twoid")%>","<%=rs("threeid")%>");
        <%
        count4 = count4 + 1
        rs.movenext
        loop
Call CloseRs(rs)
        %>
onecount4=<%=count4%>;

function changelocation(locationid)
    {
    document.form.city_two.length = 0; 
	document.form.city_two.options[0] = new Option('选择城市','');
	document.form.city_three.length = 0; 
	document.form.city_three.options[0] = new Option('选择城市','');
    var locationid=locationid;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            { 
                document.form.city_two.options[document.form.city_two.length] = new Option(subcat[i][0], subcat[i][2]);
            }        
        }
        
    }    
	
	function changelocation4(locationid,locationid1)
    {
    document.form.city_three.length = 0; 
    document.form.city_three.options[0] = new Option('选择城市','');
    var locationid=locationid;
	 var locationid1=locationid1;
    var i;
    for (i=0;i < onecount4; i++)
        {
            if (subcat4[i][2] == locationid)
            { 
			if (subcat4[i][1] == locationid1)
			{
                document.form.city_three.options[document.form.city_three.length] = new Option(subcat4[i][0], subcat4[i][3]);
            }        
        }
       } 
    }            
              </SCRIPT>
          <SELECT name="city_one" size="1" id="select" onChange="changelocation(document.form.city_one.options[document.form.city_one.selectedIndex].value)">
            <OPTION value="0" selected>选择地区</OPTION>
            <%set rs=conn.execute("select * from DNJY_city where id>0 and twoid=0 order by indexid asc")
if rs.eof or rs.bof then
response.write "<option value='0'>没有分类</option>"
else
do until rs.eof
response.write "<option value='"&rs("id")&"'>"&rs("city")&"</option>"
    rs.movenext
    loop
end if
Call CloseRs(rs)
%>
          </SELECT>
          <SELECT name="city_two" id="select6" onChange="changelocation4(document.form.city_two.options[document.form.city_two.selectedIndex].value,document.form.city_one.options[document.form.city_one.selectedIndex].value)">
            <OPTION value="0" selected>选择城市</OPTION>
          </SELECT>
          <SELECT name="city_three" id="select7">
            <OPTION value="0" selected>选择城市</OPTION>
          </SELECT> 如果不选择地区将显示总站广告</td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td width="15%" align="right" bgcolor="#FAFAFA"><div align="center">广告&nbsp;I&nbsp;D：</div></td>
      <td width="400">
      <INPUT   maxLength=14 size=20 name="ADID"> <font color="#FF0000">*</font>	  
      <input name="Check" type="button" id="Check" value="检查ID号是否存在" onClick="checkreg();"></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td width="15%" align="right" bgcolor="#FAFAFA"><div align="center">广告类型：</div></td>
      <td><select size="1" name="ADType" class="input1" onChange="ChangeType(this.options[this.selectedIndex].value)">
          <option selected value="1">普通图片</option>
          <option value="2">满屏浮动显示</option>
          <option value="3">上下浮动显示-右</option>
          <option value="4">上下浮动显示-左</option>
          <option value="5">全屏幕渐隐消失</option>
          <option value="6">普通网页对话框</option>
          <option value="7">可移动透明对话框</option>
          <option value="8">打开新窗口</option>
          <option value="9">弹出新窗口</option>
          <option value="10">对联式广告（固定）</option>
          <option value="11">对联式广告（浮动）</option>
		  <option value="12">走马灯文字</option>
		  <option value="13">普通文字广告</option>
          <option style="background-color:#F8F4F5 ;color: #FF0000" value="14">自写代码广告</option>
		  <option value="15">Flash图片广告</option>
		  <option value="16">视频广告</option>
		  <option value="17">LED广告</option>
      </select> 若选择“满屏浮动显示”会造成切换城市列表无法弹出！</td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td width="15%" align="right" bgcolor="#FAFAFA" id="adsrc_text"><div align="center">图标地址：</div></td>
      <td height="17"> <input name="ADSrc" type="text"  size="40" maxlength="100">&nbsp;<INPUT alt="请单击“浏览”上传图片<br>或填写图片的网址，如<font color=blue>http://www.ip126.com/adv/mp3.jpg</font><br>或填写站内的图片路径、文件名，如<font color=blue>adv/001.jpg</font>" TYPE="button" value="浏览图片上传" onclick="javascript:uppic('','ADSrc');"> <a href="#" onclick=openhelp("ext") title="点击查看帮助"><font color="#0000FF">上传普通图片、FLASH图片</font></a>，或填写视频文件地址 <a href="javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'" title="点此查看视频格式要求"><font color="#FF0000">[视频广告添加说明]</font></a></td>
    </tr>
	<!--弹出页面内容开始-->
<div id="light" class="white_content">
<div class="white_content_top"><span class="white_content_top_span1">视频广告添加说明</span><span class="white_content_top_span2"><a href="javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">关闭</a></span></div><span class="fRed">&nbsp;&nbsp;&nbsp;&nbsp;1、视频文件地址添加有两种方法：一是相对路径，视频文件放在本服务器，地址形式如/ads/pic/abc.wmv；二是绝对路径，视频文件可放在本服务器，也可远程，地址形式为http://www.abc.com/video/abc.wmv。<br>&nbsp;&nbsp;&nbsp;&nbsp;2、视频一般较大，如果放在本服务器不宜直接上传，可用FTP上传到/ads/pic目录下。<br>&nbsp;&nbsp;&nbsp;&nbsp;3、视频广告要求电脑必须安装Windows Media Player 9.0以上版本播放器才能正常播放（一般xp及以上版本操作系统都具备）。<br>&nbsp;&nbsp;&nbsp;&nbsp;4、视频格式兼容：wmv，mpg，avi,rmvb等，建议wmv格式文件体积小些。</div>
<div id="fade" class="black_overlay"></div>
<!--弹出页面内容结束-->
    <tr bgcolor="#FFFFFF">
      <td width="15%" align="right" bgcolor="#FAFAFA"><div align="center">图片规格：</div></td>
      <td height="17"><INPUT name=ADWidth type="text" class="input1" onkeypress="return Num();" value="468" size=8 maxlength=4>
        ×
      <INPUT name=ADHeight type="text" class="input1" onkeypress="return Num();" value="60" size=8 maxlength=4> 图片(Flash)宽高|弹窗宽高|视频广告宽高|LED广告宽高|前一框填走马灯类型广告文字滚动速度，一般填5</td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td width="15%" align="right" bgcolor="#FAFAFA"><div align="center">链接地址：</div></td>
      <td height="17"><INPUT name=ADLink type="text" class="input1" size=30 maxlength=100> 链接地址|弹窗链接地址|走马灯文字链接地址</td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td width="15%" align="right" bgcolor="#FAFAFA"><div align="center">提示文字：</div></td>
      <td height="17"><INPUT name=ADAlt type="text" class="input1" size=30 maxlength=50> 鼠标悬停提示|走马灯类型广告文字|普通文字类型广告文字|LED广告文字</td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td width="15%" height="25" align="right" bgcolor="#FaFaFa"><div align="center">自写代码：</div></td>
      <td><textarea name="ADjs" cols="70" rows="8" id="ADjs"></textarea></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td width="15%" align="right" bgcolor="#FAFAFA"><div align="center">投放限制：</div></td>
      <td height="18"><INPUT name=ADStopViews type="text" class="input1" onkeypress="return Num();" value="0" size=8 maxlength=10>
        ·
          <INPUT name=ADStopHits type="text" class="input1" onkeypress="return Num();" value="0" size=8 maxlength=10>
        ·<input type="text" name="ADStopDate" style="width:120px;" onclick="setday(this)">        
      <a href="#" onclick=openhelp("stop")> （限制说明－显示·点击·日期？）</a></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td width="15%" align="right" bgcolor="#FAFAFA"><div align="center">简单注释：</div></td>
      <td height="17"><INPUT name=ADNote type="text" class="input1" size=80 maxlength=100>
      备注不显示在广告中</td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td width="15%" height="25" align="right" bgcolor="#FaFaFa"><div align="center">是否活动：</div></td>
      <td>        
                <input type="radio" name="adkg" value="1" id="adkg" checked>
                 活动&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="radio" name="adkg" value="0" id="adkg">
                暂停</td>
                </td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td width="15%" align="right" bgcolor="#FAFAFA"><div align="center">广告主信息：</div></td>
      <td height="17">姓名<INPUT name=ADhost1 type="text" class="input1" size=10 maxlength=30>&nbsp;&nbsp;电话<INPUT name=ADhost2 type="text" class="input1" size=20 maxlength=30>&nbsp;&nbsp;手机<INPUT name=ADhost3 type="text" class="input1" size=20 maxlength=30>&nbsp;&nbsp;腾讯QQ<INPUT name=ADhost4 type="text" class="input1" size=20 maxlength=30>&nbsp;&nbsp;邮箱<INPUT name=ADhost5 type="text" class="input1" size=30 maxlength=30><br>地址<INPUT name=ADhost6 type="text" class="input1" size=38 maxlength=30>&nbsp;&nbsp;邮编<INPUT name=ADhost7 type="text" class="input1" size=20 maxlength=30>&nbsp;&nbsp;广告费<INPUT name=ADhost8 type="text" class="input1" size=17 maxlength=30> 元&nbsp;&nbsp;备注<INPUT name=ADhost9 type="text" class="input1" size=30 maxlength=30></td>
    </tr>	
    <tr bgcolor="#eeeeee">
      <td height="25" colspan="2" align="center">        <table width="100%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="35"><div align="center">
              <input name="AddAD" type="submit" class="input1" value="确定添加">
            </div></td>
            <td height="35"><div align="center">
              <input name="AddAD" type="reset" class="input1" value="取消添加">
            </div></td>
          </tr>
        </table>
      </td>
    </tr>
  </form>
</table>
<br>
</body>
</html>
        <form name='reg' action='regid.asp' method='post' target='CheckReg'>
		<input type='hidden' name='ADID' value=''> 
		<input type='hidden' name='city_one' value=''>
		<input type='hidden' name='city_two' value=''>
		<input type='hidden' name='city_three' value=''>
        </form>
      <script language=javascript>
function checkreg()
{
  if (document.form.ADID.value=="")
	{
	alert("请输入广告ID号！");
	document.form.ADID.focus();
	return false;
	}
  else
    {
	document.reg.ADID.value=document.form.ADID.value;
	document.reg.city_one.value=document.form.city_one.value;
	document.reg.city_two.value=document.form.city_two.value;
	document.reg.city_three.value=document.form.city_three.value;
	var popupWin = window.open('regid.asp', 'CheckReg', 'scrollbars=no,width=300,height=100');
	document.reg.submit();
	}
}
</script>