<!-- #Include File="Include/AMH_Onlogin.asp" -->
<%
'=======================================================
' 欢迎使用《阿赛大型门户网站系统V2.0》，简称“AsaiMHV2”
' 技术支持、商业版咨询、官方唯一指定联系QQ“4941172”
' 官方网站：http://77ya.com      程序负责人：阿赛
'=======================================================

Index_Url="ads"
pageurl="?"
call AMH_master(0,0)
Call AMH_Header(1)
%>
<SCRIPT language=javascript>
function SetAdtype(stype)
{
	if(stype==1){
		document.getElementById('adtype_1').style.display = '';
		document.getElementById('adtype_0').style.display = 'none';
		}
	else{
		document.getElementById('adtype_0').style.display = '';
		document.getElementById('adtype_1').style.display = 'none';
		}
}
function Setcloseads(stype)
{
	if(stype==1){
		document.getElementById('closeads_1').style.display = '';
		document.getElementById('closeads_0').style.display = 'none';
		}
	else{
		document.getElementById('closeads_0').style.display = '';
		document.getElementById('closeads_1').style.display = 'none';
		}
}
function SetCodeNote(stype)
{
	if(stype==1){
		document.getElementById('CodeNote_1').style.display = '';
		document.getElementById('CodeNote_0').style.display = 'none';
		}
	else{
		document.getElementById('CodeNote_0').style.display = '';
		document.getElementById('CodeNote_1').style.display = 'none';
		}
}
function setting()
{
	if(document.getElementById('ADSetting(0)').selectedIndex!='0')
	{
		document.getElementById('Adsetting_h').style.display = '';
	}
	else
	{
		document.getElementById('Adsetting_h').style.display = 'none';
	}
}
</script>
<tr><td align=center colspan=2 height=30>
  <table border=0>
  <tr>
  <td><a href='?action='<%if action="pic" then response.write " class=red"%>><%response.write tit%></a></td>
  <td width=10></td>
  <td><a href='?Action=add'<%If Action="add" Then Response.Write " class=red"%>>添加<%Response.Write tit_fir%></a></td>
  </tr>
  </table>
</td></tr>
<%
call AMH_table(1)
  if action="handle" then call AsaiMHChk_Handle()
  select case action
  case "view"
    call AsaiMHChk_View()
  case "edit"
    call AsaiMHChk_Edit()
  case "add"
    call AsaiMHChk_Add()
  case else
    call AsaiMHChk_Main()
  end select
Call AMH_Ender(tit)

sub AsaiMHChk_Handle()
  dim sel_id,hdim,hnum,hid,hi
  sel_id=trim(request.form("sel_id"))
  sel_id=replace(sel_id," ","")
  hdim=split(sel_id,",")
  hnum=ubound(hdim)
  for hi=0 to hnum
    hid=hdim(hi)
    if isnumeric(hid) then
      sql="select top 1 ADName from AsaiMHAds where aid="&hid
      set rs=Cls.exec(sql,1)
      Dim TmpCls
			Set TmpCls = New Cls_FileSystem
        if not rs.eof then Call TmpCls.Del_File(Cls.Web_Dir &"Ads/"&rs(0)&".js")
			Set TmpCls = Nothing
      rs.close
      call Cls.exec("delete from AsaiMHAds where aid="&hid,0)
    end if
  next
  erase hdim
  action=""
  call AMH_event("删除 "&(hnum+1)&" 条 "&tit_fir)
  Call AMH_Msg("已成功删除了 "&(hnum+1)&" 条 "&tit_fir&"！",pageurl,1)
end sub

sub AsaiMHChk_Edit
  	sql="select top 1 * from AsaiMHAds where aid="&id
  	call Cls.exec("",-1)
  	rs.open sql,conn,1,3
  	if rs.eof then
   	 rs.close
    	 call AMH_msg(tit_fir&"（ID："&id&"）不在存！",pageurl,1)
    	 exit sub
 	end if
  	Dim ADType,AdName,AdLinkUrl,AdIntro,AdImgUrl,ImgWidth,ImgHeight,IsFlash,CloseAds,CodeNote
	Dim ADSetting,sADSetting,sPopleft,sPoptop
  	call AMH_td("编辑"&tit_fir)
	AdSetting=split(rs("ADSetting"),"|")
  	If chk() then
	If Not Isnumeric(ADType) then AdType=0
	ADType=Clng(ADType)
	If ADType=0 then
		AdImgUrl=trim(request("AdImgUrl"))
		If Cls.Is_Null(AdName)="" then
		      	call AMH_error(tit_fir&"<br /><li>广告代码不能为空！</li>")
		End If
		If Cls.Is_Null(AdImgUrl)="" then
		      	call AMH_error(tit_fir&" <br /><li>广告图片不能为空！</li>")
		End If
		If (not(isnumeric(ImgWidth)) or not(isnumeric(ImgHeight))) then
      			call AMH_error(tit_fir&" 宽 和 高  只能为数字！")
      		exit sub
    		End if
		If Not IsNumeric(ADSetting) then ADSetting=0
		ADSetting=Cint(ADSetting)
		If ADSetting<0 or ADSetting>3 then ADSetting=0
		If Not Isnumeric(sPopleft) then sPopleft=10
		If Not Isnumeric(sPoptop) then sPoptop=10
		ADSetting=ADSetting&"|"&sPopleft&"|"&sPoptop
	Else
		If Cls.Is_Null(AdName)="" then
		      	call AMH_error(tit_fir&"<br /><li>广告代码不能为空！</li>")
		End If
		AdImgUrl=trim(request("ADCode"))
		If Cls.Is_Null(AdImgUrl)="" then
		      call AMH_error(tit_fir&" <br /><li>广告代码不能为空！</li>")
		End If
		ADSetting="0|0|0"
	End If
    rs.update
    rs.close
    call AsaiMHAds_File(id)
    call AMH_msg("成功编辑一条"&tit_fir,pageurl,1)
    exit sub
  end if
  call form_first()
