<%@ Page Language="C#" Theme="" AutoEventWireup="true" CodeBehind="Popup.aspx.cs" Inherits="Portal.Portal.Popup" %>
<%@ Register TagPrefix="cc1" Namespace="MoverControl" Assembly="MoverControl" %>
<!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 id="Head1" runat="server">
    <title>选择人员</title> <script src="../Javascript/jquery-1.9.1.min.js"></script>
   
    <script src="../javascript/jquery.cookie.js" type="text/javascript"></script>
    <style>
        #history{ text-align:left}
    .hidden{ display:none; }
    .h{ cursor:pointer; text-align:left; text-decoration:underline; display:inline-block; width:160px; height:20px; overflow:hidden; margin-top:10px; margin-left:10px;    }
    </style>
</head>


<body style="font-size:12px; font-family:Verdana; text-align:center; background-color:#C6D8FE">
    <form id="form1" runat="server">
    <div>
    
        <asp:HiddenField ID="hf_types"  Value="txt_user" runat="server" />
    <br />关键字: <asp:TextBox ID="txtAD" runat="server"></asp:TextBox><asp:Button ID="Search"
        runat="server" Text="搜索" OnClick="Search_Click" />
    <cc1:bhMover id="BhMover1" runat="server">
			 
				 
			</cc1:bhMover>
        <br />
   
            
      <span runat="server" id="sp1_user">
        <input id="btn_user" type="button" value="提交" onclick="submitAndClose()"  style="height: 26px"/>
       </span>

       <span runat="server" id="sp1_group">
         <input id="btn_group" type="button" value="提交" onclick="submitGAndClose()"  style="height: 26px"/>
      </span>
        <input type="button" onclick="clears()"  value="清除记录"  style="height: 26px"/>

            </div>



         <div id="history"></div>

              <asp:HiddenField runat="server" ID="hf_cookiename" Value="hit_dotnetcms.org_portal" />
              <asp:HiddenField runat="server" ID="hf_ismulti" ClientIDMode="Static" Value="0" />
    </form>
</body>











    
   <script>

       var itemSplit = "portal";
       var cookieName = "portalHitHistory";
       var ismulti = $("#hf_ismulti").val();
       function submitAndClose() {

           var count = $("#BhMover1_rightlstbox option").length;
          
           if (count > 0) {

               if (ismulti == "1") {
                   var theresult = "";
                   for (cc = 0; cc < count; cc++) {
                       var option = $("#BhMover1_rightlstbox").get(0).options[cc]; 
                       SetHistory($(option).text(), $(option).val());
                       theresult = theresult + '#' + $(option).val();
                     
                   }
                  
                 window.opener.setPopUser(theresult);
                  self.close();
               }
               else {   
                   var option = $("#BhMover1_rightlstbox").get(0).options[0];
                   SetHistory($(option).text(), $(option).val());
                   window.opener.setPopUser($(option).val());
               }

           }

       }

       function clears() {
           $.cookie(cookieName, null);
           $("#history").html("");
       }

       function submitGAndClose() {

           var count = $("#BhMover1_rightlstbox option").length;
           var theresult = "";
           
           for (cc = 0; cc < count; cc++) {
               var option = $("#BhMover1_rightlstbox").get(0).options[cc];
              
               theresult = theresult + '#' + $(option).val();
           }
          
           window.opener.setPopGroup(theresult);
           self.close();
           
          
       
       }

       function SetHistory(cKey, cName) {
           var itemCookie = escape(cKey) + "+" + escape(cName) + itemSplit;
           var old_itemCookies = $.cookie(cookieName);
           var insert = true;

           if (old_itemCookies == null) {

               $.cookie(cookieName, itemCookie, { expires: 10 });
               $("#history").html("");
               InitHis();
               return;

           }
           else {

               try {
                   var old_itemCookie = old_itemCookies.split(itemSplit);
                   var c = old_itemCookie.length;
                   for (var j = 0; j < c; j++) {
                       if ((old_itemCookie[j] + itemSplit).indexOf(itemCookie) != -1) {
                           insert = false;
                       }
                   }
               }
               catch (e) {
               }
           }

           if (insert) {

               $.cookie(cookieName, itemCookie + old_itemCookies, { expires: 10 });
               $("#history").html("");
               InitHis();
           }

       }




       function InitHis() {

           var itemCookies = $.cookie(cookieName);

           if (itemCookies != null) {
               var cont = "";
               var itemCookie = itemCookies.split(itemSplit);

               for (var j = 0; j < 9; j++) {
                   try {
                       var items = itemCookie[j];
                       var item = items.split("+");
                       var name = item[0];
                       var mail = item[1];

                       cont = cont + "<span class=h onclick=setQuickHis('" + name + "','" + mail + "')>" + unescape(name) + "</span>  ";

                   }
                   catch (e)
                   { }
               }

               $("#history").html(cont);


           }
           else {

           }

       }




       function setQuickHis(k, v) {
           window.opener.setPopUser(unescape(v));
           self.close();
         //  parent.setPopUser(unescape(v));
          // parent.layer.close(parent.layer.getFrameIndex(window.name));
       }

       $(document).ready(function () {
           InitHis();
       }
       );

</script>

</html>