//提交表单
$("#finished_button").on("click", function(){
    var courseid = $("#detail_form").find("input[name='courseid']").val();
    var title = $("#detail_form").find("input[name='title']").val();
    var specialid = $("#detail_form").find("select[name='specialid']").val();
    if(title==""){
      $.toast('请填写名称');
      return false;
    }
    if(specialid==""){
      $.toast("请选择专业");
      return false;
    }
    $.ajax({
        url: '/glcourse/course/basicok', 
        type: 'POST',
        dataType: "json", 
        data: $("#detail_form").serialize(),
        beforeSend: function(){
          $.showIndicator();
        },
        success: function(data){
          if(data.code=="success"){
            $.toast('保存成功');
            if(courseid=="0" || courseid=="" || isNaN(courseid)){
              setTimeout(function(){window.location.href = "/yidong/myqcourse/index";}, 2000);
            }else{
              setTimeout(function(){window.location.reload();}, 2000);
            }
          }else{
            $.toast(data.msg);
          }
        },
        error: function(){
          $.toast("系统错误，请联系管理员");
        },
        complete: function(){
          $.hideIndicator();
        }
    });
    return false;
});

//取消按钮
$("#canceled_button").on("click", function(){
  window.location.href = "/yidong/myqcourse/index";
});

var window_width = $(window).width();
var window_height = $(window).height();

//章节目录
function editTreeDetail(id){
  $.popup(".popup-editor");
  $("#editordetail").empty();
  $("#editordetail").html('<iframe src="/yidong/myqtree/index?id='+ id +'&rnum='+ Math.random() +'" width="'+ window_width +'" height="'+ (window_height-47) +'" style="border:none;"></iframe>');
}