%>
  <form action='<%response.write pageurl%>action=edit&id=<%response.write id%>' method=post>
  	<input type=hidden name=chk value='yes'>
    <tr>
      <td width='20%'>广告类型：</td>
      <td width='80%'>
		<Input type=radio name=AdType value='0' onclick="SetAdtype('0')" <%If rs("AdType")=0 then%>checked<%End If%>> 图片广告 &nbsp;&nbsp;&nbsp;&nbsp;
		<Input type=radio name=AdType value='1' onclick="SetAdtype('1')" <%If rs("AdType")=1 then%>checked<%End If%>> 代码广告
      </td>
    </tr>
    <tr>
      <td width='20%'>广告状态：</td>
      <td width='80%'>
		<Input type=radio name=closeads value='0' onclick="Setcloseads('0')" <%If rs("closeads")=0 then%>checked<%End If%>> 开放 &nbsp;&nbsp;&nbsp;&nbsp;
		<Input type=radio name=closeads value='1' onclick="Setcloseads('1')" <%If rs("closeads")=1 then%>checked<%End If%>> 关闭
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%Call AMH_Read("","广告状态","广告开关，关闭时自动清除JS文件内容。")%></td>
    </tr>
    <tr>
      <td>广告代码：</td>
      <td>
        <input name=AdName type=text value='<%=rs("AdName")%>' size=58 maxlength=255>
      </td>
    </tr>
    <tr valign=top>
      <td>广告说明：</td>
      <td><textarea name=AdIntro rows=3 cols=65><%=rs("AdIntro")%></textarea>&nbsp;&nbsp;<%Call AMH_Read("","广告说明","简短说明，限250字节，多余部分自动截止。")%></td>
    </tr>
  <table id="adtype_0" width='100%' border=0 align=center cellpadding=2 cellspacing=1 <%If rs("AdType")=1 then%>style="Display:none"<%End If%>>
    <tr>
      <td width='20%'>广告设置：</td>
      <td>
        <table width='100%' border=0 cellspacing=0 cellpadding=0>
          <tr>
            <td width=120>
			<select name=ADSetting(0) onchange="setting()">
			<option value='0' <%If AdSetting(0)=0 then%>selected<%End If%>>不 设 置</option>
			<option value='1' <%If AdSetting(0)=1 then%>selected<%End If%>>弹出广告</option>
			<option value='2' <%If AdSetting(0)=2 then%>selected<%End If%>>浮动广告</option>
			<option value='3' <%If AdSetting(0)=3 then%>selected<%End If%>>页面固定广告</option>
			</select>
            </td>
            <td id="Adsetting_h" <%If AdSetting(0)="0" then%>style="Display:none"<%End If%>>左：<input name=ADSetting(1) type=text value='<%=AdSetting(1)%>' size=6 maxlength=5>&nbsp;&nbsp;上：<input name=ADSetting(2) type=text value='<%=AdSetting(2)%>' size=6 maxlength=5> </td>
          </tr>
        </table></td>
    </tr>
    <tr>
      <td>广告地址：</td>
      <td>
        <input name=AdLinkUrl type=text value='<%=rs("AdLinkUrl")%>' size=58 maxlength=255>
      </td>
    </tr>
    <tr>
      <td>图片地址：</td>
      <td>
        <input name=AdImgUrl type=text size=58 maxlength=255 value='<%If rs("AdType")=0 then Response.write rs("AdImgUrl") End If%>'>
      </td>
    </tr>
    <tr>
      <td>图片大小：</td>
      <td>宽：<input name=ImgWidth type=text value='<%=rs("ImgWidth")%>' size=6 maxlength=5>
        像素&nbsp;&nbsp;&nbsp;&nbsp;高： <input name=ImgHeight type=text value='<%=rs("ImgHeight")%>' size=6 maxlength=5>像素&nbsp;&nbsp;<%Call AMH_Read("","图片大小","留空则取原始大小。<br />弹出广告图片大小不能留空。")%></td>
    </tr>
    <tr>
      <td>是否FLASH：</td>
      <td>
        <input type=radio name=IsFlash value='True' <%If rs("IsFlash")=True then%>checked<%End If%>>
        是&nbsp;&nbsp;&nbsp;&nbsp; <input name=IsFlash type=radio value='False' <%If rs("IsFlash")=False then%>checked<%End If%>>
        否</td>
    </tr>
  </table>
  <table id="adtype_1" width='100%' border=0 align=center cellpadding=2 cellspacing=1 <%If rs("AdType")=0 then%>style="Display:none"<%End If%>>
    <tr valign=top>
      <td width='20%'>函数引用：</td>
      <td width='80%'>
		<Input type=radio name=CodeNote value='0' onclick="SetCodeNote('0')" <%If rs("CodeNote")=0 then%>checked<%End If%>> 加上函数&nbsp;&nbsp;&nbsp;&nbsp;
		<Input type=radio name=CodeNote value='1' onclick="SetCodeNote('1')" <%If rs("CodeNote")=1 then%>checked<%End If%>> 去掉函数
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%Call AMH_Read("","JS函数开关","关闭时自动去掉document.write等函数,及他的引用括号。")%>&nbsp;&nbsp;就是生成JS文件。</td>
    </tr>
    <tr>
      <td width='20%'>广告内容：</td>
      <td><textarea name=ADCode rows=10 cols=65><%If rs("AdType")=1 then Response.write rs("AdImgUrl") End If%></textarea></td>
    </tr>
  </table>
