<%@ page language="C#" validaterequest="false" masterpagefile="AdminIndexMaster.master" autoeventwireup="true" inherits="HL_Admin_Admin_ManageAdZone, WebApp_deploy" title="广告模板管理" enableeventvalidation="false" viewstateencryptionmode="never" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script src="Js/Function.js" type="text/javascript"></script> 
<script type="text/javascript">
function SelectCheckboxes(){
  var spanChk = document.getElementById("ctl00_ContentPlaceHolder1_GridView1_ctl01_chkAll");
　var oItem = spanChk.children;
　var theBox=(spanChk.type=="checkbox")?spanChk:spanChk.children.item[0];
　xState=theBox.checked;
　elm=theBox.form.elements;
　for(i=0;i<elm.length;i++)
　if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
　{
　　elm[i].checked = !elm[i].checked;
　}
}
function ShowJsCode(JsName,ZoneName)
{
  var showJsObj=document.getElementById("AdZoneJS");
  var Jstext=document.getElementById("JsCode");
  showJsObj.style.display="block";
 
   var siteUrl=GetSiteUrl();
   Jstext.value ="<!----广告AD-----"+ZoneName+"--开始-->\r\n";
   Jstext.value +="<script type='text/javascript' src='"+siteUrl+"/AD/"+JsName+"' charset='gb2312'></";
   Jstext.value +="script>\r\n";
   Jstext.value +="<!----广告AD-----"+ZoneName+"--结束-->";
}
function copyCcode()
{
	var obj;
	obj=document.getElementById("JsCode");
	obj.focus();
	obj.select();
	document.execCommand("copy");
	
}
function GetSiteUrl()
{
   var url=window.location.href;
   var siteUrl=url.substring(0,url.indexOf('/',7));
   return siteUrl;  
}
function SearchZoneType(zoneType,zoneValue)
{
  if(zoneType=='ZoneName')
  {
    zoneValue=document.getElementById("ctl00_ContentPlaceHolder1_ZoneName").value;
    zoneValue=escape(zoneValue);
  }
  window.location.href="Admin_ManageAdZone.aspx?"+zoneType+"="+zoneValue;
}
</script>
<table class="adminheading">
<tr><th>网站广告管理</th>                  
            <td align="right">
            <div style="width:590px">
                <a href="Admin_manageadzone.aspx">管理广告版位</a>&nbsp;|&nbsp;
                <a href="Admin_updateadzone.aspx?add=1">增加广告版位</a>&nbsp;|&nbsp;
                <a href="Admin_managead.aspx">管理广告</a>&nbsp;|&nbsp;
                <a href="Admin_updateAd.aspx">添加新广告</a>&nbsp;|&nbsp;
                <a  href="Admin_Managejs.aspx">js模板管理</a>&nbsp;|&nbsp;
                <a href="Admin_ManageUploadFile.aspx">广告上传文件管理</a>
             </div>
             </td>
             <td class="rtdw"></td> 
