var time = 30 * 1000,testNextTimer,nowindex, nowobj, findNexttimer, thisTid,treeobjarr;
/**
* 查是否有下一页
*/
function testNext() {
    // 检验当前课件是否已播放完成,已播放完成,下一课件可播放;未播放完成,下一课件不可播放
    var isLearnedFlag = false;
    var url = contextPath + "/web/player!judgeClickChapterIsLearned.do?" +
        "curCourseId=" + getCurCourseId(chapterId) + "&chapterIds=" + chapterId + "&chapterWareId=" + wareId;
    myLandAjaxJson(url, "", function (code, ajaxPara) {
        var temp = eval("(" + ajaxPara + ")");
        if (de == "00") {
            isLearnedFlag = true;
        } else if (de == "11") {
            isLearnedFlag = false;
            mylandAlert("信息提示", ssage);
        }
    });
    if (isLearnedFlag) {
        chapterWareId = nxtNode;
        chapterId = nxtChapterId;
        firstWareMark = 1;
        curCourseId = getCurCourseId(chapterId);
        selectingNode = NodeByParam("id", chapterId, null);
        player_mp4(chapterId, curCourseId);
    }
    $(".aui_buttons button").click();
    unt("testNext")
}
/**
* 查当前播放节点
*/
function findnow() {
    thisTid = SelectedNodes()[0].tId;
    console.log("thisTid:", thisTid)
    for (var i = 0; i < treeobjarr.length; i++) {
        var treenode = treeobjarr[i]
        if (thisTid == treenode.tId) {
            nowindex = i;
            console.log("nowindex:", nowindex)
            break;
        }
    }
}
/**
* 查下一个可以播放的节点
*/
function findNext() {
    console.log("findNext")
    for (var i = nowindex + 1; i < treeobjarr.length; i++) {
        var treenode = treeobjarr[i]网页自动关闭
        if (treenode.check_Child_State == -1) {
            nowindex = i;
            nowobj = treenode;
            console.log("nextindex:", nowindex)
            console.log("nextobj:", nowobj)
            break;
        }
    }
}
/**
* 播放下一节点
* @param e undefined
* @param treeId undefined
* @param treeNode 下一章节节点
*/
function selectNext(e, treeId, treeNode) {
    chapterWareId = "";
    var lastAvalibleNode = SelectedNodes()[0];
    if (treeNode.isParent) {
        pandNode(treeNode);
    } else {
        if (new Date().getTime() - clickTime < 3000) {
            return;
        }
        clickTime = new Date().getTime(); // 记录当前时间
        var isLearnedFlag = false;
        var url = contextPath + "/web/player!judgeClickChapterIsLearned.do?" +
            "curCourseId=" + urseId + "&chapterIds=" + treeNode.id;
        myLandAjaxJson(url, "", function (code, ajaxPara) {
            var temp = eval("(" + ajaxPara + ")");
            if (de == "00") {
                isLearnedFlag = true;
            } else if (de == "11") {
                isLearnedFlag = false;
                mylandAlert("信息提示", ssage);
            } else { // 02提示未登录或session失效
                isLearnedFlag = false;
                mylandConfirmByFunc("信息提示", ssage, function () {
                    p.location.href = thirdWebSite;
                    return true;
                }, null, "确定", null);
                return;
            }
        });
        if (isLearnedFlag) {
            player_mp4(treeNode.id, urseId);
            zTreeObj.selectNode(treeNode)
        } else {
            if (lastAvalibleNode != null) {
                zTreeObj.selectNode(lastAvalibleNode);
            }
        }
    }
}
/**
* 翻章节
* @param nowobj 当前将要翻页的对象
*/
function testfanye(nowobj) {
    console.log(nowobj)
    selectNext(undefined, undefined, nowobj);
    $(".aui_buttons button").click();
    if (thisTid != SelectedNodes()[0].tId) {
        console.log("yi jing fan ye")
        thisTid = SelectedNodes()[0].tId;
        console.log("thisTid:", thisTid)
        findNext();
    } else {
        console.log("pre and next tid is same")
    }
}
// 开始逻辑
testNextTimer = setInterval(testNext, time);
treeobjarr = Nodes())
findnow();
findNext();
findNexttimer = setInterval(function () {
    testfanye(nowobj)
}, time);
// 关闭逻辑
//关闭自动下页
clearInterval(testNextTimer)
//关闭翻章节
clearInterval(findNexttimer)窗体底端