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

<!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("Courseware_Form_kjxzbj")%></title>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache,must-revalidate" />
    <meta http-equiv="expires" content="Wed,26 Feb 1997 08:21:57 GMT" />
    <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>
    <script src="/Themes/Scripts/DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/jquery.form.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/Validator/JValidator.js" type="text/javascript"></script>
    <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>
    <link href="/Themes/Scripts/TreeView/treeview.css" rel="stylesheet" type="text/css" />
    <script src="/Themes/Scripts/TreeView/treeview.pack.js" type="text/javascript"></script>
    <script type="text/javascript" src="/Live/swfobject.js"></script>
    <script type="text/javascript">
    $(function () {
            $('#table2').hide();
            $('#table3').hide();
            $('#table4').hide();
            $('#table5').hide();
            $('#table6').hide();
            $('#moviebutton').hide();
            $('#fujianbutton').hide();
        })
        //点击切换面板
        var IsFixedTableLoad = 1;
        function panel(obj) {
            if (obj == 1) {
                $('#table1').show();
                $('#table2').hide();
                $('#table3').hide();
                $('#table4').hide();
                $('#table5').hide();
            } else if (obj == 2) {
                $('#table1').hide();
                $("#table2").show();
                $('#table3').hide();
                $('#table4').hide();
                $('#table5').hide();
            } else if (obj == 3) {
                $('#table1').hide();
                $("#table2").hide();
                $('#table3').show();
                $('#table4').hide();
                $('#table5').hide();
            } else if (obj == 4) {
                $('#table1').hide();
                $("#table2").hide();
                $('#table3').hide();
                $('#table4').show();
                $('#table5').hide();
            } else if (obj == 5) {
                $('#table1').hide();
                $("#table2").hide();
                $('#table3').hide();
                $('#table4').hide();
                $('#table5').show();
            }
            if (IsFixedTableLoad == 1) {
                FixedTableHeader("#dnd-example", $(window).height() - 105);
                IsFixedTableLoad = 0;
            }
        }
        var $promptBg = $("#promptBg"); //正在加载模板
        var isLoad = false; //是否正在异步加载

        //设置文本框键盘按键事件（按键事件不对数据处理，因为keyDown获取的值永远是上一次keyUp的数据，这里在keyDown里面处理特殊操作）
        $("#Courseware_CsTeacher").keydown(function (e) {
            var event = e || event; //兼容性处理
            if (event.keyCode == 27) {
                $promptBg.stop().hide(0, function () {
                    $promptBg.html("");
                });
                return;
            } else if (event.keyCode == 37 || event.keyCode == 39) return; //左右键
            else if (event.keyCode == 13) {//回车键
                var $obj = $(".activePrompt");
                if ($obj.length < 1) return false;
                $("#Courseware_CsTeacherId").val($obj.attr("data"));
                $("#Courseware_CsTeacher").val($obj.text());
                $promptBg.stop().hide(0, function () {
                    $promptBg.html("");
                });
                return false;
            }
            if ($("#loadIcon").length < 1) {
                if (event.keyCode == 38) { //向上
                    if ($(".activePrompt").length < 1) {//最后一个
                        $(".promptLink").last().addClass("activePrompt");
                        return false;
                    }
                    $currObj = $(".activePrompt").parent();
                    if ($currObj.prev().length < 1) return false; //第一个
                    var $nextObj = $currObj.prev().children("a");
                    $(".activePrompt").removeClass("activePrompt");
                    $nextObj.addClass("activePrompt");
                    return false;
                }
                if (event.keyCode == 40) { //向下
                    if ($(".activePrompt").length < 1) {//第一个
                        $(".promptLink").eq(0).addClass("activePrompt");
                        return false;
                    }
                    $currObj = $(".activePrompt").parent();
                    if ($currObj.next().length < 1) return false; //最后一个
                    var $nextObj = $currObj.next().children("a");
                    $(".activePrompt").removeClass("activePrompt");
                    $nextObj.addClass("activePrompt");
                    return false;
                }
            }
        });
        function textChange() {
            if (isLoad) return;
            $("#promptBg").show(0);
            var inputvalue = $("#Courseware_CsTeacher").val();
            isLoad = true;
            $.get("SearchUserInfoTeacher.ashx", { key: inputvalue }, function (data) {
                isLoad = false;
                if (!data || parseInt(data) == -1) {
                    $promptBg.stop().hide(0);
                    return; //没有查询到数据或者异常
                }
                $("#promptBg").html(data);
                $(".promptLink").hover(function () {//绑定事件
                    $(this).addClass("activeLink");
                }, function () {
                    $(this).removeClass("activeLink");
                });
            });
        }
        function choiseExam(obj) {
            $("#Courseware_CsTeacherId").val($(obj).attr("data"));
            $("#Courseware_CsTeacher").val($(obj).text());
            $("#promptBg").hide(0);
            $("#promptBg").html("");
        }

        //预览
        function browse() {
            var url = "/Training/Learn/LearnPC.aspx?Key=" + QueryString("CoursewareKey");
            top.openDialog(url, 'LearnPC', '<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_kjlbkjyl")%>', '100%', '100%', 0, 0);
        }

    //删除视频
    function moviedelete(obj)
    {
        $(obj).parent("li").remove();
    }
    </script>
    <style type="text/css">
        li { list-style: none; }
        .file-box { position: relative; width: 400px; margin-top: 0px; }
        .txt { border: 1px solid #cdcdcd; width: 100px; }
        .btn { background-color: #ccc; border: 1px solid #CDCDCD; height: 24px; width: 100px; }
        .file { position: absolute; top: 0; left: 0; height: 24px; filter: alpha(opacity:0); opacity: 0; width: 210px; }
        #promptBg ul, #promptBg li { padding: 0; margin: 0; list-style: none; }
        .log { position: absolute; top: 50%; left: 50%; margin: -100px 0 0 -150px; width: 300px; height: 200px; z-index: 99; display: none; }
        .ResourceTable { display: none; position: absolute; background-color: White; height: 355px; }
        .olhead { width: 320px; }
        .olhead li span { padding: 2px; border: 1px solid #ccc; }
        .olcenter li span { padding: 2px; border: 1px solid #ccc; }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div class="frmtop">
        <table style="padding: 0px; margin: 0px;" cellpadding="0" cellspacing="0">
            <tr>
                <td id="menutab" style="vertical-align: bottom;">
                    <div id="tab0" class="Tabsel" onclick="GetTabClick(this);panel(1)">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Jbxx")%>
                    </div>
                    <div id="tab1" class="Tabremovesel" onclick="GetTabClick(this);panel(2);">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_Form_sp")%>
                    </div>
                    <div id="tab2" class="Tabremovesel" onclick="GetTabClick(this);panel(3);">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_Form_fj")%>
                    </div>
                    <div id="tab3" class="Tabremovesel" onclick="GetTabClick(this);panel(4);">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_Form_jj")%>
                    </div>
                    <div id="tab4" class="Tabremovesel" onclick="GetTabClick(this);panel(5);">
                        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_Form_xjqx")%>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <div id="ResourceTable" class="ResourceTable">
        <div style="width: 200px; height: 355px; float: left; overflow: auto;">
            <ul class="strTree" style="height: 320px;">
                <%=strHtml.ToString()%>
            </ul>
        </div>
        <div style="float: left; width: 320px; height: 355px; overflow: auto;" class="div-body">
            <table class="grid">
                <thead>
                    <tr>
                        <th>
                            <label title="全选" onclick="CheckAllLine()" id="checkAllOff">
                                &nbsp;</label>
                        </th>
                        <th>
                            资源名
                        </th>
                        <th>
                            资源分类
                        </th>
                    </tr>
                </thead>
                <tbody id="ResourceList">
                </tbody>
            </table>
        </div>
        <div style="float: none;">
        </div>
        <div style="text-align: center;">
            <input type="button" onclick="addav();" value="确定" />
            <input type="button" onclick="ResourceClose();" value="关闭" />
        </div>
    </div>
    <div class="div-frm" style="height: 275px;">
        <table id="table1" border="0" cellpadding="0" cellspacing="0" class="frm">
            <tr>
                <td rowspan="6" style="border: 1px #ccc solid;">
                    <img src="Courseware_Image.ashx?id=<%=CoursewareKey %>" width="200" height="150"
                        alt="封面" /><br />
                    <asp:FileUpload ID="FileUpload1" runat="server" Style="width: 200px;" />
                </td>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_Name")%>:
                </th>
                <td>
                    <input id="Courseware_CsName" maxlength="35" runat="server" type="text" class="txt"
                        datacol="yes" err="课件名" checkexpession="NotNull" style="width: 200px" />
                </td>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_Model")%>:
                </th>
                <td>
                    <select id="Courseware_Pattern" runat="server" class="select" style="width: 200px;">
                    </select>
                </td>
            </tr>
            <tr>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_Type")%>:
                </th>
                <td>
                    <select id="Courseware_CtId" class="select" runat="server" style="width: 200px">
                    </select>
                </td>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_SumDate")%>:
                </th>
                <td>
                    <input id="Courseware_SumDate" maxlength="4" runat="server" type="text" class="txt"
                        datacol="yes" err="要求学习" checkexpession="Num" style="width: 200px" /><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_Minute")%>
                </td>                
            </tr>            
            <tr>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_Xuefen")%>:
                </th>
                <td>
                    <input id="Courseware_Xuefen" maxlength="4" runat="server" type="text" class="txt"
                        datacol="yes" err="学分" checkexpession="NotNull" style="width: 50px" /><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_Fraction")%>
                </td>
                 <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_State")%>:
                    
                </th>
                <td >
                    <select id="Courseware_State" runat="server" class="select" style="width: 80px;">
                    </select>
                </td>    
            </tr>
            <tr>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("SortIndex")%>:                    
                </th>
                <td colspan="3" >  
                    <input  stype="text" class="txt" runat="server" id="Courseware_SortNo"/>
                </td>                   
            </tr>
            <tr>
            <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_CsTeacher")%>
                    :
               </th>                     
               <td colspan="3">                    
                    <span style="position: relative;">
                        <input id="Courseware_CsTeacher" runat="server" type="text" class="txt" style="width: 150px;
                            z-index: 0;" autocomplete="off" onkeyup="textChange()" />                        
                        <input type="hidden" value="" runat="server" id="Courseware_CsTeacherId" />
                         <span
                            style="color: Red; padding-left: 5px;">
                            <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_qclbzxzjs")%>
                        </span>
                        <div id="promptBg" style="display: none; cursor: pointer; position: absolute; width: 228px;
                            background-color: White;">
                            <div id="loadIcon" style="text-align: center; line-height: 18px;">
                                <img src="../../Themes/Images/loading1.gif" alt="" />
                                <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("zzcx")%>...
                            </div>
                        </div>
                    </span>
                </td>
            </tr>
        </table>
        <table id="table2" border="0" cellpadding="0" cellspacing="0" class="frm" >
            <tr>
                <td colspan="4">
                    <ol style="margin: 0 auto;; height: 250px; overflow-y: scroll;" id="fileinfo">
                      <input type="button" value=" <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_zjsp")%>"
                        onclick="ResourceShow(1);" />
                        <li style="border-bottom: 1px solid #ccc;">
                            <input type="text" readonly="readonly" value="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterPlan_Form_zjm")%> " /><input
                                type="text" readonly="readonly" value="课程名" /><input type="text" readonly="readonly"
                                    value="显示顺序" /><input type="text" readonly="readonly" value="路径" style="width: 300px" />
                          <input type="text" style="width:50px" value="是否试看"/><input type='button' readonly="readonly" value='删除' /></li>
                        <%=ziyuan %>
                    </ol>
                </td>
            </tr>
        </table>
        <table id="table3" border="0" cellpadding="0" cellspacing="0" class="frm" >
            <tr>
                <td colspan="4">
                    <ol style="margin: 0 auto;; height: 250px; overflow-y: scroll;"  id="SharesInfo">
                      <input type="button" value=" <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("AnnexUpload")%>"
                        onclick="ResourceShow(2);" />
                         <li style="border-bottom: 1px solid #ccc;">
                            <input  type="text" readonly="readonly" value="附件名" style="width:300px;" /><input type="text" readonly="readonly"
                                    value="显示顺序" style="width:80px;"/><input type="text" readonly="readonly" value="路径" style="width: 300px" />
                         <input type='button' readonly="readonly" value='删除' /></li>
                        <%=fujian%>
                    </ol>
                    
                </td>
            </tr>
        </table>
        <table id="table4" border="0" cellpadding="0" cellspacing="0" class="frm">
            <tr>
                <td colspan="5">
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_kjms")%>：<br />
                    <script src="/Themes/Scripts/kindeditor/kindeditor-min.js" type="text/javascript"></script>
                    <script type="text/javascript">
                        var editor;
                        KindEditor.ready(function (K) {
                            editor = K.create('#Courseware_CsDiscription', {
                                allowFileManager: true,
                                allowUpload: true,
                                uploadJson: '/WeiXin/UploadImage.ashx',
                                minHeight: 360
                            });
                        });
                    </script>
                    <textarea id="Courseware_CsDiscription" class="txtRemark" runat="server" style="width: 98%;
                        height: 50px;"></textarea>
                </td>
            </tr>
        </table>
                <table id="table5" border="0" cellpadding="0" cellspacing="0" class="frm">
            <tr>
                <th>
                    <font color="red">*</font><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("user_group")%>:
                </th>
                <td>
                    <script src="/Themes/Scripts/GetuserControl.js" type="text/javascript"></script>
                </td>
            </tr>
            <tr style="display:none;">
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_qxlx")%>:
                </th>
                <td>
                    <select id="dd_type" runat="server">
                    </select>
                </td>
            </tr>
        </table>
    </div>
    <div class="frmbottom">
        <asp:LinkButton ID="Save" runat="server" class="l-btn" OnClientClick="editor.sync(); return CheckDataValid('#form1');"
            OnClick="Save_Click"><span class="l-btn-left">
            <img src="/Themes/Images/disk.png" alt="" /><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Save")%></span></asp:LinkButton>
        <%=anniu %>
        <a class="l-btn" href="javascript:void(0)" onclick="OpenClose();"><span class="l-btn-left">
            <img src="/Themes/Images/cancel.png" alt="" /><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Close")%></span></a>
    </div>
    </form>
</body>
<script type="text/javascript">
    <%=getuserlist %>

    var addtype="1";//默认加载视频
         //显示
         function ResourceShow(obj){
         $("#ResourceTable").show();
         addtype=obj;
         GetResourceLib("");
         }
         function ResourceClose()
         {
          $("#ResourceTable").hide();
         }
         $(function(){
      treeAttrCss();
      GetClickValue();
    });
    //查询数据
    function GetResourceLib(TypeKey)
    {
           Loading(true);
         var strHtml="";
     getAjax("/Training/ResourceLibrary/ResourceLibrary_Get.ashx","action=GetAllByResource_TypeID&TypeKey="+TypeKey+"&CodeType="+addtype,function(rs){
             if (rs!=null) {
            rs= eval('('+rs+')');
            $.each(rs,function(i,obj){
            if (obj.Resource_TypeName=="") {
    obj.Resource_TypeName="无";
                }
            strHtml+="<tr><td> <input type=\"checkbox\" data=\""+obj.Resource_Url+"\" value=\""+obj.Resource_ID+"\"  /></td><td>"+obj.Resource_Name+"</td><td>"+obj.Resource_TypeName+"</td></tr>";
            });
            Loading(false);
              $("#ResourceList").html(strHtml);
        }
     });
    }
    function GetClickValue() {
         $(".strTree li div").click(function () {
             id = $(this).parent().find("span").html();
             if (id == "") {
                 id = id = $(this).find("span").html();
             }
             GetResourceLib(id);
            });
        }
   function addav() {
var path="";
var rid="";
var rname="";
   $("#ResourceList").find("input[type=checkbox]").each(function(i){
         if ($(this).is(':checked')) {
        path=$(this).attr("data");
        rid=$(this).val();
        rname=$(this).parent().parent().find("td").eq(1).html();
        if(addtype==2)
        {
        $("#SharesInfo").append("<li ><input type=\"text\" name=\"Sharename\" value=\"" + rname + "\"  style=\"width:300px;\" /><input type=\"hidden\" name=\"Sharerid\" value=\"" + rid + "\"  style=\"width: 300px\" /><input type=\"text\" name=\"ShareSort\" value=\"" +i + "\"  style=\"width: 80px\" /><input type=\"text\" name=\"Sharepath\" value=\"" + path + "\"  style=\"width: 300px\" /><input type='button' value='×' onclick='moviedelete(this)'  /></li>");
        }
        else{        
            $("#fileinfo").append("<li><input type=\"text\" name=\"fileChapters\" value=\"<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterPlan_Form_zjm")%> \" /><input type=\"text\" name=\"filename\" value=\"" + decodeURI(rname) + "\" /><input type=\"text\" name=\"fileSort\" value=\""+i+"\" /><input type=\"hidden\" name=\"filenid\" value=\"" +rid+ "\" /><input type=\"text\" name=\"filepath\" value=\"" + path + "\"  style=\"width: 300px\" /> <select name=\"fileTrySess\"><option value=\"允许\"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_shikan")%></option><option value=\"保密\"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Courseware_baom")%></option></select><input type='button' value='×' onclick='moviedelete(this)'/></li>");
        }
        }
   });
            ResourceClose();
    }
</script>
</html>