<%
  rs.close
  call submit_edit()
end sub

sub AsaiMHChk_Add()
  dim ADname,AdLinkUrl,AdIntro,AdImgUrl,ImgWidth,ImgHeight,IsFlash,ADType,ADSetting,sADSetting,sPopleft,sPoptop,CloseAds,CodeNote
  call AMH_td("添加"&tit_fir)
  if chk() then
	ADType=Int(request("ADType"))
	AdLinkUrl=Cls.Code_Admin("AdLinkUrl",1,100)
	AdName=Cls.Code_Admin("AdName",1,50)
	AdIntro=Cls.Code_Admin("AdIntro",1,10)
	ImgWidth=trim(request("ImgWidth"))
	ImgHeight=Trim(request("ImgHeight"))
	IsFlash=trim(request("IsFlash"))
	ADSetting=trim(request("ADSetting(0)"))
	sPopleft=trim(request("ADSetting(1)"))
	sPoptop=trim(request("ADSetting(2)"))
	closeads=trim(request("closeads"))
	CodeNote=trim(request("CodeNote"))
	If Not Isnumeric(ADType) then AdType=0
	ADType=Clng(ADType)
	If ADType<>0 then AdType=1
	If ADType=0 then
		AdImgUrl=trim(request("AdImgUrl"))
		If Cls.Is_Null(AdName)="" then
		      	call AMH_error(tit_fir&"<br /><li>广告代码不能为空！</li>")
		End If
		If Cls.Is_Null(AdImgUrl)="" then
		      	call AMH_error(tit_fir&" <br /><li>广告图片不能为空！</li>")
		End If
		If (not(isnumeric(ImgWidth)) or not(isnumeric(ImgHeight))) then
      			call AMH_error(tit_fir&" 宽 和 高  只能为数字！")
      		exit sub
    		End if
		If Not IsNumeric(ADSetting) then ADSetting=0
		ADSetting=Cint(ADSetting)
		If ADSetting<0 or ADSetting>3 then ADSetting=0
		If Not Isnumeric(sPopleft) then sPopleft=10
		If Not Isnumeric(sPoptop) then sPoptop=10
		ADSetting=ADSetting&"|"&sPopleft&"|"&sPoptop
	Else
		If Cls.Is_Null(AdName)="" then
		      	call AMH_error(tit_fir&"<br /><li>广告代码不能为空！</li>")
		End If
		AdImgUrl=trim(request("ADCode"))
		If Cls.Is_Null(AdImgUrl)="" then
		      call AMH_error(tit_fir&" <br /><li>广告代码不能为空！</li>")
		End If
		ADSetting="0|0|0"
	End If
	If AdLinkUrl="" or AdLinkUrl="http://" then AdLinkUrl="Http://77ya.Com"
	If IsFlash<>"True" then
		IsFlash=false
	Else
		IsFlash=True
	End If
	If Not Isnumeric(ImgWidth) then
		ImgWidth=0
	Else
		ImgWidth=Cint(ImgWidth)
	End If
	If Not Isnumeric(ImgHeight) then
		ImgHeight=0
	Else
		ImgHeight=Cint(ImgHeight)
	End If
    sql="select top 1 * from AsaiMHAds where AdName='"&AdName&"'"
    call Cls.exec("",-1)
    rs.open sql,conn,1,3
    if not rs.eof then
      rs.close
      call AMH_error("广告代码（<font class=red>"&ADName&"</font>）已存在！请选用其它的代码。")
      exit sub
    end if
    rs.addnew
    rs("AdIntro")=AdIntro
    rs("ADType")=ADType
	rs("ImgWidth")=ImgWidth
	rs("ImgHeight")=ImgHeight
	rs("AdImgUrl")=AdImgUrl
	rs("IsFlash")=IsFlash
	rs("AdName")=AdName
	rs("AdLinkUrl")=AdLinkUrl
	rs("ADSetting")=ADSetting
	rs("closeads")=closeads
	rs("CodeNote")=CodeNote
    rs.update
    rs.close
    call AsaiMHAds_File(first_id("AsaiMHads","aid"))
    call AMH_msg("成功添加一条新的"&tit_fir,pageurl,1)
    exit sub
  end if
  call form_first()
