
///********************************************************************///
//*新启科技自定义学习模式窗体管理功能
//*作者：张新
//*时间：2014年07月27日
///********************************************************************///
$.ajaxSetup({
    cache: false
});
var Tstate = 1; //计时器，0暂停，1正常
var Key = ""; //当前课程ID
var playVodieId = ""; //章节ID
var playTime = 0; //视频播放时间
var mvh = ""; //主视频高度
var ovh = ""; //操作视频高度
var furl = ""; //当前视频地址
var NewstartLearn = new function () {
    /// <summary>
    /// 在线学习操作类
    /// </summary>
    this.LearnLoad = function (MyJson) {
        /// <summary>
        /// 初始化界面窗口【业务逻辑】
        /// </summary>
        Key = QueryString("key");
        if (MyJson != "" && Key != "") {
            var MyWinList = eval(MyJson);
            for (var i = 0; i < MyWinList.length; i++) {
                var ID = MyWinList[i].ID;
                var SysTitle = MyWinList[i].SysTitle;
                var SysWidth = MyWinList[i].SysWidth;
                var SysHeight = MyWinList[i].SysHeight;
                var SZ = MyWinList[i].SZ;
                var SX = MyWinList[i].SX;
                var SY = MyWinList[i].SY;
                if (ID == "Chapter") {
                    ///*********************************************************///
                    ///加载章节目录
                    ///*********************************************************///
                    NewstartWindows.OpenForm(MyWinList[i].ID, MyWinList[i].SysTitle, MyWinList[i].SysWidth, MyWinList[i].SysHeight, MyWinList[i].SZ, MyWinList[i].SX, MyWinList[i].SY, "<div id='Zhangjie'>" + lgzhengzaijiazai + "...</div>");
                    $.get("/Training/Learn/Learn_CustomGet.ashx",
                        { Key: Key, Code: "Chapter" },
                        function (data) {
                            $("#Zhangjie").html(data);
                        }
                    );
                }
                else if (ID == "Mvideo") {
                    ///*********************************************************///
                    ///加载主视频
                    ///*********************************************************///
                    NewstartWindows.OpenForm(MyWinList[i].ID, MyWinList[i].SysTitle, MyWinList[i].SysWidth, MyWinList[i].SysHeight, MyWinList[i].SZ, MyWinList[i].SX, MyWinList[i].SY, "<div id='Mvideo_a1'><center>" + lgzhengzaijiazai + "</center></div>");
                    mvh = MyWinList[i].SysHeight.replace("px", "") - 27 + "px";
                    NewstartWindows.OpenForm(MyWinList[i].ID, MyWinList[i].SysTitle, MyWinList[i].SysWidth, MyWinList[i].SysHeight, MyWinList[i].SZ, MyWinList[i].SX, MyWinList[i].SY, "<div id='Zhangjie'>" + lgzhengzaijiazai + "...</div>");
                    $.get("/Training/Learn/Learn_CustomGet.ashx",
                        { Key: Key, Code: "Mvideo" },
                        function (data) {
                            var flashvars = eval("(" + data.split("|")[0] + ")"); //这是需要异步读取的
                            NewstartLearn.AddMvideo("ckplayer_a1", 'Mvideo_a1', mvh, flashvars);
                            playVodieId = data.split("|")[1];
                            furl = flashvars.f;
                        });
                }
                else if (ID == "Ovideo") {
                    ///*********************************************************///
                    ///加载第二视频（操作视频）
                    ///*********************************************************///
                    NewstartWindows.OpenForm(MyWinList[i].ID, MyWinList[i].SysTitle, MyWinList[i].SysWidth, MyWinList[i].SysHeight, MyWinList[i].SZ, MyWinList[i].SX, MyWinList[i].SY, "<div id='Ovideo_a1'><center>" + lgzhengzaijiazai + "</center></div>");
                    ovh = MyWinList[i].SysHeight.replace("px", "") - 27 + "px";
                    var houzhui = furl.substring(furl.lastIndexOf(".") + 1);
                    if (houzhui == "mp4" || houzhui == "flv") {
                        furl = furl.replace("." + houzhui, "_cz.flv");
                        var flashvars = { f: furl, c: 0, b: 0, p: 1, e: 0 };
                        NewstartLearn.AddVideo("ckplayer_a2", 'Ovideo_a1', ovh, flashvars);

                        //视频同步处理
                        Tongbu = Tongbu.hookend(
                         function Tongbu(str) {
                             var nowtime = str.substring(0, 8);
                             if (nowtime == "nowtime:") {
                                 try {
                                     var a1status = CKobject.getObjectById('ckplayer_a1').ckplayer_getstatus();
                                     var a2status = CKobject.getObjectById('ckplayer_a2').ckplayer_getstatus();
                                     if (a2status != null && a2status != undefined) {
                                         if (a2status.play) {
                                             CKobject.getObjectById('ckplayer_a1').videoPlay();
                                         }
                                         else {
                                             CKobject.getObjectById('ckplayer_a1').videoPause();
                                         }
                                     }
                                 }
                                 catch (e) {
                                     alert(e)
                                 }
                             }
                             if (str == 108) {
                                 CKobject.getObjectById('ckplayer_a1').videoPlay();
                                 CKobject.getObjectById('ckplayer_a2').videoPlay();
                             }
                         }
                        );
                    }
                    else {
                        $("#Ovideo_a1").html(lgdangqiankechengwufajiazai);
                    }

                }
                else if (ID == "Interaction") {
                    ///*********************************************************///
                    ///加载互动窗口、启动计时器，定时获得聊天内容
                    ///*********************************************************///
                    var html = "<div id=\"Interaction\" ><div class=\"interMain\"id=\"interMain\"style=\"overflow-y: scroll;\"></div><div class=\"interFooter\"id=\"interFooter\"><textarea cols=\"25\"rows=\"3\"id=\"interText\" style=\"width:80%\">" + lgzaizhelishuru + "</textarea><input type=\"button\"value=\"" + lgfabu + "\"onclick=\"NewstartLearn.setchart()\"/></div></div>";
                    NewstartWindows.OpenForm(MyWinList[i].ID, MyWinList[i].SysTitle, MyWinList[i].SysWidth, MyWinList[i].SysHeight, MyWinList[i].SZ, MyWinList[i].SX, MyWinList[i].SY, html);
                    //alert($("#D_" + MyWinList[i].ID).css("height"));
                    $("#interMain").css("height", MyWinList[i].SysHeight.replace("px", "") - 90 + "px");
                    $('body').everyTime('1s', 'Interaction', function () {
                        $.getScript("/Training/Learn/Interacts.ashx?Key=" + Key + "&pid=" + playVodieId + "&Time=" + playTime);
                        $("#interMain").scrollTop(100);
                    }, 0, true);
                }
                else if (ID == "Progress") {
                    ///*********************************************************///
                    ///显示培训进度条
                    ///*********************************************************///
                    NewstartLearn.Progress(ID, SysTitle, SysWidth, SysHeight, SZ, SX, SY);
                }
                else if (ID == "About") {
                    ///*********************************************************///
                    ///显示课程介绍等信息
                    ///*********************************************************///
                    NewstartLearn.About(ID, SysTitle, SysWidth, SysHeight, SZ, SX, SY);

                }
                else if (ID == "Annex") {
                    ///*********************************************************///
                    ///显示附件文档。（根据宽度显示内容不同，小面积显示图标，大面积直接显示内容）
                    ///*********************************************************///

                }
                else if (ID == "Exercises") {
                    ///*********************************************************///
                    ///练习题（直接显示题目）
                    ///*********************************************************///

                }
                else if (ID == "Elist") {
                    ///*********************************************************///
                    ///考试、作业题列表
                    ///*********************************************************///

                }
                else {
                    ///*********************************************************///
                    ///未知内容窗体
                    ///*********************************************************///
                    NewstartWindows.OpenForm(MyWinList[i].ID, MyWinList[i].SysTitle, MyWinList[i].SysWidth, MyWinList[i].SysHeight, MyWinList[i].SZ, MyWinList[i].SX, MyWinList[i].SY, "");
                }
            }
            //计时器
            $('body').everyTime('10s', 'Jishi', function () {
                $.get("/Training/Learn/Interacts.ashx?Key=" + Key + "&t=" + Tstate);
            }, 0, true);
        }
        else {
            NewstartWindows.alert(lghenbaoqianyemianqueshaobiyao);
        }
        $("#Loading").hide();

    }
    this.setchart = function () {
        /// <summary>
        /// 留言发言
        /// </summary>
        $.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'>" + lgwoshuo + ":" + $("#interText").val() + "<span>" + playTime + "</span></p>");
                    getchart();
                }
                else if (data == "nouser") {
                    alert(lgjinzhinimingliuyan);
                }
                else {
                    alert(lgfayanshibai);
                }
            });
    }
    this.Progress = function (ID, SysTitle, SysWidth, SysHeight, SZ, SX, SY) {
        /// <summary>
        /// 进度条
        /// </summary>
        $.get("/Training/Learn/Learn_CustomGet.ashx",
                        { Key: Key, Code: "Progress" },
                        function (html) {
                            //alert(html);
                            //var html = "<div class=\"jindu\"><span class=\"jindu_txt\"><span id=\"jindu_num\">9</span>/<span id=\"jindu_count\">10</span></span><span class=\"jindu_tiao\"id=\"jindu_tiao\"></span></div>";
                            NewstartWindows.OpenForm(ID, SysTitle, SysWidth, SysHeight, SZ, SX, SY, html);
                            var c = 0; //计时器
                            var cath = 0; //备份计时
                            $('body').everyTime('1s', 'Prpgress', function () {

                                if (c == 0) {
                                    var numbers = document.getElementById("jindu_num").innerHTML;
                                    c = Number(numbers) * 60;
                                }

                                if (Tstate == 1) {
                                    c = c + 1;
                                    var min = parseInt(c / 60); // 分钟数
                                    var lastsecs = c % 60;
                                    document.getElementById("jindu_num").innerHTML = min + "." + lastsecs;
                                    var count = document.getElementById("jindu_count").innerHTML;
                                    if (min >= count + 3) {
                                        $('body').stopTime('Prpgress');
                                        $('body').stopTime('Jishi');
                                    }
                                    else {
                                        if (parseFloat((c / 60) * 100 / count) <= 100) {
                                            document.getElementById("jindu_tiao").style.width = parseFloat((c / 60) * 100 / count) + "%";
                                        }
                                    }
                                    // alert(min);
                                }
                                else {
                                    try {

                                        c = parseInt(c / 60) * 60;  //一旦暂停则会清除余数

                                        cath = c;
                                    } catch (e) {
                                        c = cath;
                                    }

                                }
                            }, 0, true);
                        });
    }
    this.About = function (ID, SysTitle, SysWidth, SysHeight, SZ, SX, SY) {
        /// <summary>
        /// 关于课程
        /// </summary>
        $.get("/Training/Learn/Learn_CustomGet.ashx",
                        { Key: Key, Code: "About" },
          function (data) {
              NewstartWindows.OpenForm(ID, SysTitle, SysWidth, SysHeight, SZ, SX, SY, data);
          });
    }
    ///*****************************************************************************///
    ///主视频相关操作
    ///*****************************************************************************///
    this.AddMvideo = function (ID, Cantent, Height, Flashvars) {
        /// <summary>
        /// 增加课程主体内容
        ///（主视频，根据主视频格式的不同，自动匹配不同的载体播放)
        /// </summary>
        var houzhui = Flashvars.f.substring(Flashvars.f.lastIndexOf(".") + 1); //获得主视频后缀名
        if (houzhui.indexOf("?") >= 0) {
            houzhui = Flashvars.f.substring(Flashvars.f.lastIndexOf(".") + 1, Flashvars.f.lastIndexOf("?"));
        }
        if (houzhui == "htm" || houzhui == "html") {
            //静态类内容
            NewstartLearn.AddHtml(ID, Cantent, Height, Flashvars);
        }
        else if (houzhui == "flv" || houzhui == "mp4") {
            //网络视频类内容
            NewstartLearn.AddVideo(ID, Cantent, Height, Flashvars);
        }
        else if (houzhui == "swf") {
            //flash动画或播放器格式
            NewstartLearn.ADDflash(ID, Cantent, Height, Flashvars);
        }
        else {
            //其他乱七八糟视频格式
            NewstartLearn.AddSanFang(ID, Cantent, Height, Flashvars);
        }
    }
    this.AddVideo = function (ID, Cantent, Height, Flashvars) {
        /// <summary>
        /// 增加视频组件
        /// </summary>
        var params = { bgcolor: '#000', allowFullScreen: true, allowScriptAccess: 'always', wmode: 'opaque' };
        var video = [Flashvars.f + '->video/mp4'];
        CKobject.embed('/Training/Learn/m/ckplayer/ckplayer.swf', Cantent, ID, '100%', Height, false, Flashvars, video, params);
    }
    this.VideoTo = function (Flashvars, fun) {
        /// <summary>
        /// 切换视频
        /// </summary>
        //alert(Flashvars.f);
        NewstartLearn.AddMvideo("ckplayer_a1", 'Mvideo_a1', mvh, Flashvars);
        playVodieId = fun;
    }
    this.ADDflash = function (ID, Cantent, Height, Flashvars) {
        /// <summary>
        /// 增加flash组件
        /// </summary>
        var params = { bgcolor: '#000', allowFullScreen: true, allowScriptAccess: 'always', wmode: 'opaque' };
        CKobject.embedSWF(Flashvars.f, Cantent, ID, '100%', Height, "", params);
    }
    this.AddHtml = function (ID, Cantent, Height, Flashvars) {
        /// <summary>
        /// 增加SROM或HTML课程组件
        /// </summary>
        $("#" + Cantent).html("");
        $("#" + Cantent).append("<iframe id=\"" + ID + "\" style=\"text-align: left; background-color: #020301; background-image: url('m/learnplay_bg.gif'); background-position: center;background-repeat: no-repeat; border: none; width: 100%;height:" + Height + ";\" src='" + Flashvars.f + "'></iframe>");
    }
    this.AddSanFang = function (ID, Cantent, Height, Flashvars) {
        /// <summary>
        /// 引入第三方播放器(暂用影音先锋)
        /// </summary>
        $("#" + Cantent).html("");
        $("#" + Cantent).append("<OBJECT id=Xfplay name=Xfplay onerror=\"$('#" + Cantent + "').html('<center><br />" + lgninxuyaoanzhuangchajian + "<br /><a href=http://down.xfplay.com/xfplay.exe>" + lgdianjixiazaibofangqi + "</a><br />" + lganzhuangwanchenghoushuaxin + "</center>')\" CLASSID=\"CLSID:E38F2429-07FE-464A-9DF6-C14EF88117DD\" width=\"100%\" height=\"" + Height + "\"><PARAM NAME=\"URL\" VALUE=\"" + Flashvars.f + "\" width=\"100%\" height=\"" + Height + "\"><embed type=\"application/xfplay-plugin\" id=\"Xfplay2\" name=\"Xfplay2\" PARAM_URL=\"" + Flashvars.f + "\"  width=\"100%\" height=\"" + Height + "\"></embed></OBJECT>");
        var XfplayIEFF;
        var isIE = true;
        var Install = false;
        var checkIEorFirefox = {};
        if (window.ActiveXObject || window.ActiveXObject !== undefined) {
            checkIEorFirefox.ie = "yes";
            XfplayIEFF = document.getElementById("Xfplay");
        } else {
            isIE = false;
            checkIEorFirefox.firefox = "yes";
            XfplayIEFF = document.getElementById("Xfplay2");

            var $E = function () { var c = $E.caller; while (c.caller) c = c.caller; return c.arguments[0] };
            __defineGetter__("event", $E);
        }

        if (!isIE) {
            if (navigator.plugins) {
                for (i = 0; i < navigator.plugins.length; i++) {
                    var n = navigator.plugins[i].name;
                    if (navigator.plugins[n][0]['type'] == 'application/xfplay-plugin') {
                        Install = true; break;
                    }
                }
            }
            if (!Install) {
                XfplayIEFF.style.display = 'none';
                Flashvars.f = "/Training/Learn/m/xfplay/error.htm";
                NewstartLearn.AddHtml(ID, Cantent, Height, Flashvars);
            }
        }
        else {
            if (getxfdx('Xfplay2') != null) {
                getxfdx('Xfplay2').style.display = 'none';
            }
            //alert(XfplayIEFF);
            if (XfplayIEFF != null && XfplayIEFF.style.display == 'none') {
                //alert("插件未安装");
            } else {
                Install = true;
            }
        }

    }

}
function ckplayer_status(str) {
    /// <summary>
    /// 自己播放器回调时间
    /// </summary>
    //103暂停，102开始播放，101播放结束，105全屏，108加载结束（准备就绪）
    //$("#interText").val(str);//反馈数据测试
    var nowtime = str.substring(0, 5);
    if (nowtime == "time:") {
        playTime = str.substr(5); //当前播放时间
        Tstate = 1;
    }
    else if (str == 106) {
        //106打开视频错误
        NewstartWindows.alert(lghenbaoqianjiaoxueshipin);
    }
    else if (str == 103) {
        //Tstate = 0;
    } else if (str == 102) {//当正在播放才触发事件
    }
    else if (str.length > 10) {
        //alert(str); 
    }
    Tongbu(str);
}
function Tongbu(str) {
    /// <summary>
    /// 主次视频同步，当存在操作视频时触发
    /// </summary>
}
function getxfdx(objName) {
    /// <summary>
    /// 不同浏览器读取插件对象
    /// </summary>
    try {
        if (document.getElementById) {
            return eval('document.getElementById("' + objName + '")');
        }
        else {
            return eval('document.all.' + objName);
        }
    }
    catch (e) {
        NewstartTimer.s
    }
}
var NewstartWindows = new function () {
    var Zindex = 2;
    var pianyi = 0; //新建窗口偏移10像素
    var Aindex = 0;
    ///********************************************************************///
    ///窗口操作
    ///********************************************************************///
    var Chapterhtml = "<ul class=\"zhangjie\"><li>第一章<ul><li><a href=\"#\"style=\" background:#999; color:White;\">第一节 车辆结构常识</a></li><li><a href=\"#\">第二节 车辆主要安全装置</a></li><li><a href=\"#\">第三节 驾驶操纵机构</a></li><li><a href=\"#\">第四节 车辆性能</a></li><li><a href=\"#\">第五节 车辆检查和维护</a></li></ul></li><li>第二章<ul><li><a href=\"#\">第一节 机动车驾驶证申领与使用</a></li><li><a href=\"#\">第二节 道路通行规则</a></li><li><a href=\"#\">第三节 驾驶行为</a></li><li><a href=\"#\">第四节 违法行为处罚</a></li><li><a href=\"#\">第五节 机动车登记</a></li><li><a href=\"#\">第六节 交通事故处理</a></li></ul></li><li>第三章<ul><li><a href=\"#\">知识总结</a></li></ul></li></ul>";
    var MvideoHtml = "<div>" + lgzhushipin + "</div>";
    this.LoadWindow = function (MyJson) {
        /// <summary>
        /// 窗口编辑时，将原有界面样式还原
        /// </summary>
        Key = QueryString("key");
        $("#cb_Chapter").click(function () { NewstartWindows.AddWindows("Chapter", lgzhangjie, "250px", "400px", Chapterhtml); });
        $("#cb_Mvideo").click(function () { NewstartWindows.AddWindows("Mvideo", lgzhushipin, "400px", "300px", MvideoHtml); });
        $("#cb_Ovideo").click(function () { NewstartWindows.AddWindows("Ovideo", lgcaozuoshipin, "400px", "300px", lgcaozuoshipin); });
        $("#cb_Interaction").click(function () { NewstartWindows.AddWindows("Interaction", lghudong, "400px", "300px", lghudong); });
        $("#cb_Progress").click(function () { NewstartWindows.AddWindows("Progress", lgxuexijindu, "400px", "300px", lgxuexijindu); });
        $("#cb_About").click(function () { NewstartWindows.AddWindows("About", lgkechengjieshao, "400px", "300px", lgkechengjieshao); });
        if (Key != "" && MyJson != "") {
            //编辑
            var MyWinList = eval(MyJson);
            for (var i = 0; i < MyWinList.length; i++) {
                var name = MyWinList[i].ID;
                var SysTitle = MyWinList[i].SysTitle;
                var SysWidth = MyWinList[i].SysWidth;
                var SysHeight = MyWinList[i].SysHeight;
                var x = MyWinList[i].SX;
                var y = MyWinList[i].SY;
                NewstartWindows.ChongbangClick(name, MyWinList[i]);
                //alert(SysTitle);
            }
        }
    }
    this.ChongbangClick = function fuzhi(name, Obj) {
        /// <summary>
        ///重新绑定方法
        /// </summary>
        $("#cb_" + name).unbind('click');
        $("#cb_" + name).attr("checked", true);
        $("#cb_" + name).bind('click', function () {
            NewstartWindows.AddWindows(Obj.ID, Obj.SysTitle, Obj.SysWidth, Obj.SysHeight, lgyanshikechengshi, Obj.SX, Obj.SY);
        });
        NewstartWindows.AddWindows(Obj.ID, Obj.SysTitle, Obj.SysWidth, Obj.SysHeight, lgyanshikechengshi, Obj.SX, Obj.SY);
    }
    this.AddWindows = function (Nname, Ntitle, Nwidth, Nheight, Ncontent, X, Y) {
        /// <summary>
        /// 增加/删除窗口
        /// </summary>
        /// <param name="Nname" type="String">
        /// CODE窗口名字,ID
        /// </param>
        /// <param name="Ntitle" type="String">
        /// 标题
        /// </param>
        /// <param name="Nwidth" type="String">
        /// 宽度
        /// </param>
        /// <param name="Nheight" type="String">
        /// 高度
        /// </param>
        /// <returns type="void" />
        X = (X == undefined) ? ((document.documentElement.clientWidth - 700) / 2 + pianyi) : X;
        Y = (Y == undefined) ? (50 + pianyi) : Y;
        if ($("#D_" + Nname).length > 0) {
            //当窗体已经存在了，就删除掉
            $("#D_" + Nname).remove();
        }
        else {
            $("#Desktop").append("<div id=\"D_" + Nname + "\" class=\"NewForm\" style=\"display:none;width:" + Nwidth + ";height:" + Nheight + ";\"><div id=\"NewForm_title_" + Nname + "\"  class=\"NewForm_title\"><span id='title_" + Nname + "'>" + Ntitle + "</span> <a href=\"javascript:void(0)\"  class='NewForm_Close' title='关闭'> <\/a>  <a href=\"javascript:void(0)\"  class='NewForm_Max' title='设置'> <\/a>  <\/div> <div class='NewForm_Ncontent'>" + Ncontent + "</div></div>");
            $("#D_" + Nname).css("left", X);
            $("#D_" + Nname).css("top", Y);
            $("#D_" + Nname).css("z-index", Zindex);
            Zindex++;
            $("#D_" + Nname).show(250);
            pianyi = pianyi + 10;
            $("#D_" + Nname).mousedown(function () { $(this).css("z-index", Zindex); Zindex++; });
            $("#D_" + Nname).find(".NewForm_Max").click(function () { NewstartWindows.FormSys(Nname); }); //关闭
            $("#D_" + Nname).find(".NewForm_Close").click(function () { NewstartWindows.CloseForm(Nname); }); //关闭
            $("#D_" + Nname).draggable({
                containment: 'parent',
                handle: '.NewForm_title',
                start: function () {
                    NewstartWindows.SysForm.CloseSysFrom();
                }
            }); //可拖动
            $("#D_" + Nname).resizable(); //可改变窗体大小
        }
    }
    this.OpenForm = function (Nname, Ntitle, Nwidth, Nheight, Zindex, SX, SY, Ncontent) {
        /// <summary>
        /// 前台打开窗口
        /// </summary>
        $("#Desktop").append("<div id=\"D_" + Nname + "\" class=\"NewForm\" style=\"display:none;width:" + Nwidth + ";height:" + Nheight + ";\"><div id=\"NewForm_title_" + Nname + "\"  class=\"NewForm_title\"><span id='title_" + Nname + "'>" + Ntitle + "</span>  <\/div> <div class='NewForm_Ncontent'>" + Ncontent + "</div></div>");
        $("#D_" + Nname).css("left", SX);
        $("#D_" + Nname).css("top", SY);
        $("#D_" + Nname).css("z-index", Zindex);
        $("#D_" + Nname).show(250);
    }
    this.CloseForm = function (Nname) {
        /// <summary>
        /// 增加/删除窗口
        /// </summary>
        $("#D_" + Nname).remove();
        $("#cb_" + Nname).attr("checked", false);
    }
    this.FormSys = function (Nname) {
        /// <summary>
        /// 设置/查看基本属性
        /// </summary>
        NewstartWindows.SysForm.OpenSysFrom(Nname);
    }
    this.GetForms = function () {
        /// <summary>
        /// 获得全部自定义窗口数据，返回序列化数据
        /// </summary>
        var all = []; //存储容器
        $(".NewForm").each(function () {
            var ID = $(this).attr("id"); //得到窗体ID
            var Name = ID.substr(2, ID.length - 2);
            //alert(Name);
            var obj = $("#" + ID);
            all.push({
                ID: Name,
                SysTitle: $("#title_" + Name).html(),
                SysWidth: obj.css("width"),
                SysHeight: obj.css("height"),
                SX: obj.css("left"),
                SY: obj.css("top"),
                SZ: obj.css("z-index")
            });
        });
        return JSON.stringify(all);
        //alert();
    }

    ///********************************************************************///
    ///窗口设置
    ///********************************************************************///
    this.SysForm = new function () {
        /// <summary>
        /// 设置属性框操作
        /// </summary>

        this.OpenSysFrom = function (ID) {
            /// <summary>
            /// 打开并初始化窗体属性
            /// </summary>
            if ($("#SysFrom").length == 0) {
                $("#Desktop").append("<div id=\"SysFrom\"><div class=\"NewForm_title\">" + lgjianmianshezhi + "</div><input type=\"hidden\"value=\"\"id=\"SysID\"/><table width=\"100%\"><tr><td>" + lgbiaoti + ":</td><td><input type=\"text\"id=\"SysTitle\"value=\"\"class=\"tinput\"/></td></tr><tr><td>" + lgkuandu + ":</td><td><input type=\"text\"id=\"SysWidth\"value=\"\"class=\"tinput\"/></td></tr><tr><td>" + lggaodu + ":</td><td><input type=\"text\"id=\"SysHeight\"value=\"\"class=\"tinput\"/></td></tr><tr><td>X" + lgzuobiao + ":</td><td><input type=\"text\"id=\"SX\"value=\"\"class=\"tinput\"/></td></tr><tr><td>Y" + lgzuobiao + ":</td><td><input type=\"text\"id=\"SY\"value=\"\"class=\"tinput\"/></td></tr><tr><td colspan=\"2\"style=\"text-align: center;\"><input type=\"button\"value=\"" + lgqd + "\"onclick=\"NewstartWindows.SysForm.SaveSysFrom()\"/> <input type=\"button\"value=\"" + lgclose + "\"onclick=\"NewstartWindows.SysForm.CloseSysFrom()\"/></td></tr></table></div>");
            }
            var obj = $("#D_" + ID); //得到这个对象
            $("#SysID").val(ID); //设置ID
            $("#SysTitle").val($("#title_" + ID).html());
            $("#SysWidth").val(obj.css("width"));
            $("#SysHeight").val(obj.css("height"));
            $("#SX").val(obj.css("left"));
            $("#SY").val(obj.css("top"));
            $("#SysFrom").show();
        }
        this.SaveSysFrom = function () {
            /// <summary>
            /// 保存窗体属性
            /// </summary>
            var obj = $("#D_" + $("#SysID").val()); //得到要处理的对象
            $("#title_" + $("#SysID").val()).html($("#SysTitle").val());
            obj.css("width", $("#SysWidth").val());
            obj.css("height", $("#SysHeight").val());
            obj.css("top", $("#SY").val());
            obj.css("left", $("#SX").val());
            NewstartWindows.SysForm.CloseSysFrom();
        }
        this.CloseSysFrom = function () {
            /// <summary>
            /// 关闭窗体属性
            /// </summary>
            $("#SysFrom").hide();
        }
    }
    ///********************************************************************///
    ///小窗口工具（alert,confirm）
    ///********************************************************************///
    //提示对话框
    this.alert = function (content) {
        /// <summary>
        /// 自写ALert窗口！！
        /// </summary>
        Zindex++;
        $("#Desktop").append("<div id=\"alert" + Aindex + "\"  class=\"NewInfor\" style=\"display:none;\"><div class=\"NewInfor_title\"><span>" + lgxitongtishi + "</span><a href=\"javascript:void(0)\"  class='NewInfor_Close' title='" + lgclose + "'> <\/a> <\/div><p>" + content + " <br /><input type=\"button\"  id=\"queding\"  class=\"queding\" /></p></div>");
        $("#alert" + Aindex).css("width", "490px");
        $("#alert" + Aindex).css("height", "160px");
        $("#alert" + Aindex).css("left", (document.documentElement.clientWidth - 490) / 2);
        $("#alert" + Aindex).css("top", 100);
        $("#alert" + Aindex).css("z-index", "9999");
        $("#alert" + Aindex).show(100);
        //$("#alert" + Aindex).draggable(); //可拖动
        $("#alert" + Aindex).find(".NewInfor_Close").click(function () { $("#alert" + Aindex).remove(); }); //关闭
        $("#alert" + Aindex).find(".queding").click(function () { $("#alert" + Aindex).remove(); return true; }); //确认
    }
    //确认对话框
    this.confirm = function (content, fun) {
        /// <summary>
        /// 自写确认窗口！！
        /// </summary>
        Zindex++;
        $("#Desktop").append("<div id=\"confirm" + Aindex + "\"  class=\"NewInfor\" style=\"display:none;\"><div class=\"NewInfor_title\">" + lgquerenduihuakuang + "<a href=\"javascript:void(0)\"  class='NewInfor_Close' title='" + lgclose + "'> <\/a> <\/div><p class=\"p2\">" + content + " <br /><input type=\"button\"  id=\"queding\"  class=\"queding\" /> <input type=\"button\"  id=\"quxiao\"  class=\"quxiao\" /></p></div>");
        $("#confirm" + Aindex).css("width", "490px");
        $("#confirm" + Aindex).css("height", "160px");
        $("#confirm" + Aindex).css("right", 0);
        $("#confirm" + Aindex).css("top", 100);
        $("#confirm" + Aindex).css("z-index", "9999");
        $("#confirm" + Aindex).show(100);
        //$("#confirm" + Aindex).draggable(); //可拖动
        $("#confirm" + Aindex).find(".NewInfor_Close").click(function () { $("#confirm" + Aindex).remove(); }); //关闭
        $("#confirm" + Aindex).find(".queding").click(function () { $("#confirm" + Aindex).remove(); }); //确定
        $("#confirm" + Aindex).find(".queding").click(fun);
        $("#confirm" + Aindex).find(".quxiao").click(function () { $("#confirm" + Aindex).remove(); }); //取消

    }
}
//得到QueryString
function QueryString(fieldName) {
    /// <summary>
    /// 获得URL参数！！
    /// </summary>
    fieldName = fieldName.toLowerCase();
    var urlString = document.location.search.toLowerCase();
    if (urlString != null) {
        var typeQu = fieldName + "=";
        var urlEnd = urlString.indexOf(typeQu);
        if (urlEnd != -1) {
            var paramsUrl = urlString.substring(urlEnd + typeQu.length);
            var isEnd = paramsUrl.indexOf('&');
            if (isEnd != -1) {
                return paramsUrl.substring(0, isEnd);
            }
            else {
                return paramsUrl;
            }
        }
        else {
            return "";
        }
    }
    else {
        return "";
    }
}
Function.prototype.hookend = function (hook) {
    /// <summary>
    /// 函数方法重写！！
    /// </summary>
    var fn = this;
    return function () {
        ret = fn.apply(this, arguments);
        hook.apply(this, arguments);
        return;
    }
}
var i = 0;
function jishiqi() {
    Tstate = 1;
    $(".jindu").css("color", "#000");
    if (CKobject.getObjectById('ckplayer_a1') != null) {
        CKobject.getObjectById('ckplayer_a1').videoPlay();
    }
    else {
        setTimeout(function () {
            $(".jihuo_btn").remove()
        }, 500);
    }
}
function weijishi() {
    Tstate = 0; $(".jindu").css("color", "red");
    if (i == 0) {
        setTimeout(function () {
            $(".jindu").append("<input value='" + lqkongbaichujishi + "' type='button' id='jihuo_btn' class='jihuo_btn' onclick='jishiqi()' />");

        }, 1000);
        i = 1;
    }

    if (CKobject.getObjectById('ckplayer_a1') != null) {
        CKobject.getObjectById('ckplayer_a1').videoPause();
    }
}
//放挂机
$(function () {
    if (navigator.userAgent.indexOf("Firefox") > 0 || navigator.userAgent.indexOf("Safari") > 0 || navigator.userAgent.indexOf("Chorme") > 0) {
        $(window).blur(function () { weijishi(); });
        $(window).focus(function () { jishiqi(); });
    }
    else {
        document.onfocusout = function () {
            weijishi();
        };
        document.onfocusin = function () {
            jishiqi();
        };
    }
});
//计时器
jQuery.fn.extend({ everyTime: function (interval, label, fn, times, belay) { return this.each(function () { jQuery.timer.add(this, interval, label, fn, times, belay); }); }, oneTime: function (interval, label, fn) { return this.each(function () { jQuery.timer.add(this, interval, label, fn, 1); }); }, stopTime: function (label, fn) { return this.each(function () { jQuery.timer.remove(this, label, fn); }); } }); jQuery.extend({ timer: { guid: 1, global: {}, regex: /^([0-9]+)\s*(.*s)?$/, powers: { 'ms': 1, 'cs': 10, 'ds': 100, 's': 1000, 'das': 10000, 'hs': 100000, 'ks': 1000000 }, timeParse: function (value) { if (value == undefined || value == null) return null; var result = this.regex.exec(jQuery.trim(value.toString())); if (result[2]) { var num = parseInt(result[1], 10); var mult = this.powers[result[2]] || 1; return num * mult; } else { return value; } }, add: function (element, interval, label, fn, times, belay) { var counter = 0; if (jQuery.isFunction(label)) { if (!times) times = fn; fn = label; label = interval; } interval = jQuery.timer.timeParse(interval); if (typeof interval != 'number' || isNaN(interval) || interval <= 0) return; if (times && times.constructor != Number) { belay = !!times; times = 0; } times = times || 0; belay = belay || false; if (!element.$timers) element.$timers = {}; if (!element.$timers[label]) element.$timers[label] = {}; fn.$timerID = fn.$timerID || this.guid++; var handler = function () { if (belay && this.inProgress) return; this.inProgress = true; if ((++counter > times && times !== 0) || fn.call(element, counter) === false) jQuery.timer.remove(element, label, fn); this.inProgress = false; }; handler.$timerID = fn.$timerID; if (!element.$timers[label][fn.$timerID]) element.$timers[label][fn.$timerID] = window.setInterval(handler, interval); if (!this.global[label]) this.global[label] = []; this.global[label].push(element); }, remove: function (element, label, fn) { var timers = element.$timers, ret; if (timers) { if (!label) { for (label in timers) this.remove(element, label, fn); } else if (timers[label]) { if (fn) { if (fn.$timerID) { window.clearInterval(timers[label][fn.$timerID]); delete timers[label][fn.$timerID]; } } else { for (var fn in timers[label]) { window.clearInterval(timers[label][fn]); delete timers[label][fn]; } } for (ret in timers[label]) break; if (!ret) { ret = null; delete timers[label]; } } for (ret in timers) break; if (!ret) element.$timers = null; } } } }); if (jQuery.browser.msie) jQuery(window).one("unload", function () { var global = jQuery.timer.global; for (var label in global) { var els = global[label], i = els.length; while (--i) jQuery.timer.remove(els[i], label); } });
