<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="QuesNaireStatistics.aspx.cs"
    Inherits="RM.Web.Training.QuesNaire.QuesNaireStatistics" %>

<!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><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("QuesNaire_wjdc")%></title>
    <link href="../Exam/Themes/Css/ExamGlobal.css" rel="stylesheet" type="text/css" />
    <link href="Themes/QuestionnaireCss.css" rel="stylesheet" type="text/css" />
    <link href="../../Themes/Scripts/ShowMsg/msgbox.css" rel="stylesheet" type="text/css" />
    <script src="../../Themes/Scripts/ShowMsg/msgbox.js" type="text/javascript"></script>
    <script src="../../Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/FunctionJS.js" type="text/javascript"></script>
    <script>
        /**显示进度条
        /*value:         进度值
        /*maxvalue:      总值
        /*color:        （可选）进度条需要显示的颜色
        **/
        function getprogress(value, maxvalue, color) {
            var w;
            if (maxvalue <= 0)
                w = 0;
            else
                w = value * 100 / maxvalue;
            if (value > maxvalue) {
                w = 100;
            }
            document.writeln("<div class=\"process-bar\">");
            document.writeln("     <div class=\"pb-wrapper\">");
            //document.writeln("          <div class=\"pb-highlight\"></div>");
            document.writeln("          <div class=\"pb-container\">");
            document.writeln("               <div class=\"pb-text\">");
            document.writeln("               " + value + "/" + maxvalue + "</div>");
            if (color == undefined || color == "") { color = "" } else { color = "background-color:" + color + ";"; }
            document.writeln("               <div class=\"pb-value\" style=\"width: " + w + "%;" + color + "\">");
            document.writeln("               </div>");
            document.writeln("         </div>");
            document.writeln("     </div>");
            document.writeln("</div>");
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <%--<a class="button green" onclick="printer();" title="打 印"><span style="background: url('/Themes/images/16/printer.png') no-repeat scroll 0px 4px;" class="icon-botton"></span>打 印</a>--%>
    <div id="div-body">
    <div id="pageContainer">
        <div id="que_title">
            <h1 id="que_name" runat="server">
            </h1>
        </div>
        <div id="container">
            <div id="context">
                <ol>
                    <%=QuestionHtml %>
                </ol>
            </div>
        </div>
    </div>
    </div>
    
    </form>
    <script src="/Themes/Scripts/LodopFuncs.js" type="text/javascript"></script>
    <object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width="0"
        height="0">
        <embed id="LODOP_EM" type="application/x-print-lodop" width="0" height="0"></embed>
    </object>

    <script type="text/javascript">
        var LODOP; //声明为全局变量 
        function printer() {
            LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
            LODOP.PRINT_INIT('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Learn_xxjidubaobiao")%>');
            var strBodyStyle = "";// "<style>table{width:100%;border: 1 solid #000000;border-collapse:collapse }td {border: 1 solid #000000;border-collapse:collapse }</style>";
            LODOP.ADD_PRINT_TABLE(0, 0, "100%", '100%', strBodyStyle + document.getElementById("div-body").innerHTML);
            LODOP.PREVIEW();
        }

        $(function () {
            if ($("#context>ol>li").length < 1) {//页面异常
                $("#context").html("");
                ZENG.msgbox.show('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("QuesNaire_tishi")%>', 5, 2000);
                return;
            }
            function resizeimg(objImg, maxWidth, maxHeight) {
                ///	<summary>
                ///     根据图片对象和指定的参数按比例缩放图片
                ///     &#10;1: resizeimg(obj, maxW, maxH) - 根据图片对象和指定的参数按比例缩放图片
                ///	</summary>
                ///	<param name="obj" type="ImageObject">图片对象</param>
                ///	<param name="maxW" type="int">最大宽度</param>
                ///	<param name="maxH" type="int">最大高度</param>
                ///	<returns type="string" />
                var img = new Image();
                img.src = objImg.src;
                var hRatio;
                var wRatio;
                var Ratio = 1;
                var w = img.width;
                var h = img.height;
                wRatio = maxWidth / w;
                hRatio = maxHeight / h;
                if (maxWidth == 0 && maxHeight == 0) {
                    Ratio = 1;
                } else if (maxWidth == 0) {//
                    if (hRatio < 1) Ratio = hRatio;
                } else if (maxHeight == 0) {
                    if (wRatio < 1) Ratio = wRatio;
                } else if (wRatio < 1 || hRatio < 1) {
                    Ratio = (wRatio <= hRatio ? wRatio : hRatio);
                }
                if (Ratio < 1) {
                    w = w * Ratio;
                    h = h * Ratio;
                }
                objImg.height = h;
                objImg.width = w;
            }
            if ($.browser.msie) {
                var imgList = $("#context img");
                for (var i = 0; i < imgList.length; i++) {
                    resizeimg(imgList.get(i), 600, 500);
                }
            } else {
                $("#context img").load(function () {
                    resizeimg(this, 600, 500);
                });
            }
            //异步加载数据方法
            function downPage(linkObj, containerObj, backFu) {
                if (linkObj.attr("end") == "0") { backFu(); return; };
                var currIndex = parseInt(linkObj.attr("currindex"));
                var sumCount = parseInt(linkObj.attr("sumcount"));
                var queKey = linkObj.attr("qKey");
                if (currIndex > sumCount) {//数据不正确
                    linkObj.attr("end", "1");
                    linkObj.css("cursor", "text").text('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Null")%>');
                    backFu();
                    return;
                }
                linkObj.attr("end", "0").text('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Ques_loading")%>');
                $.ajax({
                    url: "LoadTxtDetail.ashx",
                    type: "post",
                    data: { "currIndex": currIndex, "sumCount": sumCount, "qKey": queKey },
                    dataType: "text",
                    success: function (data) {
                        if (data) {
                            if (data == "-2") {
                                linkObj.attr("end", "0").css("cursor", "text").text('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Null")%>');
                            } else {
                                containerObj.append(data);
                                if (currIndex + 1 > sumCount)
                                    linkObj.attr("end", "0").css("cursor", "text").text('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Null")%>');
                                else
                                    linkObj.css("cursor", "pointer").attr({ "currindex": currIndex + 1, "end": "1" }).text('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("QuesNaire_djjxjz")%>');
                            }
                        } else {
                            linkObj.attr("end", "1").css("cursor", "pointer").text('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Abnormal network connection")%>');
                        }
                        backFu();
                    },
                    error: function () {
                        linkObj.attr("end", "1").css("cursor", "pointer").text('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Abnormal network connection")%>');
                        backFu();
                    }
                });
            }

            $(".txtInfo").click(function () {
                var $currObj = $(this);
                var state = parseInt($currObj.attr("state"));
                switch (state) {
                    case 0: //显示
                        if ($currObj.parent().next().children(".detailContainer").children("li").length < 1) {
                            $currObj.attr("state", 2).text('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Ques_loading")%>'); //第一次加载
                            downPage($currObj.parent().next().find(".downPage"), $currObj.parent().next().children("ul"), function () {
                                $currObj.css("border-bottom", "1px solid White").text('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("QuesNaire_djsq")%>');
                                $currObj.parent().next().stop().slideDown(200, function () {
                                    $currObj.attr("state", 1);
                                });
                            });
                        } else {
                            $currObj.css("border-bottom", "1px solid White").text('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("QuesNaire_djsq")%>');
                            $currObj.parent().next().stop().slideDown(200, function () {
                                $currObj.attr("state", 1);
                            });
                        }
                        break;
                    case 2:
                        break;
                    default: //隐藏
                        $currObj.parent().next().stop().slideUp(200, function () {
                            $currObj.css("border-bottom", "1px solid #dddbdb").text('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("QuesNaire_djzk")%>');
                            $currObj.attr("state", 0);
                        });
                        break;
                }
            });

            $(".downPage").click(function () {
                downPage($(this), $(this).parent().prev());
            });
        });
    </script>
</body>
</html>