%>
  <form action='<%response.write pageurl%>action=add' method=post>
  <input type=hidden name=chk value='yes'>
    <tr>
      <td width='20%'>广告类型：</td>
      <td width='80%'>
		<Input type=radio name=AdType value='0' onclick="SetAdtype('0')" checked> 图片广告 &nbsp;&nbsp;&nbsp;&nbsp;
		<Input type=radio name=AdType value='1' onclick="SetAdtype('1')"> 代码广告
      </td>
    </tr>
    <tr>
      <td width='20%'>广告状态：</td>
      <td width='80%'>
		<Input type=radio name=closeads value='0' onclick="Setcloseads('0')" checked> 开放&nbsp;&nbsp;&nbsp;&nbsp;
		<Input type=radio name=closeads value='1' onclick="Setcloseads('1')"> 关闭
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%Call AMH_Read("","广告状态","广告开关，关闭时自动清除JS文件内容。")%></td>
    </tr>
    <tr>
      <td>广告代码：</td>
      <td><input name=ADname type=text value='' size=58 maxlength=255></td>
    </tr>
    <tr valign=top>
      <td>广告说明：</td>
      <td><textarea name=AdIntro rows=3 cols=65></textarea>&nbsp;&nbsp;<%Call AMH_Read("","广告说明","简短说明，限250字节，多余部分自动截止。")%></td>
    </tr>
  <table id="adtype_0" width='100%' border=0 align=center cellpadding=2 cellspacing=1>
    <tr>
      <td width='20%'>广告设置：</td>
      <td>
        <table width='100%' border=0 cellspacing=0 cellpadding=0 id="setable0">
          <tr>
            <td width=120>
			<select name=ADSetting(0) onchange="setting()">
			<option value='0' selected>不 设 置</option>
			<option value='1'>弹出广告</option>
			<option value='2'>浮动广告</option>
			<option value='3'>页面固定广告</option>
			</select>
            </td>
            <td id="Adsetting_h" style="Display:none">左：<input name=ADSetting(1) type=text value='100' size=6 maxlength=5>&nbsp;&nbsp;上：<input name=ADSetting(2) type=text value='100' size=6 maxlength=5></td>
          </tr>
        </table></td>
    </tr>
    <tr>
      <td>广告地址：</td>
      <td>
        <input name=AdLinkUrl type=text value='http://' size=58 maxlength=255>
      </td>
    </tr>
    <tr>
      <td>图片地址：</td>
      <td>
        <input name=AdImgUrl type=text value='../Ads/' size=58 maxlength=255 value=''>
      </td>
    </tr>
    <tr>
      <td>图片大小：</td>
      <td>宽：<input name=ImgWidth type=text size=6 maxlength=5>像素&nbsp;&nbsp;&nbsp;&nbsp;高：<input name=ImgHeight type=text size=6 maxlength=5>像素&nbsp;&nbsp;<%Call AMH_Read("","图片大小","留空则取原始大小。<br />弹出广告图片大小不能留空。")%></td>
    </tr>
    <tr>
      <td>是否FLASH：</td>
      <td><input type=radio name=IsFlash value='True'>是&nbsp;&nbsp;&nbsp;&nbsp; <input name=IsFlash type=radio value='False' checked>否</td>
    </tr>
  </table>
  <table id="adtype_1" width='100%' border=0 align=center cellpadding=2 cellspacing=1 style="DISPLAY: none">
    <tr valign=top>
      <td width='20%'>函数引用：</td>
      <td width='80%'>
		<Input type=radio name=CodeNote value='0' onclick="SetCodeNote('0')"  checked> 加上函数&nbsp;&nbsp;&nbsp;&nbsp;
		<Input type=radio name=CodeNote value='1' onclick="SetCodeNote('1')"> 去掉函数
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%Call AMH_Read("","JS函数开关","关闭时自动去掉document.write等函数,及他的引用括号。")%>&nbsp;&nbsp;就是生成JS文件。</td>
    </tr>
    <tr>
      <td width='20%'>广告内容：</td>
      <td><textarea name=ADCode rows=10 cols=65></textarea></td>
    </tr>
  </table>
<%
  call submit_add()
end sub

