<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="col_StuHeader.ascx.cs" Inherits="MTCUN.Mobile.User_Col.col_StuHeader" %>
<%@ Import Namespace="MTCUN" %>
<link id="Link1" runat="server" href="../themes/bottom.css" rel="stylesheet"
    type="text/css" />
<script src="../JScript/Cookie.js" type="text/javascript"></script>
<script type="text/javascript">

    var xmlHttp = null;
    //var newcount = 0;


    //接收消息并返回本地未读消息数。
    function ReceiveMsg() {
        try {
            if (window.XMLHttpRequest) {
                xmlHttp = new XMLHttpRequest();
            }
            else if (window.ActiveXObject) {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlHttp.open("GET", __mt_requesturl + "&action=1&s=" + Math.random(), false);
            xmlHttp.send("");

            var text = xmlHttp.responseText;
            var count = parseInt(text);

            if (count > 0) {
                var sound = true;

                var chat = document.getElementById("__mt_chat");
                if (chat != null) {
                    doRefresh(); //刷新消息列表或对话窗。
                    sound = false;
                }

                //显示消息数。
                setMsgCount(count, sound);
            }
        }
        catch (ex) {
            alert(ex);
        }
    }

    //心跳程序，保持与服务器连接。
    function HeartRequest() {
        try {

            if (window.XMLHttpRequest) {
                xmlHttp = new XMLHttpRequest();
            }
            else if (window.ActiveXObject) {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }

            //连接心跳程序。
            xmlHttp.open("GET", __mt_requesturl + "&action=0&s=" + Math.random(), false);
            xmlHttp.send("");

            //存在新消息，需要更新。
            if (xmlHttp.responseText == "1") {
                ReceiveMsg();
            }

            window.setTimeout(HeartRequest, 15000);
        }
        catch (ex) {
            alert(ex);
            window.setTimeout(HeartRequest, 15000);
        }
    }
    window.setTimeout(HeartRequest, 15000);

    //显示消息数。
    function setMsgCount(num, sound) {
        if (num > 0) {

            if (num > 99) {
                divNum.innerHTML = "<span style='font-size:9px'>99+</span>";
            }
            else {
                divNum.innerHTML = "<span>" + num + "</span>";
            }

            divNumBg.style.display = "block";
            if (sound)
                PaySound();
        } else {
            divNum.innerHTML = "";
            divNumBg.style.display = "none";
        }
    }

    //播放声音。
    function PaySound() {
        try {
            document.getElementById('bgaudio').play();
        } catch (e) {
        }
    }

    function closetip() {
        document.getElementById('divNumBg').style.display = 'none';
    }
</script>
<style type="text/css">
    .header_menu {
        text-align: right;
    }

    #header {
        text-align: right;
    }

    #header_menu, #header_menu ul {
        text-align: right;
    }

    #header_sub {
        right: 0px;
        left: auto;
        bottom: auto;
    }

        #header_sub .dian {
            right: 20px;
            left: auto;
        }
</style>


<div class="btn3 clearfix">

    <div class="menu">
        <div class="bt-name"><a href="cover.aspx" target="myiframe">首页</a></div>
    </div>
    <!--menu-->

    <div class="menu">
        <div class="bt-name" onclick="window.open('Topic.aspx','myiframe'); closetip();">
            <div style="position: relative; max-width: 80px; height: 100%; border: 0px dashed red; padding-left: 20px; padding-right: 20px; margin-left: auto; margin-right: auto">
                消息
                            <div id="divNumBg" style="display: none; border-radius: 10px; position: absolute; background-color: rgba(255, 0, 0,0.9); color: #ffffff; width: 18px; height: 18px; left: 1px; top: 5px">
                                <div id="divNum" style="color: #ffffff;"></div>
                            </div>
            </div>
        </div>
    </div>
    <!--menu-->

    <div class="menu">
        <div class="bt-name">菜单</div>
        <div class="sanjiao"></div>
        <div class="new-sub">
            <ul style="margin: 0px; padding: 0px">

                <li style="border-top-width: 0px">
                    <a href="LessonTable.aspx" target="myiframe">我的课表</a>
                </li>
                <li>
                    <a href="StuClass.aspx" target="myiframe">我的班级</a>
                </li>
                <li>
                    <a href="StuPayment.aspx" target="myiframe">我的钱包</a>
                </li>
                <li>
                    <a href="FoundClass.aspx" target="myiframe">我要购班</a>
                </li>
                <li>
                    <a href="Basic.aspx" target="myiframe">基本信息</a>
                </li>
                <li>
                    <a href="Password.aspx" target="myiframe">修改密码</a>
                </li>
                <li>
                    <a href="exit.aspx" target="myiframe">退出系统</a>
                </li>
            </ul>
            <div class="tiggle"></div>
            <div class="innertiggle"></div>
        </div>
    </div>
    <!--menu-->

</div>
<!--btn3-->

<script type="text/javascript">
    //弹出垂直菜单
    $(".menu").click(function () {
        if ($(this).hasClass("cura")) {
            $(this).children(".new-sub").hide(); //当前菜单下的二级菜单隐藏
            $(".menu").removeClass("cura"); //同一级的菜单项
        } else {
            $(".menu").removeClass("cura"); //移除所有的样式
            $(this).addClass("cura"); //给当前菜单添加特定样式
            $(".menu").children(".new-sub").slideUp("fast"); //隐藏所有的二级菜单
            $(this).children(".new-sub").slideDown("fast"); //展示当前的二级菜单
        }
    });
</script>

<span style="display: none; visibility: hidden">
    <audio id="bgaudio">
        <source src='<%=swq.SystemVirtualPath + "Sound/msg.mp3" %>' type="audio/mpeg">
    </audio>
</span>


<script type="text/javascript">
    //初始化数目。
    setMsgCount(__mt_newmsgcount, true);
</script>
