<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Admin_Ad_Code1.aspx.vb" Inherits="TourEx.Web.Admin_Ad_Code" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!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=utf-8" />
<title>无标题页</title>
<link rel="stylesheet" type="text/css" href="Css/Style.css"/>
<script language="javascript" src="../Sys/Js/jquery.js"></script>
<script language="javascript" src="../Sys/Js/AlertWindow.js"></script>
</head>
<body>
    <div id="messWindow" class="messWindow">
    </div>
    
    <div id="promptWindow" class="promptWindow" align="center" p="45">
        <div class="titleBar">
            <span>添加代码广告</span><span onclick="HideWindow()" style="float: right;"><img src="Images/popclose.gif" /></span></div>
        <div class="mainContent">
            <form method="post" action="?Act=add" onsubmit="return CheckForm();">
            <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D6DFF7">
                <tr>
                    <td class="subMainLeft" width="80">广告内容：</td>
                    <td class="subMainRight"><textarea name="A_Text" id="A_Text_0" cols="45" rows="10" class="formTextarea"></textarea></td>
                </tr>
			    <tr>
			        <td class="subMainLeft" width="80">位置描述：</td>
			        <td class="subMainRight">
			            <input name="A_Description" type="text" id="A_Description_0" size="30" maxlength="50" class="formTitle"/>
			        </td>
                </tr>
            </table>
			<div class="subMainFoot"><input name="submit" type="submit" class="formInput01" value="添加" /> <input type="button" class="formInput02" value="取消" onclick="HideWindow()"/></div>
            </form>
        </div>
    </div>
	<ul class="tools">
		<li class="add" p="45"><span><a href="javascript:void(0);" onclick="ShowWindow()">添加</a></span></li>
		<li class="save" p="46"><span><a href="javascript:void(0);" onclick="Save(0);return false;">保存</a></span></li>
		<li class="del" p="47"><span><a href="javascript:void(0);" onclick="Del(0);return false;">删除</a></span></li>
		<li class="search"><select onchange="location=this.value;">
			<option value="Admin_Ad_Text.aspx" p="39,40,41">文字广告</option>
			<option value="Admin_Ad_Pic.aspx" p="42,43,44">图片广告</option>
			<option value="Admin_Ad_Code1.aspx" selected>代码广告</option>
			</select></li>
	</ul>
    <form id="BatchSubmit" name="BatchSubmit" method="post" action="?act=edit" style="display: none">
    </form>
<asp:Repeater ID="Repeater" runat="server">
    <HeaderTemplate>
		<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabBox">
            <tr class="tabTitleMain">
                <td width="35" class="selectAll">
                    <a href="javascript:void(0);" onclick="$('input[name=\'A_ID\']').attr('checked',!$(this).attr('checked'));$(this).attr('checked',!$(this).attr('checked'));">全选</a>
                </td>
                <td width="50">广告位</td>
                <td>广告内容</td>
                <td>描述</td>
                <td width="60">操作</td>
            </tr>
    </HeaderTemplate>
    <ItemTemplate>
        <tr class="tabTextMain" id="From_<%#Eval("A_ID")%>" onmouseout="this.style.background='#FFFFFF';" onmouseover="this.style.background='#F4F7FA';">
            <td><input name="A_ID" id="A_ID_<%#Eval("A_ID")%>" type="checkbox" value="<%#Eval("A_ID")%>" /></td>
            <td align="center"><%#Eval("A_OrderId")%> </td>
            <td>
                <textarea name="A_Text_<%#Eval("A_ID")%>" id="A_Text_<%#Eval("A_ID")%>" cols="50" rows="10" class="formTextarea"><%#Eval("A_Text")%></textarea>
                <textarea id="Text_<%#Eval("A_ID")%>" style="display:none" class="formTextarea"><%#Eval("A_Text")%></textarea>
            </td>
            <td>
                <input maxlength="50" id="A_Description_<%#Eval("A_ID")%>" name="A_Description_<%#Eval("A_ID")%>" type="text" value="<%#Eval("A_Description")%>" ovalue="<%#Eval("A_Description")%>" size="50" class="formTitle"/>
            </td>
            <td>
                <a href="javascript:void(0);" onclick="Save(<%#Eval("A_ID")%>);return false;" p="46">保存</a>
                <a href="javascript:void(0);" onclick="Del(<%#Eval("A_ID")%>);return false;" p="47">删除</a>
            </td>
        </tr>
    </ItemTemplate>
    <FooterTemplate>
        </table>
        <asp:Label ID="lblEmpty" Text="暂无" runat="server" Visible="<%#Boolean.Parse((Repeater.Items.Count = 0).ToString())%>"
            Width="100%" Style="text-align: center">     
        </asp:Label>
    </FooterTemplate>
