
var config = getConfig();
var id= config.id;

$(document).ready(function () {
    getuserask(id);
    getPJ(id,0);
});





function submitask(j, i) {
    var askcontent = $("#liuyan #askmore" + i).val();
    alert(askcontent);
    if (askcontent != "") {
        $.ajax({
            type: 'post',
            datatype: 'text',
            url: "/index.aspx?c=course&a=teacherview&addmoreask=" + id + "&parentID=" + j ,
            data: { content: askcontent, tcid: id },
            success: function (msg) {
                if (msg == "0") { 
                    alert("您未登录，请登录");
                    location.href = config.userLogin
                }
                else if (msg == "00") { }
                else {
                    getuserask(id);
                }
            }
        });
    }
    else alert("请输入回复内容");
}



var num = 1;
var face = 1;
var live = 1;
var ask = 1;
flagtype=1;


function oncourselist() {
    $("#toploadcourse").hide();
    num++;
    loadks("TeacherViewCourse", id, num);
}
function onfacelist() {
    $("#toploadface").hide();
    face++;
    loadks("TeacherViewFaceCourse", id, face);
}
function onlivelist() {
    $("#toploadlive").hide();
    live++;
    loadks("TeacherViewLiveCourse", id, live);
}
function onasklist() {
    $("#toploadask").hide();
    ask++;
    loadks("TeacherViewAskList", id, ask);
}
$(document).ready(function () {

    flagtype = 1;
    loadks("TeacherViewCourse", id, 1);
    loadks("TeacherViewFaceCourse", id, 1);
    loadks("TeacherViewLiveCourse", id, 1);
    loadks("TeacherViewAskList", id, 1);
    
    $("#toploadcourse").click(function () {
        oncourselist();
    });
    $("#toploadface").click(function () {
        onfacelist();
    });
    $("#toploadlive").click(function () {
        onlivelist();
    });
    $("#toploadask").click(function () {
        onasklist();
    });

});

/**
 * 提问问答
 */
function subask() {
    var content = $("#asktext").val();
    if (content == '') {
        alert("请输入问题内容");
        
    } else {
        
        teacheraskgo(0, content, id);
    }

}

function teacheraskgo(id, content, tcid) {

    $.ajax({
        url: "/plus/course/CourseAjax.ashx?action=subask&courseid=" + id + "&content=" + escape(content) + "&tcid=" + tcid,
        context: document.body,
        success: function (d) {
            if (d == "ok") {
                alert("问题发表成功，请耐心等待，名师将很快为您解答!");
                $("#contentask").val('');
                window.scrollTo(0,0)
                loadks("TeacherViewAskList", tcid, 1);
            
            }
        }
    });
}

$(function(){
    
    //讲师课程切换	
    $("#coursetab dt").click(function(){
        var i = $(this).index()
        $("#coursetab dt").removeClass("curr")
        $(this).addClass("curr")
        $(".teachercourse .tcourselist").hide()
        $(".teachercourse .tcourselist:eq("+i+")").show()
        
    });
    
    //评价讲师弹出
    $("#pjclick").click(function(){
        $("#mywrapbg").fadeIn(500)
        $("#commentbox").animate({bottom:"4.083em"},500)
        $(".foot_tcalk ul li:eq(0)").addClass("curr")
    });
    $("#mywrapbg,#closebg").click(function(){
        $("#mywrapbg").fadeOut(500)
        $("#commentbox").animate({bottom:"-24em"},500)
        $(".foot_tcalk ul li:eq(0)").removeClass("curr")
    });
    
    //教师信息切换
    var t = $("#epinfo").text()
    if(t==""){
        $("#epinfo").parents(".teacherintro").hide()
    }
    
    //评价没数据的时候
    var a = $(".teacherintro .box2 li").length;
    if(a=="0"){
        $(".teacherintro .box2").html("<div class=empty2>该老师还没有学员评价哦~</div>")	
    }
    
    //教师介绍判断
    
    var tinfo = $.trim($(".teacherintro .box1").text());
    if(tinfo==""){
        $(".teacherintro .box1").html("<div class=empty2>该老师暂无介绍~</div>")	
    }
    
    
});

function _$(id) {
    return document.getElementById(id);
}
function select_sort(s, v) {
    for (i = 1; i <= 5; i++) {
        if (i <= v) {
            _$("img_" + s + i).src = config.templateDir+"/static/teacher/images/icon_star2.png";
        }
        else {
            _$("img_" + s + i).src = config.templateDir+"/static/teacher/images/icon_star1.png";
        }
    }
    if (v == 1) {
        _$("stext" + s).innerHTML = "<b>1分</b> &nbsp;很差";
    }
    else if (v == 2) {
        _$("stext" + s).innerHTML = "<b>2分</b> &nbsp;差";
    }
    else if (v == 3) {
        _$("stext" + s).innerHTML = "<b>3分</b> &nbsp;一般";
    }
    else if (v == 4) {
        _$("stext" + s).innerHTML = "<b>4分</b> &nbsp;好";
    }
    else if (v == 5) {
        _$("stext" + s).innerHTML = "<b>5分</b> &nbsp;很好";
    }
    $("#star").val(v);
}
    