sub AsaiMHAds_File(aid)
  	Dim file_name,ADName,atemp,awh,IsFlash,sqlAD,rsAD,sTempAD,sWidth,sHeight,sADid,ShowAD,AdIntro,CloseAds,CodeNote
  	awh=""
	sql="Select AID,AdName,AdLinkUrl,AdImgUrl,ImgWidth,ImgHeight,IsFlash,ADType,ADSetting,AdIntro,CloseAds,CodeNote from AsaiMHAds where AID="&AID
    	set rsAD=Cls.exec(sql,1)
    	closeads=trim(request("closeads")) 
    	CodeNote=trim(request("CodeNote")) 
	if not rsAd.bof and not rsAD.eof then
		sAdID=rsAD(0)
		AdName=rsAD(1)
		if Not IsNumeric(sAdID) then sAdID=1
		sAdID=Clng(sAdID)
	end if
	if rsAd.bof and rsAD.eof then
		if sAdID=1 then
			set rsAD=Cls.Exec("Select Top 1 AID,AdName,AdLinkUrl,AdImgUrl,ImgWidth,ImgHeight,IsFlash,ADType,ADSetting,AdIntro from AsaiMHAds",0)
			if rsAd.bof and rsAD.eof then
				Set rsAD=Nothing
				ShowAD="document.write ('');"
				Exit sub
			end if
		else
			Set rsAD=Nothing
			ShowAD="document.write ('');"
			Exit sub
		end if
	end if
	if rsAd(7)=0 and closeads=0 then
		if Not IsNumeric(sWidth) or sWidth=0 then sWidth=rsAd(4)
		if Not IsNumeric(sHeight) or sHeight=0 then sHeight=rsAd(5)
		if rsAd(6)=true then
			sTempAD= "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://Download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0'"
			if sWidth>0 then sTempAD = sTempAD & " width='" & sWidth & "'"
			if sHeight>0 then sTempAD = sTempAD & " height='" & sHeight & "'"
			sTempAD = sTempAD & "><param name='movie' value='" & rsAd(3) & "'><param name='quality' value='high'><embed src='" & rsAd(3) & "' pluginspage='http://www.macromedia.com/shockwave/Download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash'"
			if sWidth>0 then sTempAD = sTempAD & " width='" & sWidth & "'"
			if sHeight>0 then sTempAD = sTempAD & " height='" & sHeight & "'"
			sTempAD = sTempAD & "></embed></object>"
		else
			'sTempAd = "<a href='" & rsAd(2) & "' target='_blank' title='" & rsAd("AdIntro") & "：" & rsAd(2) & "'><img src='" & rsAd(3) & "'"
			sTempAd = "<a href='" & rsAd(2) & "' target='_blank' title='" & rsAd("AdIntro") & "'><img src='" & rsAd(3) & "'"
			if sWidth>0 then sTempAD = sTempAD & " width='" & sWidth & "'"
			if sHeight>0 then sTempAD = sTempAD & " height='" & sHeight & "'"
			sTempAD = sTempAD & " border='0'></a>"
		end if
		if CodeNote=0 then
		    sTempAD = Replace(sTempAD,vbcrlf,"\n")
		else
		    sTempAD = Replace(sTempAD,vbcrlf,vbcrlf)
		End if
		'sTempAD = Replace(sTempAD,vbcrlf,"\n")
		Dim AdSetting
		AdSetting=split(rsAd(8),"|")
		if Clng(AdSetting(1))=0 then AdSetting(1)=100
		if Clng(AdSetting(2))=0 then AdSetting(2)=100
		Select Case Cint(AdSetting(0))
		Case 0
			ShowAD="document.write (""" & sTempAD & """);"
		Case 1
		ShowAD=ShowAD &vbcrlf& "<!--"
		ShowAD=ShowAD &vbcrlf& "function openad(){"
		ShowAD=ShowAD &vbcrlf& "window.open ('../Common/PopAd.asp?AID="&rsAd(0)&"','popad_"&rsAd(0)&"','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width="&rsAd(4)&",height="&rsAd(5)&",top="&AdSetting(2)&",left="&AdSetting(1)&"')"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "function get_cookie(Name) {"
		ShowAD=ShowAD &vbcrlf& "  var search = Name + '='"
		ShowAD=ShowAD &vbcrlf& "  var returnvalue = '';"
		ShowAD=ShowAD &vbcrlf& " if (document.cookie.length > 0) {"
		ShowAD=ShowAD &vbcrlf& "   offset = document.cookie.indexOf(search)"
		ShowAD=ShowAD &vbcrlf& "   if (offset != -1) { // if cookie exists"
		ShowAD=ShowAD &vbcrlf& "      offset += search.length"
		ShowAD=ShowAD &vbcrlf& "      // set index of beginning of value"
		ShowAD=ShowAD &vbcrlf& "      end = document.cookie.indexOf(';', offset);"
		ShowAD=ShowAD &vbcrlf& "      // set index of end of cookie value"
		ShowAD=ShowAD &vbcrlf& "      if (end == -1)"
		ShowAD=ShowAD &vbcrlf& "       end = document.cookie.length;"
		ShowAD=ShowAD &vbcrlf& "      returnvalue=unescape(document.cookie.substring(offset, end))"
		ShowAD=ShowAD &vbcrlf& "     }"
		ShowAD=ShowAD &vbcrlf& "  }"
		ShowAD=ShowAD &vbcrlf& "  return returnvalue;"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "if (get_cookie('popad_"&rsAd(0)&"')==''){"
		ShowAD=ShowAD &vbcrlf& "openad()"
		ShowAD=ShowAD &vbcrlf& "document.cookie='popad_"&rsAd(0)&"=yes'"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "-->"
		Case 2
		ShowAD=ShowAD &vbcrlf& "document.write (""<div id='FlAD_"&sAdID&"' style='position:absolute; z-index:10;left: "&AdSetting(1)&"; top: "&AdSetting(2)&"'>" & sTempAD & "</div>"");"
		ShowAD=ShowAD &vbcrlf& "<!--"
		ShowAD=ShowAD &vbcrlf& "var xPos = 300;"
		ShowAD=ShowAD &vbcrlf& "var yPos = document.body.clientHeight;"
		ShowAD=ShowAD &vbcrlf& "var step = 1;"
		ShowAD=ShowAD &vbcrlf& "var delay = 30; "
		ShowAD=ShowAD &vbcrlf& "var height = 0;"
		ShowAD=ShowAD &vbcrlf& "var Hoffset = 0;"
		ShowAD=ShowAD &vbcrlf& "var Woffset = 0;"
		ShowAD=ShowAD &vbcrlf& "var yon = 0;"
		ShowAD=ShowAD &vbcrlf& "var xon = 0;"
		ShowAD=ShowAD &vbcrlf& "var pause = true;"
		ShowAD=ShowAD &vbcrlf& "var interval;"
		ShowAD=ShowAD &vbcrlf& "FlAD_"&rsAd(0)&".style.top = yPos;"
		ShowAD=ShowAD &vbcrlf& "function changePos() {"
		ShowAD=ShowAD &vbcrlf& "width = document.body.clientWidth;"
		ShowAD=ShowAD &vbcrlf& "height = document.body.clientHeight;"
		ShowAD=ShowAD &vbcrlf& "Hoffset = FlAD_"&rsAd(0)&".offsetHeight;"
		ShowAD=ShowAD &vbcrlf& "Woffset = FlAD_"&rsAd(0)&".offsetWidth;"
		ShowAD=ShowAD &vbcrlf& "FlAD_"&rsAd(0)&".style.left = xPos + document.body.scrollLeft;"
		ShowAD=ShowAD &vbcrlf& "FlAD_"&rsAd(0)&".style.top = yPos + document.body.scrollTop;"
		ShowAD=ShowAD &vbcrlf& "if (yon) {"
		ShowAD=ShowAD &vbcrlf& "yPos = yPos + step;"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "else {"
		ShowAD=ShowAD &vbcrlf& "yPos = yPos - step;"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "if (yPos < 0) {"
		ShowAD=ShowAD &vbcrlf& "yon = 1;"
		ShowAD=ShowAD &vbcrlf& "yPos = 0;"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "if (yPos >= (height - Hoffset)) {"
		ShowAD=ShowAD &vbcrlf& "yon = 0;"
		ShowAD=ShowAD &vbcrlf& "yPos = (height - Hoffset);"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "if (xon) {"
		ShowAD=ShowAD &vbcrlf& "xPos = xPos + step;"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "else {"
		ShowAD=ShowAD &vbcrlf& "xPos = xPos - step;"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "if (xPos < 0) {"
		ShowAD=ShowAD &vbcrlf& "xon = 1;"
		ShowAD=ShowAD &vbcrlf& "xPos = 0;"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "if (xPos >= (width - Woffset)) {"
		ShowAD=ShowAD &vbcrlf& "xon = 0;"
		ShowAD=ShowAD &vbcrlf& "xPos = (width - Woffset);"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "function start() {"
		ShowAD=ShowAD &vbcrlf& "FlAD_"&rsAd(0)&".visibility = ""visible"";"
		ShowAD=ShowAD &vbcrlf& "interval = setInterval('changePos()', delay);"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "function pause_resume() {"
		ShowAD=ShowAD &vbcrlf& "if(pause) {"
		ShowAD=ShowAD &vbcrlf& "clearInterval(interval);"
		ShowAD=ShowAD &vbcrlf& "pause = false;"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "else {"
		ShowAD=ShowAD &vbcrlf& "interval = setInterval('changePos()',delay);"
		ShowAD=ShowAD &vbcrlf& "pause = true;"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "start();"
		ShowAD=ShowAD &vbcrlf& "-->"
		Case 3
		ShowAD=ShowAD &vbcrlf& "document.write (""<div id='FixAD_"&sAdID&"' style='position:absolute; z-index:10;left: "&AdSetting(1)&"; top: "&AdSetting(2)&"'>" & sTempAD & "</div>"");"
		ShowAD=ShowAD &vbcrlf& "<!--"
		ShowAD=ShowAD &vbcrlf& "var imgheight"
		ShowAD=ShowAD &vbcrlf& "var imgleft"
		ShowAD=ShowAD &vbcrlf& "document.ns = navigator.appName == ""Netscape"""
		ShowAD=ShowAD &vbcrlf& "if (navigator.appName == ""Netscape"")"
		ShowAD=ShowAD &vbcrlf& "{"
		ShowAD=ShowAD &vbcrlf& "imgheight=document.FixAD_"&rsAd(0)&".pageY"
		ShowAD=ShowAD &vbcrlf& "imgleft=document.FixAD_"&rsAd(0)&".pageX"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "else"
		ShowAD=ShowAD &vbcrlf& "{"
		ShowAD=ShowAD &vbcrlf& "imgheight=600-parseInt(FixAD_"&rsAd(0)&".style.top)"
		ShowAD=ShowAD &vbcrlf& "imgleft=parseInt(FixAD_"&rsAd(0)&".style.left)"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "myload()"
		ShowAD=ShowAD &vbcrlf& "function myload()"
		ShowAD=ShowAD &vbcrlf& "{"
		ShowAD=ShowAD &vbcrlf& "if (navigator.appName == ""Netscape"")"
		ShowAD=ShowAD &vbcrlf& "{document.FixAD_"&rsAd(0)&".pageY=pageYOffset+window.innerHeight-imgheight;"
		ShowAD=ShowAD &vbcrlf& "document.FixAD_"&rsAd(0)&".pageX=imgleft;"
		ShowAD=ShowAD &vbcrlf& "leftmove();"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "else"
		ShowAD=ShowAD &vbcrlf& "{"
		ShowAD=ShowAD &vbcrlf& "FixAD_"&rsAd(0)&".style.top=document.body.scrollTop+document.body.offsetHeight-imgheight;"
		ShowAD=ShowAD &vbcrlf& "FixAD_"&rsAd(0)&".style.left=imgleft;"
		ShowAD=ShowAD &vbcrlf& "leftmove();"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "function leftmove()"
		ShowAD=ShowAD &vbcrlf& " {"
		ShowAD=ShowAD &vbcrlf& " if(document.ns)"
		ShowAD=ShowAD &vbcrlf& " {"
		ShowAD=ShowAD &vbcrlf& " document.FixAD_"&rsAd(0)&".top=pageYOffset+window.innerHeight-imgheight"
		ShowAD=ShowAD &vbcrlf& " document.FixAD_"&rsAd(0)&".left=imgleft;"
		ShowAD=ShowAD &vbcrlf& " setTimeout(""leftmove();"",50)"
		ShowAD=ShowAD &vbcrlf& " }"
		ShowAD=ShowAD &vbcrlf& " else"
		ShowAD=ShowAD &vbcrlf& " {"
		ShowAD=ShowAD &vbcrlf& " FixAD_"&rsAd(0)&".style.top=document.body.scrollTop+document.body.offsetHeight-imgheight;"
		ShowAD=ShowAD &vbcrlf& " FixAD_"&rsAd(0)&".style.left=imgleft;"
		ShowAD=ShowAD &vbcrlf& " setTimeout(""leftmove();"",50)"
		ShowAD=ShowAD &vbcrlf& " }"
		ShowAD=ShowAD &vbcrlf& " }"
		ShowAD=ShowAD &vbcrlf& "function MM_reloadPage(init) {  //reloads the window if Nav4 resized"
		ShowAD=ShowAD &vbcrlf& "  if (init==true) with (navigator) {if ((appName==""Netscape"")&&(parseInt(appVersion)==4)) {"
		ShowAD=ShowAD &vbcrlf& "    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}"
		ShowAD=ShowAD &vbcrlf& "  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();"
		ShowAD=ShowAD &vbcrlf& "}"
		ShowAD=ShowAD &vbcrlf& "MM_reloadPage(true)"
		ShowAD=ShowAD &vbcrlf& "-->"
		End Select
	Elseif rsAd(7)=1 and closeads=0 then
	if CodeNote=0 then
		ShowAD="document.write ('" & Replace(Replace(rsAd(3),"'",""),vbcrlf,"\n") & "');"
	else
		ShowAD=""&Replace(Replace(rsAd(3),"",""),vbcrlf,vbcrlf)&""
	End if
	else
	if CodeNote=0 then
		ShowAD="document.write ('');"
		else
		ShowAD=""
	End if
	End if
 file_name=Cls.Web_Dir &"Ads/"&ADName&".js"
    Dim TmpCls
	Set TmpCls = New Cls_FileSystem
    Call TmpCls.Create_File(file_name,ShowAD)
	Set TmpCls = Nothing
