<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="mainFrame.aspx.cs" Inherits="Czou2012.UI.Manager.mainFrame" %>

<!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>
     <title>WEB后台管理平台</title>
    <link rel="stylesheet" type="text/css" href="Styles/layout.css" />
    <link rel="stylesheet" type="text/css" href="Scripts/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="Scripts/themes/icon.css" />
    <link type="text/css" rel="stylesheet" href="Styles/table.css" />
    <script type="text/javascript" src="Scripts/jquery.min.js"></script>
    <script type="text/javascript" src="Scripts/jquery.easyui.min.js"></script>
    <script type="text/javascript" src='Scripts/jquery.newtabs.js'> </script>
    <script type="text/javascript" src="Scripts/jquery.validate.field.js"></script>
    <script type="text/javascript" src="Scripts/jquery.cookie.js"></script>
    <script type="text/javascript">
        //创建登录窗口
        function OpenWindow() {
            $('#w').css("display", "");
            $('#w').window({
                title: '用户登录(登录超时)',
                width: 300,
                height: 160,
                modal: true,
                shadow: true,
                closed: true,
                resizable: false
            });
        }

        //关闭登录窗口
        function closeOpenWindow() {
            $('#w').window('close');
        }

        //打开重新登录窗口
        function openReloginWindow() {
            OpenWindow();
            $('#w').window("open");
            $('#loginPassword').focus();
        }

        //重新登录
        function btnReLogin() {
            var username = $.trim($('#loginUserName').val());
            var password = $.trim($('#loginPassword').val());

            var msg = $.ValidateField.ValidateUserName(username);
            if (msg != $.ValidateField.OK) {
                $('#loginUserNameInfo').html("输入有误!");
                $('#loginUserName').focus();
                return;
            } else { $('#loginUserNameInfo').html(""); }

            msg = $.ValidateField.ValidatePassword(password);
            if (msg != $.ValidateField.OK) {
                $('#loginPasswordInfo').html("密码有误!");
                $('#loginPassword').focus();
                return;
            } else { $('#loginPasswordInfo').html(""); }


            $.post('Utility/reLogin.aspx?userName=' + username + '&passWord=' + password + '&type=reLogin', function (msg) {
                if (msg == 'loginOverTimes') {
                    $.messager.alert('系统提示', '登录次数过多，退出系统', 'info');
                    window.location.href = "default.aspx";
                    return;
                }
                if (msg == 'loginError') {
                    //alert('错误用户名和密码，请确认Caps Lock是否打开。');
                    $('#loginPasswordInfo').html("密码有误!");
                    $('#loginPassword').val("");
                    $('#loginPassword').focus();
                    return;

                }
                if (msg == 'ok') {
                    $('#loginPassword').val("");
                    closeOpenWindow();
                    window.location.href = "mainFrame.aspx";
                }
            })

        }
        //重新登录
        function SubIframeAddTab(title, href, icon, closable) {
            $.ajax({
                type: "get",
                url: href,
                beforeSend: function () {
                    addTab(title, "../Manager/Utility/loadingDiv.htm", icon, closable);
                }, //执行ajax前执行loading函数.直到success 
                success: function () {
                    var currTab = $('#tabs').tabs('getTab', title);
                    $('#tabs').tabs('update', { tab: currTab, options: { content: createFrame(href)} });
                    // addTab(title, href, icon, closable);
                } //成功时执行
            });
        }


        $(function () {
            $('#w').window("close");

            $('#reLogin').click(function () {
                openReloginWindow();
            });

            $('#homeImage').click(function () {
                tabAllClose();
                addTab('欢迎光临', 'Utility/cover.aspx', 'icon icon-users', false);
            });

            //Tab控制区
            //默认打开第一个封面页
            addTab('欢迎光临', 'Utility/cover.aspx', 'icon icon-users', false);


            //弹出窗口关闭事件
            $('#btnClose').click(function () { closeOpenWindow(); })

            //获取左边权限树
            $.ajax({  //解决插入Iframe文件后，Jquery没定义的问题;
                type: "GET",
                url: "Utility/leftTree.aspx",
                beforeSend: function () { $("#ifrmLeft").attr("src", "Utility/loadingDiv.htm"); }, //执行ajax前执行loading函数.直到success 
                success: function () { $("#ifrmLeft").attr("src", "Utility/leftTree.aspx"); } //成功时执行Response函数 
            });

            $('#loginOut').click(function () {
                $.messager.confirm('系统提示', '您确定要退出本次登录吗?', function (r) {
                    if (r) {
                        location.href = 'Utility/exitLogin.aspx';
                    }
                });
            })

            if ($.cookie("UserNameCookie") != null) { $("#loginUserName").attr("value", $.cookie("UserNameCookie").toString()); }
        });
		

    </script>