</asp:Repeater>
<webdiyer:AspNetPager ID="TourExPage" runat="server" UrlPaging="true" ShowPageIndexBox="Never"
    PageIndexBoxType="DropDownList" TextBeforePageIndexBox=""
    PageSize="20" OnPageChanged="BindData" EnableTheming="true" FirstPageText="首页"
    LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页" CssClass="page" 
        PagingButtonSpacing="" CurrentPageButtonClass="current" 
    CurrentPageButtonStyle="">
</webdiyer:AspNetPager>
<script type="text/javascript">
 <!--//
 var AP='<%=TourEx.BLL.GetSession("AdminPermissions") %>';
 if(AP!='')
 {
    if(AP.indexOf(',45,')==-1)$('*[p="45"]').remove();
    if(AP.indexOf(',46,')==-1)$('*[p="46"]').remove();
    if(AP.indexOf(',47,')==-1)$('*[p="47"]').remove();
    if(AP.indexOf(',42,')+AP.indexOf(',43,')+AP.indexOf(',44,')==-3)$('*[p="42,43,44"]').remove();
    if(AP.indexOf(',39,')+AP.indexOf(',40,')+AP.indexOf(',41,')==-3)$('*[p="39,40,41"]').remove();
 }
 function Save(ID)
 {
 	var A_IDs=ID==0?$('input[name="A_ID"]'):$('#A_ID_'+ID);
	var A_T,A_O,A_D;
	$('#BatchSubmit').html('');
	for(var i=0;i<A_IDs.length;i++)
	{
		A_T = $.trim($('#A_Text_'+A_IDs[i].value).val());
		$('#A_Text_'+A_IDs[i].value).val(A_T);
		if(A_T==''){alert('请填写广告内容！');return;}
		A_O=$('#Text_'+A_IDs[i].value).val();
		A_D=$.trim($('#A_Description_'+A_IDs[i].value).val());
		if(A_T!=A_O || A_D!= $.trim($('#A_Description_'+A_IDs[i].value).attr('ovalue')))
		{
			A_IDs[i].checked=true;
			$('#From_'+A_IDs[i].value).clone().prependTo("#BatchSubmit");
			$('#A_Text_'+A_IDs[i].value,'#BatchSubmit').val(A_T);
			$('#A_Description_'+A_IDs[i].value,'#BatchSubmit').val(A_D);
			$('#Text_'+A_IDs[i].value,'#BatchSubmit').remove();
		}
	}
 	if($('#BatchSubmit').html()==''){alert('数据没有改动过，无需保存！');return;}
	$('input[name="A_ID"]','#BatchSubmit').attr('checked',true);
	$('#BatchSubmit').submit();
 }
 function CheckForm()
 {
    if($("A_Text_0").val()=='')
    {
        alert('请填写广告内容！');return false;
    }
    return true;
 }
 function Del(ID)
 {
 	var Url='?Act=del&';
	var IDs;
	if(ID>0)
	{
		Url +='A_ID='+ID;
	}else{
 		IDs = $("input[name='A_ID']").serialize().replace(/&A_ID=/g,',');
		if(IDs==''){alert('请选择您要删除的帮广告！');return;}
		Url +=IDs;
	}
	if(confirm('您确定删除吗！')){location=Url;}
 }
    //-->
</script>
