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

<!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">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
<head>
    <title>
        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Learn_onlineyulan")%></title>
    <link href="/Themes/Styles/Site.css" rel="stylesheet" type="text/css" />
    <script src="/Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <link href="/Themes/Scripts/artDialog/skins/opera.css" rel="stylesheet" type="text/css" />
    <script src="/Themes/Scripts/artDialog/artDialog.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/artDialog/iframeTools.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/FunctionJS.js" type="text/javascript"></script>
    <script type="text/javascript">
        function getExamList(key, epk) {
            openDialog("/Training/Exam/ExamIntroduce.aspx?ExamKey=" + key + "&exam=" + key + "&EPKey=" + epk, 'Examination_Test', '<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterIndex_sjlb")%> - <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterIndex_ksxz")%>', 650, 380, 50, 50);
            //window.location = "/Training/Exam/CorrectExam.aspx?HashKey=67dcdaed-6dff-4f53-a521-4e7af50c4cee";
            return false;
        }
        function Golianxi(examId) {
            window.open("/Training/Exam/Practise.aspx?EKey=" + examId); //进入练习
        }
        function ExamShow() {
            $("#ExamBtn").show();
        }
        function ExamClose() {
            $("#ExamBtn").hide();
        }
        var url = QueryString("p");

        if (url.indexOf("htm") >= 0) {
            $("#kaoshi").hide();
        }
        var browser = {
            versions: function () {
                var u = navigator.userAgent, app = navigator.appVersion;
                return {         //移动终端浏览器版本信息
                    trident: u.indexOf('Trident') > -1, //IE内核
                    presto: u.indexOf('Presto') > -1, //opera内核
                    webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
                    gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
                    mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
                    ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
                    android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器
                    iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
                    iPad: u.indexOf('iPad') > -1, //是否iPad
                    wp: u.indexOf('IEMobile') > -1, //是否wp
                    symbianos: !!u.match(/SymbianOS.*/), //是否SymbianOS
                    webApp: u.indexOf('Safari') == -1 //是否web应该程序，没有头部与底部
                };
            } (),
            language: (navigator.browserLanguage || navigator.language).toLowerCase()
        }
        $(function () {
            if (browser.versions.ios) {
                $("#lineheader").show();
            }
        });
    </script>
