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

<!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>
        <%=csname %>_<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_SfenModel")%>
    </title>
    <link href="../../Themes/Styles/Site.css" rel="stylesheet" type="text/css" />
    <link href="m/Learn.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
h1 { font-size: 18px; color: #434242; margin: 10px; font-weight: normal; }
h1 span { color: Blue; }
.left_win { position: absolute; top: 0; left: 0; width: 250px; height: 100%; background-color: #f4f4f4; border-right: 1px #dcdcdc solid; }
.left_winvideo{text-align: left; position: relative; background-color: #020301;
            background-image: url('m/learnplay_bg.gif'); background-position: center; background-repeat: no-repeat;
            height: 200px; z-index: 999;}
.zhangjie { margin: 10px 0px 10px 10px; padding: 0; overflow-y:scroll; height:158px; }
.zhangjie li { margin: 3px 0; padding: 0; list-style: none; text-align: center; padding: 3px; margin-right: 5px; color: #434242; background-color: White; border: 1px #dcdcdc solid; }
.zhangjie li:hover { background-color: #04d204; }
.zhangjie li:hover a { color: White; }
.zhangjie .hover { background-color: #04d204; }
.zhangjie .hover a { color: White; }
.zhangjie .old { background-color: #f4f4f4; }
.zhangjie .old a { color: #999; }
.center_win{ padding-left:260px; padding-right:40px;}
.right_win{ position: absolute; right: 0; background-color: #f4f4f4; width: 40px; height: 100%; border-left: 1px #dcdcdc solid; text-align: center; }
.right_win a { display: block; height: 35px; border-bottom: 1px #dcdcdc solid; padding-top: 5px; }
.right_win a:hover { background-color: #e9e9e9; }
.right_win .hover { background-color: #e9e9e9; width: 41px; }
#interFooter{ margin: 10px 0px 10px 5px; padding: 0; }
</style>
</head>
<body>
    <div class="left_win" id="">
        <div class="left_winvideo">
            <div id="video">
                <img src="../../Themes/Images/16/cog.png" style="cursor: pointer; position: absolute;
                    top: 10px; right: 10px; z-index: 9999;" alt='<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Learn_movetz")%>'
                    title='<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Learn_movetz")%>' width="16"
                    height="16" onclick="CKobject.getObjectById('ckplayer_a1').ckplayer_plugin('adjustment.swf',true);" />
                <div id="a1">
                </div>
            </div>
        </div>
        <div class="zhangjie" id="zhangjie">
            <%=ziyuan %>
        </div>
        <div class="Interacts" id="Interacts">
            <div class="interHead">
                <h1>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Int_xxhd")%><span>Interacts</span></h1>
            </div>
            <div class="interMain" id="interMain" style="overflow-y: scroll; height: 50px;">
            </div>
            <div id="interFooter">
                <textarea cols="32" rows="5" id="interText" onclick="myinput(this)" onblur="inputonblur(this)"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Learn_fayan")%></textarea>
                <div style="text-align: right">
                    <%=RM.Common.DotNetBean.RequestSession.GetSessionUser()==null?"":RM.Common.DotNetBean.RequestSession.GetSessionUser().UserName.ToString() %>
                    <input type="button" value='<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Button_fabu")%>'
                        onclick="setchart()" /></div>
            </div>
        </div>
    </div>
    <div class="right_win" id="left_menu">
        <a href="#" class="hover">
            <img alt='<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_wendang")%>'
                src="/Themes/Images/16/projection-screen-presentation.png" /><br />
            <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_wendang")%></a>
    </div>
    <div class="center_win">
        <h1>
            <%=csname %><span id="cstitle"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Learn_firstjie")%></span></h1>
        <iframe src="Learn_FenWen.aspx?Key=<%=Request.QueryString["Key"]  %>" id="scormHtml"
            style="text-align: left; position: relative; background-color: White; background-position: center;
            background-repeat: no-repeat; z-index: 999;min-height:800px; width: 99%; border: 1px #dcdcdc solid;">
        </iframe>
    </div>
    <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 type="text/javascript" src="/Themes/Scripts/ifvisible.js"></script>
    <script type="text/javascript" src="/Training/Learn/m/ckplayer/ckplayer.js" charset="utf-8"></script>
    <script type="text/javascript">
 var playTime = 0;  //全局变量，当前视频播放时间,单位秒
        var playVodieId = "";
        var dqbh = 0; //当前应该播放的视频索引，默认是0
        var flvurl = new Array(); //视频地址组
        var API = "NOTSCRIPT";
        <%=varstring %>
       
        playerstop(); //默认页面加载的时候先运行一次播放当前索引为0的视频
        
        //视频高度自适应
        function iframeresize() {
            resizeU();
            $(window).resize(resizeU);
            function resizeU() {
                var divkuangH = $(window).height();
                $("#scormHtml").css("height", divkuangH - 50);
                $("#interMain").css("height",divkuangH-400-document.getElementById("zhangjie").offsetHeight);
                $("#zhangjie").css("height",divkuangH-500);                
            }
        }
          //防挂机
            document.writeln("<div class=\"well\" id=\"guaji\"  style=\"position:absolute; left:50%; margin-left:-200px;top:25px; width:400px; font-size:12px; background:#f4f4f4; color:#red; padding:5px; z-index:9999;\"><div id=\"guaji_text\"  style=\"color:#red;\">" + lgLearnPCguajiValidata + "</div><div id=\"guaji_err\" style=\"color:red; text-align:center; font-weight:bold;\"></div><div class=\"progress\" style=\"height:20px; border:1px #ccc solid; background-color:#FFFFFF; margin:5px;\"><div class=\"bar\" id=\"idlebar\" style=\"width: 0%;background-color:red; height:20px;\"></div></div></div>");
            ifvisible.setIdleDuration(600);
            ifvisible.idle(function () {
                $("#guaji_err").html(lgLearnxiumian);
                 Tstate = 0;
                if (CKobject.getObjectById('ckplayer_a1') != null) { CKobject.getObjectById('ckplayer_a1').videoPause(); }
                $("#guaji_err").show();
                $("#guaji_text").hide();
            });
            ifvisible.wakeup(function () {
                Tstate = 1;
                if (CKobject.getObjectById('ckplayer_a1') != null) { CKobject.getObjectById('ckplayer_a1').videoPlay(); }
                $("#guaji_text").show();
                $("#guaji_err").hide();
            });
            setInterval(function () {
                var info = ifvisible.getIdleInfo();
                if (info.timeLeftPer < 3) {
                    info.timeLeftPer = 0;
                    info.timeLeft = ifvisible.getIdleDuration();
                }
                $("#idlebar").css("width", info.timeLeftPer + "%");
                if (info.timeLeftPer > 50) { $("#guaji").show(); } else { $("#guaji").hide(); }
            }, 100);

function playerstop(obj) {
    //这是点击视频名称的动作，把要播放的视频索引赋给当前要播放的视频索引然后调用播放类（也就是视频结束类）
    //alert("1");
    if ($("#video").is(":hidden")) {
        /*$("#scormHtml").attr("src", "").hide();*/
        $("#video").show();
    }
    CKobject._K_('video').innerHTML = '<div id="a1"></div>';
    $("#interMain").html("<center style=\"color: #999;\"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Learn_notfayan")%></center>");
    if ($(".hover").length > 0)
        $(".hover").removeClass("hover").addClass("old");
    if (obj == undefined || obj == null) {
        //设置当前播放的列表样式
        for (var i = 0; i < flvurl.length; i++) {
            if (i == dqbh) {
                //alert("2");
                CKobject._K_('list_' + i).className = 'hover'; //设置新的样式
                $("#cstitle").html($("#list_" + i).find("a").text());
                playVodieId = $("#list_" + i).find("a").attr("id"); //得到现在播放的ID
            }
        }
    } else {
        $(obj).parent().removeClass("old").addClass("hover");
        $("#cstitle").html($(obj).text());
        playVodieId = $(obj).attr("id"); //得到现在播放的ID
    }
    
    //设置列表样式结束
    var flashvars = {
        f: flvurl[dqbh],
        c: 0,
        b: 0,
        p: 1,
        e: 0,
        loaded: 'loadedHandler'
    };
    var params = { bgcolor: '#000', allowFullScreen: true, allowScriptAccess: 'always', wmode: 'opaque' };
    CKobject.embedSWF('/Training/Learn/m/ckplayer/ckplayer.swf', 'a1', 'ckplayer_a1', '100%', '200', flashvars, params);
    
    //当为MP4格式时调用HTML5
    var houzhui = "";
    if(flvurl.length>0){
    houzhui = flvurl[dqbh].substring(flvurl[dqbh].lastIndexOf(".") + 1);
    }
    //alert(houzhui);
    if (!CKobject.Flash()['f']) {//当系统不支持FLASH时
        if (browser.versions.android) {//安卓建议安装flash, 这样才能支持横屏
            $("#noflash").html("<a href=\"http://www.newstartsoft.com/flashplayer.apk\"  target=\"_blank\" style=\"color:red\"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Learn_anzhuangflash")%></a>");
            document.getElementById("noflash").style.display = "block";
        }
        else {
            if (houzhui == "mp4") {
                var video = [flvurl[dqbh] + '->video/mp4'];
                var support = ['iPad', 'iPhone', 'ios', 'android', 'msie10+false', 'webKit', 'IEMobile'];
                CKobject.embedHTML5('video', 'ckplayer_a1', '100%', '200', video, flashvars, support);
            }
        }
    }


    dqbh = dqbh + 1; //把正在播放的视频的索引+1得到下个视频的索引用来做循环播放
    if (dqbh >= flvurl.length) {
        //全部视频都播放完成后，目前回到第一个视频，也可以对用户进行提示
        dqbh = 0;
    }
    iframeresize();
   
    //    windowActive();
}
    
// function loadedHandler(){
//CKobject.getObjectById('ckplayer_a1').addListener('time', 'timego');
//  }
function playload(obj, str) {
    dqbh = str;
    playerstop(obj);
}
//html网页资源课件的点击事件
function showHtml(obj, urlSrc) {
    if(urlSrc.substring(urlSrc.lastIndexOf(".") + 1) == "html" || urlSrc.substring(urlSrc.lastIndexOf(".") + 1) == "htm")
    {
        AddHtml("video", "100%", "100%");
    }
    else
    {
        if ($("#scormHtml").is(":hidden")) {
            $("#ckplayer_a1").remove();
            $("#video").hide();
            $("#scormHtml").show();
        }
        playTime = 0;
      //  setInterval(function () { playTime++; }, 1000);
        $(".hover").removeClass("hover").addClass("old");
        $(obj).parent().removeClass("old").addClass("hover");
        playVodieId = $(obj).attr("id");
        $("#scormHtml").attr("src", urlSrc);
        $("#cstitle").html($(obj).text());
        iframeresize();
        //    windowActive();
        }
}

function AddHtml(Cantent, Height, mima) {
        /// <summary>
        /// 静态类内容
        /// </summary>
        $("#" + Cantent).html("");
        $("#" + Cantent).append("<iframe  style=\"text-align: left; background-color: #fff; background-position: center;background-repeat: no-repeat; border: none; width: 100%;Height:" + Height + "px\" src='" + mima + "'></iframe>");
    }


$(function () {
    iframeresize(); //自动调整页面自适应尺寸
    setInterval(getchart, 10000); //加载互动信息,10秒查1次
    setInterval(Setlearntime, 60000); //统计学习时间,10秒统计1次，越小统计精度越大
          
        });   
//更新统计学习时间
function Setlearntime() {
  
    $.get("/Training/Learn/Interacts.ashx?Key=" + QueryString("Key") + "&t=" + zanting);
}
function right_frameclose() {
    $("#right_frame").animate({ right: "-187px" }, function () { $("#Tmain").css("margin-right", "0"); });
    $("#right_frame_btn").attr("src", "/Training/Learn/m/tringht_open.gif");
    $("#right_frame_btn").attr("onclick", "right_frameopen(this)");
}
function right_frameopen() {
    $("#right_frame").animate({ right: 0 }, function () { $("#Tmain").css("margin-right", "187px"); });
    $("#right_frame_btn").attr("src", "/Training/Learn/m/tringht_close.gif");
    $("#right_frame_btn").attr("onclick", "right_frameclose(this)");
}
//菜单操作
function rightgo(obj, id) {
    // right_frameclose();
    $("#left_menu a").removeClass("hover");
    $(obj).addClass("hover");
    if (id == 1) {
        $("#Interacts").show()
        $("#rightmain").hide();
    } else if (id == 2) {
        $("#rightmain").attr("src", "Learn_Shares.aspx?Key=" + QueryString("Key"));
        $("#rightmain").show();
        $("#Interacts").hide();

    } else if (id == 3) {
        $("#rightmain").attr("src", "/Training/Exam/Practise_List.aspx?Key=" + QueryString("Key"));
        $("#rightmain").show();
        $("#Interacts").hide();
    } else if (id == 4) {
        $("#rightmain").attr("src", "/Training/Exam/Practise_List.aspx?Key=" + QueryString("Key") + "&type=1");
        $("#rightmain").show();
        $("#Interacts").hide();
    } else if (id == 5) {
        $("#courBar").css('display', 'block');
        $("#courDetail").stop().animate({ left: 5 });
    }
    else {
        window.open("/Frame/MainPet.aspx?url=/Training/ExamPlan/ExamSchoolAssignment.aspx?Key=" + QueryString("Key"));
    }
    right_frameopen();
}

//视频播放
function playstart() {
    CKobject.getObjectById('ckplayer_a1').ckplayer_play();
   
}

//切换播放视频
function playGoto(filepath) {
    //参数格式：{f->http://movie.ks.js.cn/flv/2012/02/6-1.flv}
    CKobject.getObjectById('ckplayer_a1').ckplayer_newaddress(filepath);
}
//播放状态监控
var zanting = 1;

function ckplayer_status(str) {
    //103暂停，102开始播放，101播放结束，105全屏，108加载结束（准备就绪）
    //$("#interText").val(str);//反馈数据测试
   
    var nowtime = str.substring(0, 5);
    if (nowtime == "time:") {
        playTime = str.substr(5); //当前播放时间
        zanting = 1;
    }
    else if (str == 'Play') {
        alert("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Learn_notmove")%>"); //106打开视频错误
    }
    else if (str == 'Pause') {
        zanting = 0;
    } else if (str == 102) {//当正在播放才触发事件
    }
    else if (str.length > 10) {
        //alert(str); 
    }
}
//获取互动
function getchart() {
    // alert("asd");
   $.get("/Training/Learn/Interacts.ashx?action=Interacts&Key=" + QueryString("Key") + "&pid=" + playVodieId + "&Time=" + playTime, function(data){
    data = data.replace('\n','');
    eval(data);
   });
    $("#interMain").scrollTop(100);
}
function timego(times) {
    /// <summary>
    /// 监听视频播放时间
    /// </summary>

    playTime = times;
}
//发言
function setchart() {
    
   
    $.get("/Training/Learn/Interacts.ashx",
            { Key: QueryString("Key"), pid: playVodieId, Time: playTime, ChartText: $("#interText").val() },
            function (data) {
                if (data == "ok") {
                    $("#interMain").prepend("<p class='schart'><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Learn_woshuo")%>:" + $("#interText").val() + "<span>" + playTime + "</span></p>");
                    getchart();
                }else if(data=="1ok")
                {
                alert(lghudongshenhe);
                }
                else if (data == "nouser") {
                    alert("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Learn_stopfayan")%>");
                }
                else {
                    alert("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Learn_fayanfailure")%>");
                }
            });
}
//点击发言区
function myinput(obj) {
    if (obj.value == "<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Learn_fayan")%>") {
        obj.value = "";
    }
}
//鼠标移动开时
function inputonblur(obj) {
    if (obj.value == "") {
        obj.value = "<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Learn_fayan")%>";
    }
}
var zantingdian = -1; //上一次暂停点记录（防止重复暂停）
function loadedHandler() {
    /// <summary>
    /// 播放器加载完成监听
    /// </summary>
   
    window.top.onblur = function () {
        if (zantingdian == -1)//弹出窗口后无效
        {
            try {
                Tstate = 0;
                CKobject.getObjectById('ckplayer_a1').videoPause();
            }
            catch (e) { }
        }
    };
    window.top.onfocus = function () {
        if (zantingdian == -1)//弹出窗口后无效
        {
            try {
                Tstate = 1;
                CKobject.getObjectById('ckplayer_a1').videoPlay();
            }
            catch (e) { }
        }
    }
}
    </script>
</body>
</html>