</head>
<body class="easyui-layout" style="overflow-y: hidden" scroll="no">
    <noscript>
        <div style="position: absolute; z-index: 100000; height: 2046px; top: 0px; left: 0px;
            width: 100%; background: white; text-align: center;">
            <img src="images/noscript.gif" alt='抱歉，请开启脚本支持！' />
        </div>
    </noscript>
    <div region="north" split="false" border="false" style="overflow: hidden; margin-bottom: 5px;
        height: 50px; background: #66cccc;">
        <div id="northTop" style="width: 100%; height: 45px; background: url(images/northTopBgLeft.jpg) #7ED7DB repeat-x center 50%;
            line-height: 46px; color: #fff; font-family: Verdana, 微软雅黑,黑体">
            <div style="width: 499px; height: 100%; float: right; background: url(images/northTopBg.jpg) no-repeat right 50%;">
                <div style="width: 260px; height: 100%; padding-top: 10px; float: right; text-align: right;">
                    <input type="hidden" id="ifChange" value="0" />
                    <div id="homeLink" class="hand" style="float: left; width: 35px;margin-top:5px;">
                        <div id="homeImage" class="icons backHomeImage" style="cursor: pointer; float: left;">
                            &nbsp;</div>
                   </div>
                    <div style="float:left;height:25px;">
                        欢迎
                        <asp:Label ID="lblTrueName" runat="server"></asp:Label>&nbsp;&nbsp;<a href="#" class="whiteLink" id="reLogin">重新登录</a>
                        <a href="#"  class="whiteLink" id="loginOut">安全退出</a>
                    </div>
                </div>
            </div>
            <span style="padding-left: 5px; padding-top: 10px;">
                <img src="images/logo.png" align="absmiddle" /></span>
        </div>
    </div>
    <div region="south" hide="true" split="false" border="false" style="height: 5px;
        background: #9DD6FD;">
    </div>
    <div region="west" hide="true" split="true" title="导航菜单" style="width: 180px; background: #fff;
        overflow: hidden" id="west">
        <iframe id="ifrmLeft" src="" style="margin: 0px; padding: 0px; width: 100%; height: 100%;
            border: none;" frameborder="0"></iframe>
        <iframe id="ifrmMiddle" style="width: 0px; height: 0px; background-color: #c6e7ff;
            border: 0px;" name="frmMiddle" frameborder="0"></iframe>
    </div>
    <div id="mainPanle" region="center" style="background: #eee; overflow-y: hidden">
        <div id="tabs" class="easyui-tabs" fit="true" border="false">
            <!-- Tab内容显示区,示例:
			<div title="操作中心" style="padding:0px;overflow:hidden; color:red; " >
				<h1 style="font-size:24px;"></h1>
			</div>
        -->
        </div>
    </div>
    <!--修改重新登录窗口-->
    <div id="w" class="easyui-window" title="" collapsible="false" minimizable="false"
        maximizable="false" icon="icon-save" style="width: 300px; height: 150px; padding: 5px;
        background: #fafafa; display: none;">
        <div class="easyui-layout" fit="true">
            <div region="center" border="false" style="padding: 8px; background: #fff; border: 1px solid #ccc;">
                <table cellpadding="3">
                    <tr>
                        <td>
                            用户名：
                        </td>
                        <td>
                            <input id="loginUserName" type="text" class="txt01" tabindex="1" /><label id="loginUserNameInfo"
                                class="labelInfo"></label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            密 码：
                        </td>
                        <td>
                            <input id="loginPassword" type="password" class="txt01" tabindex="2" onkeydown="javascript:if (event.keyCode == 13){btnReLogin();}" /><label
                                id="loginPasswordInfo" class="labelInfo">必填</label>
                        </td>
                    </tr>
                </table>
            </div>
            <div region="south" border="false" style="text-align: right; height: 30px; line-height: 30px;">
                <a id="btnReLogin" class="easyui-linkbutton" icon="icon-ok" href="javascript:btnReLogin()"
                    tabindex="3">确定</a> &nbsp;&nbsp;<a id="btnClose" class="easyui-linkbutton" icon="icon-cancel"
                        href="#" tabindex="5">关闭</a>
            </div>
        </div>
    </div>
    <%
        if (HttpContext.Current.Session["UserNameSession"] == null)
        {
    %>
    <script type="text/javascript">
        $("#reLogin").click();
    </script>
    <%
        HttpContext.Current.Response.End();
        return;
        }
    %>
</body>
</html>
