<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AuthorListControl.ascx.cs"
    Inherits="PowerEasy.Module.General.WebSite.Admin.Controls.Common.AuthorListControl" %>
<% AuthorInput = Request.QueryString["BackControlId"];%>

<script language="javascript" type="text/javascript">
       <!--
    document.write('<div    id=loadDiv    style="padding-top:    50;    padding-left:    50">正在加载页面，请稍候<span    id="loading"></span></div>');   
       var setInterval1    =    setInterval(" document.getElementById('loading').innerText    +=    '.'",    300);   
       var setInterval2    =    setInterval(" document.getElementById('loading').innerText    =    ''",    15000);   

		function addLoadEvent(func) {
			var oldonload = window.onload;
			if (typeof window.onload != 'function') {
				window.onload = func;
			} else {
				window.onload = function() {
				oldonload();
				func();
				}
			}
		}

		function  Initial()   
		{   
			  document.getElementById("hiddenDiv").style.display="";    //显示页面内容   
			  document.getElementById("loadDiv").parentNode.removeChild( document.getElementById("loadDiv"));
			 clearInterval(setInterval1);   
			 clearInterval(setInterval2);   
		}
	   addLoadEvent(Initial);

       // -->
</script>

<div style="text-align: center; display: none" id="hiddenDiv">
    <table width='560' border='0' cellpadding='2' cellspacing='0' class='border'>
        <tr class='title' style="height: 22">
            <td valign='top'>
                <b><asp:Localize ID="Localize1" 
                    Text="已经选定的作者：" 
                    runat="server" /></b>
            </td>
            <td align='right' style="width: 177px">
                <%--  <a href='javascript:window.close();'>返回&gt;&gt;</a>--%>
            </td>
        </tr>
        <tr class='tdbg'>
            <td>
                <input type="text" id="AuthorList" size="60" maxlength="200" readonly="readonly"
                    class="inputtext" />
            </td>
            <td align='center' style="width: 177px">
                <input id="DelectFinal" runat="server" type="button" class="inputbutton" name="del1" onclick="del(1)" value="删除最后 " />
                <input id="DelectAll" runat="server" type="button" class="inputbutton" name="del2" onclick="del(0)" value="删除全部 " />
            </td>
        </tr>
    </table>
    <br />
    <table width="560" border="0" cellpadding="2" cellspacing="0" class="border">
        <tr class="title">
            <td align="left">
                <span style="cursor:pointer;" onclick="GetAuthorList();">
                <asp:Localize ID="Localize2" 
                    Text="全部分类 " runat="server" /></span>
                <asp:Repeater ID="RptAuthorType" runat="server">
                    <ItemTemplate>
                        | <span style="cursor:pointer;" onclick="OpenMainRightType('<%# Eval("DataTextField") %>')">
                            <%# Eval("DataTextField")%>
                        </span>
                    </ItemTemplate>
                </asp:Repeater>
            </td>
        </tr>
    </table>
    <br />
    <table width="560" border="0" cellpadding="2" cellspacing="0" class="border">
        <tr class="title">
            <td>
                <b><asp:Localize ID="Localize3" 
                    Text="作者列表：" runat="server" /></b>
            </td>
            <td align="right">
                <asp:Localize ID="Localize4" 
                    Text="姓名：" runat="server" />
                <input id="HdnListType" type="hidden" />
                <input name='Author' type='text' size='20' class="inputtext" />&nbsp;&nbsp;<input id="inputSelect" runat="server"
                    type='submit' value="查找 " />
            </td>
        </tr>
        <tr>
            <td valign='top' style="height: 100px" colspan="2">
                <asp:Repeater ID="RepAuthors" runat="server" OnItemDataBound="RepAuthors_ItemDataBound">
                    <HeaderTemplate>
                        <table width='550' border='0' cellspacing='1' cellpadding='1'>
                            <tr>
                                <td style="width: 20%" align='center'>
                                    <asp:Localize ID="Localize5" Text="姓名 " runat="server" />
                                </td>
                                <td style="width: 10%" align='center'>
                                    <asp:Localize ID="Localize6" Text="性别 " runat="server" />
                                </td>
                                <td style="width: 70%" align='center'>
                                    <asp:Localize ID="Localize7" Text="简介 " runat="server" />
                                </td>
                            </tr>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr style="background-color: #f9f9f9">
                            <td align='center'>
                                  <pe:ExtendedLiteral ID="LitAuthor" runat="server"></pe:ExtendedLiteral>
                            </td>
                            <td align='center'>
                                <asp:Localize ID="Localize8" runat="server" />
                            </td>
                            <td align="left">
                                <%# Eval("Intro")%>
                            </td>
                        </tr>
                    </ItemTemplate>
                    <FooterTemplate>
                        </table>
                    </FooterTemplate>
                </asp:Repeater>
            </td>
        </tr>
    </table>
    <table border="0" cellpadding="2" cellspacing="0">
        <tr>
            <td align="center">
                <pe:AspNetPager ID="Pager" runat="server" OnPageChanged="Pager_PageChanged">
                </pe:AspNetPager>
            </td>
        </tr>
    </table>

    <script language="javascript" type="text/javascript">
        document.getElementById('AuthorList').value = parent.document.getElementById('<%= AuthorInput %>').value;
        function GetAuthorList()
        {
            var url= "AuthorList.aspx?BackControlId=<%= AuthorInput %>";
            window.location =url; 
        }
        function OpenMainRightType(value)
        {
            var url= "AuthorList.aspx?ListType=4&BackControlId=<%= AuthorInput %>&SearchType="+escape(value);
            document.getElementById("HdnListType").value=5;
            window.location =url; 
        }
          
        function add(obj)
        {
            if(obj==""){return alert('dfs');}
            if(parent.document.getElementById('<%= AuthorInput %>').value=="")
            {
                parent.document.getElementById('<%= AuthorInput %>').value=obj;
                document.getElementById('AuthorList').value = parent.document.getElementById('<%= AuthorInput %>').value;
                return false;
            }
            var singleAuthor=obj.split("|");
            var ignoreAuthor="";
            for(i=0;i<singleAuthor.length;i++)
            {
                if(checkAuthor(parent.document.getElementById('<%= AuthorInput %>').value,singleAuthor[i]))
                {
                    ignoreAuthor=ignoreAuthor+singleAuthor[i]+" ";
                }
                else
                {
                    parent.document.getElementById('<%= AuthorInput %>').value = parent.document.getElementById('<%= AuthorInput %>').value + "|" + singleAuthor[i];
                    document.getElementById('AuthorList').value = parent.document.getElementById('<%= AuthorInput %>').value;
                }
            }
            if(ignoreAuthor!="")
            {
                alert(ignoreAuthor + " 作者已经存在，此操作已经忽略！");
            }
        }
        function del(num)
        {
            if (num==0 || parent.document.getElementById('<%= AuthorInput %>').value=="" || parent.document.getElementById('<%= AuthorInput %>').value=="|")
            {
                parent.document.getElementById('<%= AuthorInput %>').value="";
                document.getElementById('AuthorList').value="";
                return false;
            }
        
            var strDel=parent.document.getElementById('<%= AuthorInput %>').value;
            var s=strDel.split("|");
            parent.document.getElementById('<%= AuthorInput %>').value = strDel.substring(0,strDel.length-s[s.length-1].length-1);
            document.getElementById('AuthorList').value = parent.document.getElementById('<%= AuthorInput %>').value;
        }
        
        function checkAuthor(Authorlist,thisAuthor)
        {
          if (Authorlist==thisAuthor){
                return true;
          }
          else{
            var s=Authorlist.split("|");
            for (j=0;j<s.length;j++){
                if(s[j]==thisAuthor)
                    return true;
            }
            return false;
          }
        }
    </script>

</div>