</tr>
</table> 
 <table class="nick">
            <tr><td colspan="4" class="tit">快速查找</td></tr>
            <tr>
                <td class="ltd">版位名称：</td>
                <td class="rtd" style="width: 35%;">
                    <asp:TextBox ID="ZoneName"  runat="server"/><input type="button" value="确定" onclick="SearchZoneType('ZoneName','')" /></td>
                <td class="ltd">版位类型</td>
                <td class="rtd" style="width: 35%;">
                  <asp:DropDownList ID="ZoneType" runat="server" onchange="SearchZoneType('ZoneIntro',this.value)">
                    <asp:ListItem  value="">全部</asp:ListItem>
                    <asp:ListItem value="1">矩形横幅</asp:ListItem>
                    <asp:ListItem value="2">文字代码</asp:ListItem>
                    <asp:ListItem value="3">弹出窗口</asp:ListItem>
                    <asp:ListItem value="4">随屏移动</asp:ListItem>
                    <asp:ListItem value="5">固定位置</asp:ListItem>
                    <asp:ListItem value="6">漂浮移动</asp:ListItem>
                  </asp:DropDownList>
                  
                </td>
             </tr>
        </table>    

         <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
              DataSourceID="AdZoneDatasource" OnDataBound="GridView1_DataBound" 
              DataKeyNames="zoneid" OnRowDataBound="GridView1_RowDataBound" CssClass="adminlist">
                    <Columns>
                        <asp:TemplateField HeaderText="选择">
                            <ItemTemplate>
                                <asp:CheckBox ID="CheckBox1" runat="server" Text='<%# Eval("ZoneID") %>' Font-Size="0"/>
                            </ItemTemplate>
                            <HeaderTemplate>
                               <input id="chkAll" onclick="SelectAllCheckboxes(this);" runat="server" type="checkbox" />
                            </HeaderTemplate>
                            <HeaderStyle Width="30px" />
                        </asp:TemplateField>                        
                        <asp:BoundField DataField="ZoneID" HeaderText="ID" />
                        <asp:BoundField DataField="Zonename" HeaderText="名称" />
                        <asp:BoundField DataField="Zonetype" HeaderText="类型" />
                        <asp:BoundField DataField="ShowType" HeaderText="显示" />
                        <asp:BoundField DataField="zoneWidth" HeaderText="长" />
                        <asp:BoundField DataField="zoneHeight" HeaderText="宽" />
                        <asp:BoundField DataField="Active" HeaderText="启用" />
                        <asp:TemplateField HeaderText="操作">
                          <ItemTemplate>
                             <asp:LinkButton ID="cl" runat="server" Text="删除"  CommandName='<%#Eval("ZoneID") %>' OnClientClick="{if(confirm('确定删除吗？')) return true;return false;}" OnCommand="GridView1_SelectedIndexChanged" />|
                             <asp:HyperLink ID="updateLinke" runat="server"  Text="修改" NavigateUrl='<%#"Admin_UpdateAdzone.aspx?UpdateZoneID="+Eval("ZoneID") %>'  />|
                               <asp:HyperLink ID="PreviewAD" runat="server" NavigateUrl='<%#"../AD/admin_adprevrew.aspx?js="+Eval("zoneJSName") %>' Text='预览' target="_blank"/>|
                               <a href="javascript:void(0)" onclick="ShowJsCode('<%# Eval("ZoneJSName") %>','<%#Eval("Zonename") %>')">调用JS</a>
                          </ItemTemplate>
                        </asp:TemplateField>                      
                    </Columns>
                    <EmptyDataTemplate>
                    <tr>
                      <th>全选</th><th>ID</th><th>名称</th><th scope="col">类型</th><th scope="col">显示</th><th scope="col">长</th><th scope="col">宽</th><th scope="col">活动</th><th scope="col">删除</th><th scope="col">修改</th><th scope="col">调用代码</th><th scope="col">预览</th>
		              </tr>
		            <tr>
		               <td colspan="12">暂无广告版位！</td>
		            </tr>
                    </EmptyDataTemplate>
                </asp:GridView>              
            <div class="div_btm">
                <input type="button" value="反选" name="ddd" onclick="return SelectCheckboxes()" />
                <asp:Button ID="Button3" runat="server" OnClientClick="{if(confirm('确定删除吗？')) return true;return false;}" OnClick="Button3_Click" Text="删除" />
                
            </div>
             <div id="AdZoneJS" style="display:none;">
                 <input type="button" value="复制到粘贴板" onclick="copyCcode()" /><textarea id="JsCode"  style="width:80%; height:60px;font-family:Verdana;" ></textarea>
             </div>
            <div class="help_intro" >
               <h1>新增广告流程：</h1>
               
                 <ul>
                    <li>第一步：新增广告版位---(注：广告版位作用是用于放置广告，相当于报纸杂志的广告版位，每个版位可放置1个或多个广告)</li>
                    <li>第二步：新增广告,在左侧选择该广告所投放的版位，设置权重及有效期.注（广告权重表示广告显示的机率，权重越大，显示的机率越大，若为0则不显示。<br />有效期--是指广告显示的有效期限，过期广告不显示）</li>
                    <li>第三步：在管理广告版位，选择刚才新增广告所选择的版位，点击预览，若能正确显示表示该广告生成成功。</li>
                    <li>第四步：点击调用JS代码，复制文本框的JS代码内容，将其放入模板合适的位置内，保存模板。</li>
                    <li>至此结束。</li>
                 </ul>
               
              
            </div>
        
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"  SelectMethod="GetChannels" TypeName="HoWave.Web.ChannelBLL"/> 
    <asp:ObjectDataSource ID="AdZoneDatasource" runat="server" DeleteMethod="DelectAdZone"
        SelectMethod="GetAdZoneByNameIntro" TypeName="HoWave.Web.AdZoneBll"  OldValuesParameterFormatString="original_{0}">
        <DeleteParameters>
            <asp:Parameter Name="AdZoneID" Type="Int32" />
        </DeleteParameters>  <SelectParameters>        
            <asp:QueryStringParameter Name="ZoneName" DefaultValue="" Type="String" QueryStringField="ZoneName" />
            <asp:QueryStringParameter DefaultValue="" Name="ZoneIntro" QueryStringField="ZoneIntro"
                Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>    
</asp:Content>