end sub

sub AsaiMHChk_View()
  dim file_name,ADName,atemp,awh,IsFlash
  awh=""
  sql="select top 1 * from AsaiMHAds where aid="&id
  set rs=Cls.exec(sql,1)
  if rs.eof then
    rs.close
    call AMH_msg(tit_fir&"（ID："&id&"）不在存！",pageurl,1)
    exit sub
  end if
  call AMH_td("浏览"&tit_fir)
  IsFlash=Rs("IsFlash")
  ADName=Rs("ADName")
  if rs("ADType")=0 then awh=" width="&rs("ImgWidth")&" height="&rs("ImgHeight")
  select case rs("ADType")
  case 0
    	If Isflash=False Then
    atemp="<a href='"&rs("AdLinkUrl")&"' target=_blank><img src='"&rs("AdImgUrl")&"' border=0 alt='"&rs("AdIntro")&"'"&awh&"></a>"
	Else
    atemp="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://Download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0'"&awh&">" & _
	  "<param name=movie value='"&rs("AdImgUrl")&"'><param name=quality value=high>" & _
	  "<embed src='"&rs("AdImgUrl")&"' quality=high pluginspage='http://www.macromedia.com/shockwave/Download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash'"&awh&">" & _
	  "</embed></object>"
	End if
  case 1
    atemp="<a href='"&rs("AdLinkUrl")&"' target=_blank>"&rs("AdImgUrl")&"</a>"
  end select
  rs.close
