<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Chat.aspx.cs" Inherits="SWTraining.OA.Chat"
    ValidateRequest="false" %>

<!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 runat="server">
    <title></title>
    <link id="linkStyle" runat="server" href="../Themes/Blue/css.css" rel="stylesheet"
        type="text/css" />
    <style type="text/css">
        #ifWin
        {
            height: 300px;
            width: 496px;
        }
        .liStyle li
        {
            list-style-type: none;
            list-style-position: outside;
            float: left;
            text-align: center;
            height: 25px;
            line-height: 25px;
            vertical-align: middle;
        }
    </style>
    <script type="text/javascript"> 
<!--
        var FocusState = true;
        function Focus() {
            if (FocusState) {
                if (document.getElementById("tbxContent") != null)
                document.getElementById("tbxContent").focus();
            }
        }

        //计算输入状态 延时3秒
        var tempTextLength = 0;
        var tempCount = 0;
        var change = false;

        function GetPostTextLength() {

            if (document.getElementById("tbxContent") == null)
                return;

            var count = tempCount;
            if (tempCount > 2) {
                tempCount = 0;
                var length = document.getElementById("tbxContent").value.length;
                if (length != tempTextLength) {
                    tempTextLength = length;
                    change = true;
                }
                else {
                    change = false;
                }
            }
            else {
                tempCount++;
            }
            return count + "$" + change;
        }

        function Writing() {
            document.getElementById("divWriting").style.display = "block";
            document.getElementById("spanWriting").style.display = "block";
        }

        function WriteStop() {
            document.getElementById("divWriting").style.display = "none";
            document.getElementById("spanWriting").style.display = "none";
        }


        function hotkey() {
            var a = window.event.keyCode;
            if (((a == 13) && (event.ctrlKey)) || ((a == 83) && (event.altKey))) {
                document.getElementById("btnPost").click();
            }
        } // end hotkey

        document.onkeydown = hotkey; //当onkeydown 事件发生时调用hotkey函数
        //document.onclick = Focus;
        window.onfocus = Focus;
//--> 
    </script>
</head>
<body style="padding:0px">
    <script type="text/javascript">
        function AJAX_Request() {
            var data = document.getElementById("tbxContent").value;
            AJAX_GetCallbackEvent(data);
        }

        function AJAX_Respone(data) {
            if (data != "") {
                document.getElementById("tbxContent").value = "";
                FocusState = true;
                Focus();
            }
        }
    </script>
    <form id="form1" runat="server">
    <div>
        <table class="table" cellspacing="0" style="width: 500px; margin-right: auto; margin-left: auto;
            margin-top: 5px">
            <tr>
                <th>
                    <div style="margin: 4px; height: 20px; line-height: 20px; vertical-align: middle;">
                        <div style="width: 20px; height: 20px; float: left; background-repeat: no-repeat"
                            id="divFace" runat="server">
                            <div style="width: 20px; height: 20px; background-repeat: no-repeat; display: none"
                                class="tips_writing" id="divWriting">
                            </div>
                        </div>
                        <div style="float: left">
                            <asp:Literal ID="litTrueName" runat="server"></asp:Literal></div>
                        <div style="float: left">
                            <span id="spanWriting" style="display: none; margin-left: 10px">正在输入</span>
                        </div>
                        <div style="clear: both; height: 0px; overflow: hidden">
                        </div>
                    </div>
                </th>
            </tr>
            <tr>
                <td style="text-align: center;">
                    <iframe frameborder="1" scrolling="yes" runat="server" id="ifWin"></iframe>
                </td>
            </tr>
            <tr>
                <td style="text-align: center">
                    <div style="margin-left: auto; margin-right: auto">
                        <asp:TextBox ID="tbxContent" runat="server" Height="88px" TextMode="MultiLine" Width="496px"></asp:TextBox>
                        <br />
                        <div style="float: right; margin-right: 5px">
                            <asp:HyperLink ID="hlkChatMsg" runat="server" NavigateUrl='<%# string.Format("ChatMsg.aspx?UserID={0}",Request.QueryString["UserID"]) %>'
                                Target="_blank" Text="聊天记录"></asp:HyperLink>
                            <label class="lab_buttom"><input id="btnPost" style="width: 131px" type="button" value="发送(Ctrl + Enter)" onclick="AJAX_Request()"
                                runat="server" /></label><span runat="server" id="spanCtrl"></span>
                        </div>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