</head>
<body oncontextmenu="window.event.returnvalue=false">
    <div id="ExamBtn" style="position: absolute; height: 300px; background-color: White;
        left: 40%; top: 20%; width: 300px; display: none; overflow: auto; z-index:10;">
        <div class="div-body">
            <table border="0" cellpadding="0" cellspacing="0" class="grid">
                <thead>
                    <tr>
                        <th>
                            <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("MyExamPlan-sjm")%>
                        </th>
                        <th>
                            <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Mylearn-ks")%>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <%=htmlstr %>
                    <tr>
                        <td colspan="2">
                            <input type="button" onclick="ExamClose()" value='<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Close")%>' />
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div id="lineheader" style="height:20px;background-color:#4e91dc; display:none;"></div>
    <div class="osfooter" style="background: #f4f4f4; height: 45px;">
        <a href="#" onclick="backgo();" id="goback" class="dc_submit closeLive" style=" display:none; transition: all 0.2s linear 0s;vertical-align: bottom;width: 90px;height: 30px;
            line-height: 30px; background-color: Red; background-color: #11DA86; text-align: center; color: White; margin-top: 8px; margin-right: 8px; float: left; margin-left: 10px;">返回</a>
        <h1 style="float: left; font-size: 16px; margin-left: 8px;">
            <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("office_wdzxyl")%></h1>

        <a href="javascript:ExamShow();" id="kaoshi" class="dc_submit closeLive" style="transition: all 0.2s linear 0s;
            vertical-align: bottom; width: 90px; height: 30px; line-height: 30px; background-color: Red;
            background-color: #d33031; display: block; text-align: center; color: White;
            margin-top: 8px; margin-right: 8px; float: right;">
            <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Mylearn-ks")%></a>
        <%=downbutton %>
    </div>
    <div id="flashplayer" style="overflow: scroll; height: 98%; background-color: #999;
        display: none;">
    </div>
    <div id="osloading" style="width: 600px; margin: 10px auto; background: #f4f4f4;
        text-align: center; line-height: 30px; border: 1px #ccc solid;">
        <img src="nooffice.gif" width="600" height="400" alt="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("office_wdydq")%>" />
        <img src="/Themes/Images/loading.gif" width="16" height="16" alt="loading" style="margin-bottom: -3px;" />
        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("office_showinit")%>....
    </div>
    <script type="text/javascript" src="js/swfobject/swfobject.js"></script>
    <script type="text/javascript" src="js/flexpaper_flash_debug.js"></script>
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/pdf.js"></script>
    <script src="js/Base64.js" type="text/javascript"></script>
    <script type="text/javascript">
        function backgo() {
            top.location.href = "/Training/Learn/Learn_ListMoblie.aspx?load=mycourse";
        }
        $(function () {
            if (document.body.clientWidth < 1000) {
                $("#goback").show();
            }
            getword();
            //如果未登录 跳转到首页
            //            getAjax("/Mall/Mall_HeadLoginStatus.ashx", "id=2", function (rs) {
            //                if (rs == "end") {
            //                    location.href = "/";
            //                }
            //            });
            $(document).bind("contextmenu", function () { return false; });
        });
        function getword() {
            var houzhui = '<%=officepath %>'.substring('<%=officepath %>'.lastIndexOf(".") + 1);
            if (houzhui == "pdf" && typeof (Worker) !== "undefined") {
                pdfshow('?file=<%=officepath %>');
            }
            if ('<%=officepath %>'.substring('<%=officepath %>'.lastIndexOf(".") + 1) == "pdf") {
                $("#osloading").hide();
                $("#flashplayer").show();
                var file = "<%=officepath %>";
                file = base64encode(file);
                file = "?file=" + file;
                pdfshow(file);
            }
            if (houzhui == "bmp" || houzhui == "jpg" || houzhui == "jpge" || houzhui == "png") {
                imgshow('<%=officepath %>');
                return;
            }  else {
            $.post("GetOffice.ashx", { p: '<%=officepath %>' },
            function (data) {
                if (data == "go") {
                    $("#osloading").hide();
                    $("#flashplayer").show();
                    if (typeof (Worker) !== "undefined") {//当支持HTML5时
                        // var file = "?file=<%=filespath %>".replace(".swf", ".pdf");
                        var file = "<%=filespath %>".replace(".swf", ".pdf");
                        file = base64encode(file);
                        file = "?file=" + file;
                        pdfshow(file);
                    }
                    else {
                        var swfVersionStr = "10.0.0";
                        var xiSwfUrlStr = "playerProductInstall.swf";
                        var emotion = "<%=filespath %>";
                        var swfFile = emotion;
                        var flashvars = { SwfFile: escape(swfFile), Scale: 0.6, ZoomTransition: "easeOut", ZoomTime: 0.5, ZoomInterval: 0.2,
                            FitPageOnLoad: false,
                            FitWidthOnLoad: true,
                            PrintEnabled: true,
                            FullScreenAsMaxWindow: false,
                            ProgressiveLoading: true,
                            PrintToolsVisible: false,
                            ViewModeToolsVisible: true,
                            ZoomToolsVisible: true,
                            FullScreenVisible: true,
                            NavToolsVisible: true,
                            CursorToolsVisible: true,
                            SearchToolsVisible: true,
                            localeChain: "zh_CN"
                        };
                        var params = {};
                        params.quality = "high";
                        params.bgcolor = "#ffffff";
                        params.allowscriptaccess = "sameDomain";
                        params.allowfullscreen = "true";
                        params.wmode = "transparent";
                        var attributes = {};
                        attributes.id = "FlexPaperViewer";
                        attributes.name = "FlexPaperViewer";
                        //document.getElementById("flashplayer").innerHTML = "<embed id='flashplay' width='100%' src=<%=filespath %> ></embed>";
                        var divkuangH = $(window).height();
                        swfobject.embedSWF("FlexPaperViewer.swf", "flashplayer", "100%", "98%", swfVersionStr, xiSwfUrlStr, flashvars, params, attributes);
                        swfobject.createCSS("#flashplayer", "display:block;text-align:left;"); // resizeU();
                    }  
                    $("#FlashID").show();
                }
                else {
                    $("#osloading").html("<img src=\"/Themes/Images/16/01.png\" width=\"16\" height=\"16\" style=\" margin-bottom:-3px;\" /> " + data);
                }
            }
      )};
        }
        function pdfshow(file) {
            var divkuangH = $(window).height();
            $("#flashplayer").html("<iframe id=\"osiframe\" name=\"osiframe\" style='width:100%;border:0;height:" + divkuangH + "px' src='officeshow/web/viewer.html" + file + "' />");
            $("#flashplayer").show();
        }
        function imgshow(file) {
            var divkuangH = $(window).height();
            $("#flashplayer").html("<img src='"+file+"' />");
            $("#flashplayer").show();
        }
        function pagego(pageindex) {
            $("#osiframe")[0].contentWindow.pagego(pageindex);
            //document.getElementById("osiframe").pagego(pageindex);
        }
    </script>
</body>
</html>