%>
  <tr><td colspan=2 align=center><br /><%response.write atemp%><br /><br /></td></tr>
  <tr class=tr1><td colspan=2 align=center height=40><input class=btn type=button name=go_back value='编辑此<%response.write tit_fir%>' onclick="location.href='<%response.write pageurl%>action=edit&id=<%response.write id%>';" class="sub">　　<%response.write go_back%></td></tr>
<%
end sub

sub AsaiMHChk_Main()
  dim topic,AdSetting
%>
  <form name=sel_form action='<%response.write pageurl%>action=handle' method=post>
  <tr align=center>
      <td class=td width='5%'>ID</td>
      <td class=td width='8%'>广告类型</td>
      <td class=td width='12%'>广告名称</td>
      <td class=td width=*>广告说明</td>
      <td class=td width='8%'>开始日期</td>
      <td class=td width='8%'>结束日期</td>
      <td class=td width='8%'>广告预览</td>
      <td class=td width='5%'>操作</td>
     <td class=td width='5%'><input type=checkbox name=sel_all value='yes' onclick="javascript:select_all(this.form);"></td>
  </tr>
<%
  dim obj_page
  set obj_page=new Cls_PageCute
  obj_page.pageurl=pageurl
  obj_page.nummer=nummer+5
  obj_page.page_t=1
  obj_page.page_p=5
  obj_page.page_unit="条"
  obj_page.page_tit=tit_fir
  obj_page.v_id="aid"
  Call obj_page.p_init("*","AsaiMHAds",sql_add,"aid desc")
  sql=obj_page.sql_count
  set rs=Cls.exec(sql,1)
  obj_page.rssum=rs(0)
  rs.close
  call obj_page.p_main("*","AsaiMHAds",sql_add,"aid desc")
  for i=1 to obj_page.page_num
    id=rs("aid")
%>
  <tr align=center>
      <td class=tims><%Response.Write obj_page.page_now+i%></td>
      <td>
        <%
		If rs("ADType")=1 then
			response.write "<font color=blue>代码广告</font>"
		Else
			AdSetting=Split(rs("AdSetting"),"|")
			response.write "图片广告"
			Select Case Cint(AdSetting(0))
			Case 1
				response.write "(<font color='#ff0033'>弹出</font>)"
			Case 2
				response.write "(<font color='#ff0033'>浮动</font>)"
			Case 3
				response.write "(<font color='#ff0033'>固定</font>)"
			end select
		End If
		%>
      </td>
      <td align=left>
        <%If rs("ADType")=1 then%>
			<font color=blue><%=rs("AdName")%></font>
		<%Else%>
		 <a href="<%=rs("AdLinkUrl")%>" target='blank' title="链接地址：<%=rs("AdLinkUrl")%>"><%=rs("AdName")%></a>
		<%End If%>
	 </td>
  <td align=left><%=rs("AdIntro")%></td>
  <td></td>
  <td></td>
  <td><a href="<%response.write pageurl%>action=view&id=<%=id%>"><font color=blue>点击预览广告</font></a></td>
  <td><a href='<%response.write pageurl%>action=edit&id=<%=id%>'>编辑</a></td>
  <td><input type=checkbox name=sel_id value='<%response.write id%>'></td>
    </tr>
<%
    rs.movenext
  next
  rs.close
%>
<tr class=tr1>
<td colspan=6>
  <table border=0>
  <tr class=tr1>
  <td></td>
  <td><%Response.Write obj_page.page_var%></td>
  <td width=3></td>
  <td>分页：</td>
  <td><%Response.Write obj_page.page_cute%></td>
  </tr>
  </table>
</td>
<td align=center>
  <select name=sel_type size=1>
  <option value='删除'>删除</option>
  </select>
</td>
<td colspan=2 align=center>
  <input type=submit value='操作' onclick="return sel_click(this.form);" class=btn>
</td>
</tr>
</form>
<%
end sub
%>
