/*function deleteFriend(friendId){
 callGetAjax("/ajax/deletefriend.do?friendId="+friendId);
 }*/

$(function() {
    $("#toggle").click(function() {
        processToggle();
        this.checked = !this.checked;
    });
})


function viewGift(giftId) {
    $("#giftLists").load("/ajax/gift/giftShopAjax.do", {giftId:giftId});
}
function deleteUserPractice(userId, practiceId) {
    confirm("Delete this exercise?", function() {
        $.getJSON("/ajax/deleteUserPractice.do", { userId: userId,practiceId: practiceId},
                function(json) {
                    $("#result_" + practiceId + "_" + userId).fadeOut();
                    var number = $('#jspTotal').val();
                    if (number == '1') {
                        number = '0';
                    } else {
                        number = number - 1;
                    }
                    $('#jspTotal').val(number);
                    $("#total").html(number);
                }
                );
    })
}
function removeActivity(activityId) {

    confirm("你确认要删除吗? ", function() {
        $.get("/www/activityRemove.do?id=" + activityId,
                function() {
                    window.location.replace('/www/activityList.do');
                }
                );
    })
}
function removeapp(appid) {
    confirm("确认要卸载弄清该工具吗?<br>卸载之后你的工具使用记录会被清空。", function() {
        $.get("/appoperate.do?operatetype=deleteapp&appid=" + appid,
                function() {
                    window.location.replace('/appoperate.do?operatetype=deletelist');
                }
                );
    })
}
function cancelActMem(actId) {
    confirm("你确认要取消报名吗？", function() {
        $.get("/www/act/activityMember.do?id=" + actId + "&mact=cancel",
                function() {
                    window.location.replace("/www/act/activityMember.do?id=" + actId);
                }
                );
    })
}
function loadLessons(courseId, faceId) {
    $("#lessons").load("/ajax/loadLessons.do", {courseId:courseId,faceId:faceId});
}
function loadCourses(categoryId, faceId) {
    //    alert("sdf");
    $("#courses").load("/ajax/loadCourses.do", {categoryId:categoryId,faceId:faceId})
}
function adminloadCourses(categoryId, faceId) {
    //    alert("sdf");
    $("#courses").load("/ajax/courses.do", {categoryId:categoryId,faceId:faceId})
}
function loadCitys(provinceId) {
    $("#city").load("/ajax/loadCity.do", {provinceId:provinceId});
}
function loadTags(cityId) {
    $("#tagDiv").load("/ajax/loadTag.do", {cityId:cityId});

}
function loadSubCategory(categoryId) {
    $("#subcate").load("/ajax/loadSubCat.do", {categoryId:categoryId});
}
//comment functions start
function addComment(targetType, targetId, receiverId, viewAll) {
    var submitButton = document.getElementById("f-f-addcomment-button");
    submitButton.value = "posting... ...";
    submitButton.disabled = true;
    var content = $('#f-f-commentBody').val();
    var inputValidate = $('#inputValidate').val();
    $.post("/ajax/addComment.do", { receiverId: receiverId,targetType:targetType,targetId:targetId,content:content,inputValidate:inputValidate},
            function(json) {
                json = eval("(" + json + ")");
                var result = json.result;
                if (result == 1) {
                    $("#commentData").load("/ajax/commentList.do", {receiverId: receiverId,targetType:targetType,targetId:targetId,add:true,viewAll:viewAll});
                } else {
                    $("#commentTip").html(json.msg);
                }
                submitButton.value = "post";
                submitButton.disabled = false;
            }
            );
}
function deleteComment(targetType, targetId, commentId) {
    confirm("Delete this comment?", function() {
        $.getJSON("/ajax/deletecomment.do", { targetType:targetType,targetId:targetId,commentId: commentId},
                function(json) {
                    $("#comment_" + commentId).fadeOut();
                }
                );
    })
}
function addPostComment(targetType, targetId, receiverId, commentId, viewAll) {
    var submitButton = document.getElementById("f-f-addcommentPost-button");
    submitButton.value = "posting... ...";
    submitButton.disabled = true;
    var content = $('#postComment' + commentId).val();
    var postValide = $('#inputPostValidate' + commentId).val();
    $.post("/ajax/addPostComment.do", { receiverId: receiverId,targetType:targetType,targetId:targetId,commentId: commentId ,content:content,postValide:postValide},
            function(json) {
                json = eval("(" + json + ")");
                var result = json.result;
                if (result == 1) {
                    $("#postComments_" + commentId).load("/ajax/postCommentList.do", {receiverId: receiverId,targetType:targetType,targetId:targetId,commentId: commentId,viewAll:viewAll});

                    var form = document.getElementById("replyForm" + commentId);
                    var textCon = document.getElementById("postComment" + commentId);
                    textCon.value = "";
                    if (!viewAll) {
                        form.style.display = 'none';
                    }
                }
                $("#commentTip" + commentId).show();
                $("#commentTip" + commentId).html(json.msg);
                submitButton.value = "post";
                submitButton.disabled = false;
            }
            );
}

function addStudentPostComment(faceCommentId, faceId) {
    //    var submitButton = document.getElementById("f-f-addcommentPost-button");
    //    submitButton.value="posting... ...";
    //    submitButton.disabled=true;
    var content = $('#postComment' + faceCommentId).val();
    var postValide = $('#inputPostValidate' + faceCommentId).val();
    $.post("/ajax/addStudentPostComment.do", { faceCommentId: faceCommentId,faceId:faceId,content:content,postValide:postValide},
            function(json) {
                json = eval("(" + json + ")");
                var result = json.result;
                if (result == 1) {
                    $("#postStudentComments_" + faceCommentId).load("/ajax/postStudentCommentList.do", { faceCommentId: faceCommentId,faceId:faceId});
                    var form = document.getElementById("replyForm" + faceCommentId);
                    var textCon = document.getElementById("postComment" + faceCommentId);
                    textCon.value = "";
                    form.style.display = 'none';
                }
                $("#commentTip" + faceCommentId).show();
                $("#commentTip" + faceCommentId).html(json.msg);
            }
            );
}
function deleteStudentPostComment(postFaceCommentId, faceCommentId) {
    confirm("确定要删除 ?", function() {
        $.getJSON("/ajax/delStudentPostComment.do", {postFaceCommentId:postFaceCommentId},
                function(json) {
                    $("#facepostcomment_" + postFaceCommentId).fadeOut();
                    //                    $("#commentTip" + postFaceCommentId).hide();
                    $("#commentTip" + faceCommentId).hide();
                }
                );
    })
}
function deletePostComment(targetType, targetId, commentId, postCommentId) {
    confirm("确定要删除 ?", function() {
        $.getJSON("/ajax/deletePostComment.do", {targetType:targetType,targetId:targetId, postCommentId: postCommentId},
                function(json) {
                    $("#postcomment_" + commentId + "_" + postCommentId).fadeOut();
                    $("#commentTip" + commentId).hide();
                }
                );
    })
}
//comment functions end

function processFaceMember(userFaceId) {
    $.get("/ajax/faceMember.do", { userFaceId: userFaceId,status:"1"},
            function(json) {
                $("#buttons").html("You have accepted his request.");
            }
            );
}

function refuseFaceMember(userFaceId, count) {
    confirm("Are you sure to refuse this request?", function() {
        $.get("/ajax/faceMember.do", { userFaceId: userFaceId,status:"-1"},
                function(json) {
                    $("#studentItem" + count).fadeOut();
                }
                );
    })
}

function joinMyEt() {
    var name = $("#name").val();
    var phone = $("#phone").val();
    var email = $("#email").val();
    var msn = $("#msn").val();

    $.post("/ajax/joinMyEt.do", {name: name,phone:phone,email:email,msn:msn},
            function(data) {
                data = eval("(" + data + ")");
                if (data.result == '0') {
                    $("#joinError").html(data.error);
                } else if (data.result == '1') {
                    $("#joinError").html(data.error);
                }
                else {
                    $("#joinMyEt").load("/ajax/joinMyEtSucc.do");
                }
            }
            );

}
function changeMessage() {
    var name = $("#name1").val();
    var phone = $("#phone1").val();
    var email = $("#email1").val();
    var msn = $("#msn1").val();
    $.post("/ajax/changeMessage.do", {name: name,phone:phone,email:email,msn:msn},
            function(data) {
                $("#joinMyEt").html(data);
            }
            );
}


function deleteMsg(msgId) {
    confirm("确定要删除 ?? ", function() {
        $.getJSON("/ajax/deletemsg.do", { msgId: msgId},
                function(json) {
                    $("#result_" + msgId).fadeOut();
                    if (json.result == 1) {
                        $("#hide").fadeIn();
                    }
                }
                );
    })
}
function deleteHello(sayhelloid) {
    confirm("确认删除这个招呼吗? ", function() {
        $.getJSON("/ajax/deletehello.do", { sayhelloid: sayhelloid},
                function(json) {
                    $("#result_" + sayhelloid).fadeOut();
                    if (json.result == 1) {
                        $("#hide").fadeIn();
                    }

                }
                );
    })
}
function deleteTeacher(action, tid) {

    confirm("确定要删除 ? ", function() {
        $.get("/admin/assistantManageTeacher.do", { tid: tid,action:action},
                function() {
                    $("#result_" + tid).fadeOut();
                }
                );
    })
}
function deleteMemberCustom(type, mcid) {

    confirm("你确认要删除吗? ", function() {
        $.get("/club/memberCustomManage.do", { mcid:mcid,type:type},
                function() {
                    $("#result_" + mcid).fadeOut();
                }
                );
    })
}
function leaderDeleteTeacher(action, tid) {

    confirm("确定要删除 ?", function() {
        $.get("/leader/leaderManagerTeacher.do", { tid: tid,action:action},
                function() {
                    $("#result_" + tid).fadeOut();
                }
                );
    })
}
function processToggle() {
    $("input[@type='checkbox']").each(function() {
        this.checked = !this.checked;
    });
}
function findFriendByEmail() {

    if ($("#youremail").val() == ("")) {
        alert('请输入邮箱');
        return false;
    }
    if ($("#yourpassword").val() == "") {
        alert('请输入邮箱密码');
        return false;
    }
    if ($("#serviceoffer").val() == "") {
        alert('请选择邮箱类型');
        return false;
    }


}
function addFriend(user_id) {
    $.get("/ajax/addfriend.do", {targetId: user_id},
            function(data) {
                var aman = eval("(" + data + ")");
                if (aman.status == 90) {
                    window.location = "/photoError.do?turn=2";
                    //                    alert("dff")
                    //                    $.post("/sendmsgform.do");

                }
                /*alert(aman.msg, function hiddenLink() {
                 if (aman.status == 1) {
                 $("#result_" + user_id).fadeOut();
                 }
                 });*/ else {
                    $("#friendlink" + user_id).html(aman.msg);
                }

            }
            );
}
function addVocabulary(temp_Id) {
    var vocabulary = $("#vocabulary").val();
    var meaning = $("#meaning").val();
    $("#div_vocabulary_list").load("/ajax/addVocabulary.do", {tempId:temp_Id,vocabulary:vocabulary,meaning:meaning});
    $("#vocabulary").val("");
    $("#meaning").val("");
}
function deleteVocabulary(key) {
    //var key=$("#key").val();
    var tempId = $("#tempId").val();
    $.get("/ajax/deleteVocabulary.do", {tempId:tempId,key:key},
            function() {
                $("#" + key).fadeOut();
            });
}
function addFavsTopic(topicId, userId) {
    if (userId == 0) {
        $("#addToFavorites").html("<span>please <a href=\"/loginForm.do\">log in</a></span>");
    } else {
        $("#addToFavorites").load("/ajax/addFav.do", {topicId:topicId})
    }
}
function deleteFavsTopic(userId, topicId) {
    confirm("Are you sure to remove this topic?", function() {
        $.get("/ajax/deleteFavs.do", {ownerId:userId,topicId:topicId},
                function() {
                    $("#result_" + topicId).fadeOut();
                })
    });
}
function addSpeakLanguage() {
    var speak = $("#speakid option[@selected]").val();
    var level = $("#speaklevel option[@selected]").val();
    $.get("/ajax/addlanguage.do", {language: speak,level:level,type:'speak'},
            function(data) {
                var aman = eval("(" + data + ")");
                if (aman.result == 1) {
                    $("#speak").load("/ajax/languageList.do?type=speak&add=true");
                }
            }
            );
}
function editLearnLanguage(learn) {
    var level = $("#learnlevel_edit" + learn + " option[@selected]").val();
    $.get("/ajax/editLevel.do", {language:learn,level:level,type:'learn'},
            function(data) {
                var aman = eval("(" + data + ")");
                if (aman.result == 1) {
                    $("span#learn_level" + learn).html(' ' + aman.levelStr);
                    hidelevel(learn, 1);
                    $("#div_lang_learn").show();
                    $("#div_lang_learn").html("<span class=\"ajaxSuccess\">修改成功 !</span>");
                }
            }
            )
}
function editSpeakLanguage(speak) {
    var level = $("#speaklevel_edit" + speak + " option[@selected]").val();
    $.get("/ajax/editLevel.do", {language:speak,level:level,type:'speak'},
            function(data) {
                var aman = eval("(" + data + ")");
                if (aman.result == 1) {
                    $("span#speak_level" + speak).html(' ' + aman.levelStr);
                    hidelevel(speak, 0);
                    $("#div_lang_speak").show();
                    $("#div_lang_speak").html("<span class=\"ajaxSuccess\">Changes saved !</span>");
                }
            }
            )
}
function addLearnLanguage() {
    var learn = $("#learnid option[@selected]").val();
    var level = $("#learnlevel option[@selected]").val();
    $.get("/ajax/addlanguage.do", {language: learn,level:level,type:'learn'},
            function(data) {
                //                alert(data);
                var aman = eval("(" + data + ")");
                if (aman.result == 1) {
                    $("#learnLan").load("/ajax/languageList.do?type=learn&add=true");

                }
            }
            );
}

function deleteLearnLanguage(learn) {
    $.get("/ajax/deletelanguage.do", {language: learn},
            function(data) {
                var aman = eval("(" + data + ")");
                $(".resultlearn" + learn).fadeOut();
            }
            );
}
function deleteSpeakLanguage(speak) {
    $.get("/ajax/deletelanguage.do", {language: speak,type:'speak'},
            function(data) {
                var aman = eval("(" + data + ")");
                $(".resultspeak" + speak).fadeOut();
            }
            );
}
function deleteFriend(user_id) {
    confirm("delete this Friend?", function() {
        $.get("/ajax/deletefriend.do", {friendId: user_id},
                function(data) {
                    var aman = eval("(" + data + ")");
                    $("#result_" + user_id).fadeOut();
                    $("span.delFriend").hide();
                }
                );
    });
}
function deleteTopic(topicId) {
    confirm("确定要删除这个话题 ?", function() {
        $.get("/ajax/deleteTopic.do", {topicId: topicId},
                function() {
                    $("#result_" + topicId).fadeOut();
                }
                );
    });
}
function processRequest(requestId, action) {
    $.get("/ajax/processrequest.do", {requestId: requestId,action:action},
            function(data) {
                var aman = eval("(" + data + ")");
                // alert(aman.msg,
                $("#sucess").html("<span style=\"color:#000\">" + aman.msg + "</span>");
                $("#result_" + requestId).fadeOut();

            }
            );
}
//$(function() {
//    viewMsgAndRequestCount();
//    setInterval(function() {
//        viewMsgAndRequestCount();
//    }, 60000)
//
//});

//function viewMsgAndRequestCount() {
//    $.get("/ajax/count.do",
//            function(data) {
//                var aman = eval("(" + data + ")");
//
//                $('#navMessageCount').html("(" + aman.msgcount + ")");
//                $('#navFriendCount').html("(" + aman.reqcount + ")");
//            }
//            );
//}
function submitinvite(youxiang) {

    var account = $("#acount" + youxiang).val();
    var pass = $("#pass" + youxiang).val();
    var type = $("#serviceoffer").val();
    if (account == "") {
        alert("账号不能为空");
        return false;
    }
    if (pass == "") {
        alert("密码不能为空");
        return false;
    }
    $("body").append("<div id=\"backcolor\" style=\"background: rgb(51, 51, 51) none repeat scroll 0% 0%; display: none; width: 100% ! important; height: 600px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; opacity: 0.2; position: absolute; top: 0px; left: 0px;\"></div>")
    $("body").append("<div id=\"loadimg\" style=\"position:absolute;left:400px;bottom: 250px;z-index:12000;\"></div>")
    $("#backcolor").css("display", "block");
    $("#loadimg").html("<img src='/images/loadingAnimation.gif'/><br/>正在获取通讯录，请稍侯...");
    $.post("/ajax/invitemsn.do", { account: account ,pass:pass,type:type,youxiang:youxiang},
            function(json) {
                json = eval("(" + json + ")");
                var result = json.result;
                $("#backcolor").css("display", "none");
                $("#loadimg").html("");
                if (result == 1) {
                    $("#result_message").html("<p style='color:darkorange;font-size:26px;font-weight:bold;'>邀请邮件发送成功！</p>")
                } else if (result == 2) {
                    $("#geterror" + youxiang).show();
                } else if (result == 3) {
                    $("#getempty" + youxiang).show();
                }
            }
            );

}
function addCourseComment(cid) {

    var content = $('#f-f-courseCommentBody').val();
    $.post("/ajax/courseComment.do", { cid: cid ,content:content},
            function(json) {
                json = eval("(" + json + ")");
                var result = json.result;
                if (result == 1) {
                    $("#courseCommentData").load("/ajax/courseCommentList.do", {id:cid,add:true});
                } else {
                    $("#commentTip").html(json.msg);
                }
            }
            );
}
function deleteCourseComment(commentId) {
    confirm("Delete this comment?", function() {
        $.getJSON("/ajax/deleteCourseComment.do", { courseCommentId: commentId},
                function(json) {
                    $("#comment_" + commentId).fadeOut();
                }
                );
    })
}

function joinFace(faceId, userLevel, faceLevel, faceType) {
    var content = $('#practiceContent').val();
    confirm("确定要报名参加该面授课吗？", function() {
        $.post("/ajax/joinFace.do", {faceId: faceId},
                function(json) {
                    json = eval("(" + json + ")");
                    var result = json.result;
                    if (result == 1) {
                        $("#joinFace").html("<span class=\"ajaxSuccess\">Attended successfully !</span>");
                        $("#joinFace1").html("<span class=\"ajaxSuccess\">Attended successfully !</span>");
                    } else if (result == 2) {
                        window.location = "/club/faceDetail.do?faceId=" + faceId;
                        //                         $("#joinFace").html("<span class=\"ajaxSuccess\">确认通过!</span>");
                        //                        $("#joinFace1").html("<span class=\"ajaxSuccess\">确认通过 !</span>");
                    } else if (result >= 100) {
                        tb_show('close', '/ajax/joinFace.jsp?height=250&width=300&modal=true&faceId=' + faceId + '&faceType=' + faceType, '');
                    }
                }
                );
    });
}

function joinFaceByAdviser(faceId, userId) {
    confirm("确定要报名参加该面授课吗？", function() {
        $.post("/admin/joinFace.do", {faceId:faceId,userId:userId},
                function(json) {
                    json = eval("(" + json + ")");
                    var result = json.result;
                    var conName = "join" + userId;
                    document.getElementById(conName).innerHTML = json.msg;
                });
    });
}
function addPostCourseComment(id, courseId) {
    var content = $('#postComment' + id).val();
    $.post("/ajax/postCourseComment.do", { id: id ,postcontent:content},
            function(json) {
                json = eval("(" + json + ")");
                var result = json.result;
                if (result == 1) {
                    $("#courseCommentData").load("/ajax/courseCommentList.do", {id:courseId,addPost:true,courseCommentId:id});
                } else {
                    $("#commentTip" + id).show();
                    $("#commentTip" + id).html(json.msg);
                }
            }
            );
}

function showReply(commentId) {
    $("#replyForm" + commentId).show();
    $("#commentTip" + commentId).hide();
    $("#postCommentTip" + commentId).html("");
    var textCon = document.getElementById("postComment" + commentId);
    textCon.value = "";
    var textCode = document.getElementById("inputPostValidate" + commentId);
    textCode.value = "";
    var rand = Math.round(Math.random() * 10000);
    document.getElementById("validateCodePost" + commentId).src = '/postVaCode?r=' + rand;
}
function hideReply(commentId) {
    $("#replyForm" + commentId).hide();
    $("#commentTip" + commentId).hide();
    $("#postCommentTip" + commentId).show();
    $("#postCommentTip" + commentId).html("");
    $("#postVideoComment" + commentId).value = "";
    //    $("#postCommentTip"+commentId).values="";
    //    alert("df");
}
function deletePostCourseComment(postCommentId, commentId) {
    confirm("Delete this comment?", function() {
        $.getJSON("/ajax/deletePostCourseComment.do", { postCourseCommentId: postCommentId},
                function(json) {
                    $("#postcomment_" + commentId + "_" + postCommentId).fadeOut();
                    $("#commentTip" + commentId).hide();
                }
                );
    })
}


function showMoreDesc() {
    $("#moreDesc").show();
    $("#lessDesc").hide();
}
function hiddenMoreDesc() {
    $("#lessDesc").show();
    $("#moreDesc").hide();
}
function isURL(argvalue)
{
    if (argvalue.indexOf(" ") != -1)
    {
        alert("不允许空格!");
        return false;
    }
    else if (argvalue.indexOf("http://") == -1)
    {
        alert("必须以http://开头");
        return false;
    }
    else if (argvalue == "http://")
        {
            alert("请输入完整的地址 !");
            return false;
        }

    argvalue = argvalue.substring(7, argvalue.length);
    if (argvalue.indexOf(".") == -1)
    {
        alert("Please enter an extension like .com, .edu(etc) for  urlname !");
        return false;
    }
    else if (argvalue.indexOf(".") == 0)
    {
        alert("Please enter correct  urlname!");
        return false;
    }
    else if (argvalue.charAt(argvalue.length - 1) == ".")
        {
            alert("Please enter an extension after . like com, edu(etc) for  urlname !");
            return false;
        }

    if (argvalue.indexOf("/") != -1)
    {
        argvalue = argvalue.substring(0, argvalue.indexOf("/"));
        if (argvalue.charAt(argvalue.length - 1) == ".")
        {
            alert("Please enter correct  urlname !");
            return false;
        }
    }

    if (argvalue.indexOf(":") != -1)
    {
        if (argvalue.indexOf(":") == (argvalue.length - 1))
        {
            alert("Please enter correct  urlname !");
            return false;
        }
        else if (argvalue.charAt(argvalue.indexOf(":") + 1) == ".")
        {
            alert("Please enter correct  urlname !");
            return false;
        }
        argvalue = argvalue.substring(0, argvalue.indexOf(":"));
        if (argvalue.charAt(argvalue.length - 1) == ".")
        {
            alert("Please enter correct urlname !");
            return false;
        }
    }
    return true;
}
function validateDetail() {
    var title = document.getElementById("title");
    var category = document.getElementsByName("category");
    var learn = document.getElementsByName("learn");
    var b = false;
    if (title.value == "") {
        alert("title不能为空");
        return false;
    }
    if (learn.value == -1) {
        alert("请选择一个要学的语言")
        return false;
    }
    for (var i = 0; i < category.length; ++i) {
        if (category[i].checked) {
            b = true;
        }
    }
    if (b == false) {
        alert("请选择一个种类");
        return false;
    }
    return true;
}
function sortVideo(value) {
    $("#videoCommentData").load("/ajax/vidoList.do", {order:value});
}
function getOrderValue() {
    var value = $("#sort_order").val();
    return value;
}
function addTopicComment(topicId) {
    var content = $("#topicCommentContent").val();
    $.post("/ajax/topicComment.do", {topicId:topicId,content:content},
            function(json) {
                json = eval("(" + json + ")");
                var result = json.result;
                if (result == 1) {
                    $("#topicComment").load("/ajax/topicCommentList.do", {topicId:topicId,add:true});
                } else {
                    $("#commentTip").html(json.msg);
                }
            }
            )

}
function deleteTopicComment(topicCommentId) {
    confirm("Delete this comment?", function() {
        $.getJSON("/ajax/deleteTopicComment.do", { topicCommentId: topicCommentId},
                function(json) {
                    $("#comment_" + topicCommentId).fadeOut();
                }
                );
    })
}
function addPostTopicComment(topicCommentId, topicId) {
    var content = $('#postTopicComment' + topicCommentId).val();
    $.post("/ajax/addPostTopicComm.do", {topicCommentId:topicCommentId,content:content},
            function(json) {
                json = eval("(" + json + ")");
                var result = json.result;
                if (result == 1) {
                    $('#postTopicComments' + topicCommentId).load("/ajax/postTopicCommentList.do", {topicCommentId:topicCommentId,topicId:topicId});
                    $('#replyForm' + topicCommentId).hide();
                    var form = document.getElementById("replyForm" + topicCommentId);
                    var textCon = document.getElementById("postTopicComment" + topicCommentId);
                    textCon.value = "";
                    form.style.display = 'none';
                }
                $("#postCommentTip" + topicCommentId).show();
                $("#postCommentTip" + topicCommentId).html(json.msg);
            })
}
function deletePostTopicComment(postTopicCommentId) {
    confirm("确定要删除 ?", function() {
        $.getJSON("/ajax/deletePostTopicComment.do", { postTopicCommentId: postTopicCommentId},
                function(json) {
                    $('#postTopicComments' + postTopicCommentId).fadeOut();
                }
                );
    })
}
function addVideoComment(videoId) {
    var content = $("#videoCommentContent").val();
    $.post("/ajax/videoComment.do", {videoId:videoId,content:content},
            function(json) {
                json = eval("(" + json + ")");
                var result = json.result;
                if (result == 1) {
                    //                    alert(videoId)
                    $("#videoComment").load("/ajax/videoCommentList.do", {id:videoId,add:true});
                } else {
                    $("#commentTip").html(json.msg);
                }
            }
            )

}
function deleteVideoComment(videoCommentId) {
    confirm("确定要删除 ?", function() {
        $.getJSON("/ajax/deleteVideoComment.do", { videoCommentId: videoCommentId},
                function(json) {
                    $("#comment_" + videoCommentId).fadeOut();
                }
                );
    })
}
function addPostVideoComment(videoCommentId) {
    var content = $('#postVideoComment' + videoCommentId).val();
    $.post("/ajax/addPostVideoComment.do", {videoCommentId:videoCommentId,content:content},
            function(json) {
                json = eval("(" + json + ")");
                var result = json.result;
                if (result == 1) {
                    $('#postVideoComments' + videoCommentId).load("/ajax/postVideoCommentList.do", {videoCommentId:videoCommentId,addPost:true});
                    var textCon = document.getElementById("postVideoComment" + videoCommentId);
                    textCon.value = "";
                    $('#replyForm' + videoCommentId).hide();
                    $("#postCommentTip" + videoCommentId).hide();
                    //                    var textTip=document.getElementById("commentTip"+videoCommentId);
                    //                    alert(textTip.value);
                    //                    textTip.value="";
                    //                    alert("df");
                    //                    $("#postCommentTip"+videoCommentId).value="";
                }
                //                else {
                //                    alert("dfd");
                $("#postCommentTip" + videoCommentId).html(json.msg);
                //                }
            })
}
function deletePostVideoComment(postVideoCommentId) {
    confirm("确定要删除 ?", function() {
        $.getJSON("/ajax/deletePostVideoComment.do", { postVideoCommentId: postVideoCommentId},
                function(json) {
                    $('#postVideoCommentss' + postVideoCommentId).fadeOut();
                }
                );
    })
}
function addFavoriteVideo(videoId, userId) {
    //    addToFavorites
    //    alert(userId+"df");
    if (userId == 0) {
        $("#addToFavorites").html("<span>please <a href=\"/loginForm.do\">登录</a></span>");

    } else {
        $("#addToFavorites").load("/ajax/addFavorite.do", {videoId:videoId});
    }

    //    $.load()
}
function removeFavorite(userId, videoId) {
    confirm("Are you sure to remove this video?", function() {
        $.getJSON("/ajax/removeFavorite.do", {uid:userId,vid:videoId},
                function(json) {
                    $('#favorite_' + userId + '_' + videoId).fadeOut();
                })
    })
}
function deleteVideo(videoId) {
    confirm("Are you sure to delete this video?", function() {
        $.getJSON("/ajax/deleteVideo.do", {id:videoId},
                function(json) {
                    $('#video' + videoId).fadeOut();
                })
    })
}
function showMoreInfor() {
    $("#infor").show();
    $("#more").hide();
    $("#less").show();
}
function lessInfor() {
    $("#less").hide();
    $("#infor").hide();
    $("#more").show();
}

function sayHeloForm(nickName, receiverid, gender, icon, replyid) {

    $.post("/ajax/sayhelloform.do", {receiverid:receiverid},
            function(json) {
                json = eval("(" + json + ")");
                var result = json.friend;
                if (result == 'yes') {
                    tb_show('向' + nickName + '打招呼', '/ajax/sayhellofriend.jsp?height=450&width=500&modal=false&receiverid=' + receiverid + '&gender=' + gender + '&icon=' + icon + '&replyid=' + replyid, '');
                } else {
                    tb_show('向' + nickName + '打招呼', '/ajax/sayhello.jsp?height=350&width=500&modal=false&receiverid=' + receiverid + '&gender=' + gender + '&icon=' + icon + '&replyid=' + replyid, '');
                }
            });


}
function showwordselect(wordcourseid) {
    $.post("/ajax/showwordselect.do", {wordcourseid:wordcourseid},
            function(json) {
                json = eval("(" + json + ")");
                var result = json.studied;
                var filterover = json.filterover;
                var learnover = json.learnover;
                if (result == 'yes') {
                    if (filterover == 'yes') {

                        $(".wordcontentload").load('/ajax/wordselect.jsp?wordcoursid=' + wordcourseid + '&studyover=' + learnover);
                    } else {
                        //继续过滤。标志

                        $(".wordcontentload").load("/ajax/wordfilter.do", {wordcourseid:wordcourseid,comeon:'yes'});
                    }
                } else {
                    $(".wordcontentload").load("/ajax/studyword.do", {wordcourseid:wordcourseid,isnew:'yes'});
                }
            });
}
function loadwordfilter(wordcourseid, lastpage) {
    var unSelect = "";
    $("input[@name=wordscheck]").each(function() {
        if ($(this).attr("checked") == undefined) {
            unSelect += $(this).val() + ',';
        }
    });
    $(".wordcontentload").load("/ajax/wordfilter.do", {wordcourseid:wordcourseid,filterover:lastpage,forgetids:unSelect});
}
function loadfirtfilter(wordcourseid) {
    $(".wordcontentload").load("/ajax/wordfilter.do", {wordcourseid:wordcourseid});
}
function loadwordstudy(wordcourseid, restart, remember) {

    $(".wordcontentload").load("/ajax/studyword.do", {wordcourseid:wordcourseid,restart:restart,remember:remember});
    tb_remove();
}
function onclickrember(wordsid) {
    $(".wordcontent").load("/ajax/remberword.do", {wordsid:wordsid})
}
function onclickforget(wordsid) {
    $(".wordcontent").load("/ajax/forgetword.do", {wordsid:wordsid})
}

function loadmemo() {
    $("#li1").removeClass("active");
    $("#li2").removeClass("active");
    $("#li3").addClass("active");
    $(".wordcontentload").load("/ajax/loadmemo.do");
}
function loadrecord() {
    // $("#li2").css("background","url( '/images/33.gif' ) no-repeat");
    $("#li1").removeClass("active");
    $("#li3").removeClass("active");
    $("#li2").addClass("active");
    $(".wordcontentload").load("/ajax/loadrecord.do");
}
function loadtheory(curpage) {
    $(".wordcontentload").html("");
    $(".wordcontentload").load("/ajax/knowtheory.do?curpage=" + curpage);
}
function selectradio() {
    // alert("***");
    $("#custom").attr("checked", "true");
}
function sayHelo(receiverid, replyid) {


    var hellotype = $("input[@type=radio][@checked]").val();
    var content1 = $("#content1").val();
    if (hellotype == 0 && content1 == ("")) {
        alert('自定义内容不能为空');
        return false;
    }
    $.post("/ajax/sayhello.do", {receiverid:receiverid,replyid:replyid,hellotype:hellotype,content1:content1},
            function(json) {
                tb_show('打招呼', '/ajax/sayhellosuc.jsp?height=250&width=400&modal=true', '');
                window.setTimeout(tb_remove, '3000');
                if (replyid != '' && replyid != '0') {
                    $("#reply_" + replyid).html("已回复 ");
                }
            });


}


function submitPractice(practiceId) {
    var content = $('#practiceContent').val();
    $.post("/ajax/addExercise.do", {practiceId:practiceId,content:content},
            function(json) {
                json = eval("(" + json + ")");
                var result = json.result;
                if (result == 1) {
                    tb_show('Invite friends to review', '/ajax/sendPracticeMail.do?height=500&width=500&modal=true&practiceId=' + practiceId, '');
                } else {
                    $("#errMsg").html(json.msg);
                }

            });
}

function sendPracticeMail(practiceId) {
    var sendTo = $("#sendTo").val();
    var subject = $("#subject").val();
    var message = document.getElementById("message1").value;
    var uids = "";
    $("input[@name=friendName]").each(function() {
        if ($(this).attr("checked") == true) {
            uids += $(this).val();
            uids += ',';
        }
    });
    $.post("/ajax/sendPracticeMail.do", {practiceId:practiceId,act:'send',sendTo:sendTo,subject:subject,message:message,uids:uids},
            function(json) {
                json = eval("(" + json + ")");
                var result = json.result;
                if (result == 1) {
                    //tb_remove();
                    tb_show('Invite friends to review', '/ajax/sendPracticeMail.do?height=380&width=400&modal=true&practiceId=' + practiceId + "&act=succ", '');
                    //                    window.location.replace(json.toUrl);
                } else {
                    $("#warnMsg").html(json.msg);
                }
            });
}


function sendUpdateMessage(faceId) {
    $.post("/ajax/sendUpdateMessage.do", {faceId:faceId},
            function(json) {
                json = eval("(" + json + ")");
                var result = json.status;
                if (result == 1) {
                    $("#myCheckBox").html(json.msg);
                } else {

                }
            });
}

function editTeacherFormAlert() {
    if ($("#nick_name").val() == ("")) {
        alert('nick_name is Required');
        return false;
    }
    if ($("#first_name").val() == ("")) {
        alert('first_name is Required');
        return false;
    }
    if ($("#last_name").val() == ("")) {
        alert('last_name is Required');
        return false;
    }
    if ($("#mobile").val() == ("") && $("#phone").val() == ("")) {
        alert('Either mobile or phone is required！');
        return false;
    }
    if ($("#from_country").val() == 0) {
        alert('country is required');
        return false;
    }
    if ($("#provinceId").val() == 0) {
        alert('the province you are living in is required');
        return false;
    }
    if ($("#city").val() == 0) {
        alert('the city you are living in is required');
        return false;
    }

}
function viewTip(tipId) {
    $.post("/ajax/changeTip.do", {tipId:tipId}, function(json) {
        var json = eval("(" + json + ")");
        if (json.result == '1') {
            $("#mytip").css("display", "none");
        }
    });
}
function getHomeLeft(kind) {
    if (kind != 'all') {
        $("#myhomeLeft").load("/ajax/homeLeft.do", {kind:kind});
    }
    else
    {
        $("#myhomeLeft").load("/ajax/homeLeft.do");
    }
}
//修改语言
function showlevel(language, type) {
    if (type == 1) {
        $("span.learnedit" + language).hide();
        $("div.learn" + language).show();
    } else {
        $("span.speakedit" + language).hide();
        $("div.speak" + language).show();
    }
}
function hidelevel(language, type) {
    if (type == 1) {
        $("span.learnedit" + language).show();
        $("div.learn" + language).hide();
    } else {
        $("span.speakedit" + language).show();
        $("div.speak" + language).hide();
    }
}
function showaddLanguageForm(type) {
    if (type == 1) {
        $("#addlearn").hide();
        $(".learnform").show();
    } else {
        $("#addspeak").hide();
        $(".speakform").show();
    }
}
function hideaddLanguageForm(type) {
    if (type == 1) {
        $("#addlearn").show();
        $(".learnform").hide();
    } else {
        $("#addspeak").show();
        $(".speakform").hide();
    }
}
function deletePractice(id) {
    confirm("你确定要删除这个练习吗？", function() {
        window.location = "/admin/managePractice.do?act=delete&id=" + id;
    });
}
function deleteFace(type, faceId, rank) {
    confirm("确实要删除该课程吗？", function() {
        if (rank == 1) {
            window.location = "/leader/admin/manageFace.do?action=delete&type=" + type + "&fid=" + faceId;
        }
        if (rank == 2) {
            window.location = "/admin/manageFace.do?action=delete&type=" + type + "&fid=" + faceId;
        }
    });
}
function relive(status, ufid, url, faceId, rank) {
    confirm("确实要为该会员取消资格吗？", function() {
        $.post("/ajax/leaderprocess.do",{status:status,ufid:ufid,url:url,faceId:faceId},function(data){
             if(data==1){
                  $("#userface_"+ufid).fadeOut(500);
             }else if(data==-3){
                alert("本级别已达到取消次数上限，不能取消了。");
            }else{
                 alert(data);
                alert("出现错误，取消失败，记住用户名和所报名课程，请联系技术部。");
            }
        });
    });

}
function materialIsUrl() {
    var argvalue = $("#link").val();
    if (argvalue.indexOf(" ") != -1)
    {
        alert("Spaces not allowed!");
        return false;
    }
    else if (argvalue.indexOf("http://") == -1)
    {
        alert(" must begin with a http://");
        return false;
    }
    else if (argvalue == "http://")
        {
            alert("Please enter complete  urlname !");
            return false;
        }

    argvalue = argvalue.substring(7, argvalue.length);
    if (argvalue.indexOf(".") == -1)
    {
        alert("Please enter an extension like .com, .edu(etc) for  urlname !");
        return false;
    }
    else if (argvalue.indexOf(".") == 0)
    {
        alert("Please enter correct  urlname!");
        return false;
    }
    else if (argvalue.charAt(argvalue.length - 1) == ".")
        {
            alert("Please enter an extension after . like com, edu(etc) for  urlname !");
            return false;
        }

    if (argvalue.indexOf("/") != -1)
    {
        argvalue = argvalue.substring(0, argvalue.indexOf("/"));
        if (argvalue.charAt(argvalue.length - 1) == ".")
        {
            alert("Please enter correct  urlname !");
            return false;
        }
    }

    if (argvalue.indexOf(":") != -1)
    {
        if (argvalue.indexOf(":") == (argvalue.length - 1))
        {
            alert("Please enter correct  urlname !");
            return false;
        }
        else if (argvalue.charAt(argvalue.indexOf(":") + 1) == ".")
        {
            alert("Please enter correct  urlname !");
            return false;
        }
        argvalue = argvalue.substring(0, argvalue.indexOf(":"));
        if (argvalue.charAt(argvalue.length - 1) == ".")
        {
            alert("Please enter correct urlname !");
            return false;
        }
    }
    return true;
}
function deleteMaterial(id, rank) {
    confirm("确实要删除这个资料吗？", function() {
        if (rank == 1) {
            window.location = "/leader/admin/manageMaterial.do?action=delete&mid=" + id;
        }
        if (rank == 2) {
            //                alert("rank");
            window.location = "/leader/admin/manageMaterial.do?action=delete&mid=" + id;
        }
    });


}
function saveMyself(faceId, userFaceId) {
    $("#myform").attr('action', '/club/refresher.do?faceId=' + faceId + '&userFaceId=' + userFaceId + '&type=saveAnswer');
    $("#myform").submit();
}
function hideC() {
    $('#TB_window').fadeOut("fast", function() {
        $('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();
    });
}
function changeCode(type, commentId) {
    var rand = Math.round(Math.random() * 10000);
    if (type == 1) {
        document.getElementById("validateCode_img").src = '/validateCode?r=' + rand;
    } else if (type == 2) {
        document.getElementById("validateCodePost" + commentId).src = '/postVaCode?r=' + rand;
    }
}
function showDown(divId) {
    $("#" + divId).show();
}
function hideDown(divId) {
    $("#" + divId).hide();
}

function showHot(type, temp) {
    if (temp == 1) {
        $("#hotv").hide();
        $("#hott").hide();
        $("#hotp").hide();
        $(".v").css("background", "none");
        $(".v").css("color", "#000");
        $(".t").css("background", "none");
        $(".t").css("color", "#000");
        $(".p").css("background", "none");
        $(".p").css("color", "#000");
        $("#hot" + type).show();
        $("." + type).css("background", "transparent url(../../static/css/zh_CN/img/moduleBg.gif) repeat-x 0 0");
        $("." + type).css("color", "#003399");
    } else if (temp == 2) {
        $("#welcomItem").hide();
        $("#studyItem").hide();
        $("#tenItem").hide();
        $("#courseItem").hide();
        $(".welcom").css("background", "none");
        $(".welcom").css("color", "#000");
        $(".study").css("background", "none");
        $(".study").css("color", "#000");
        $(".ten").css("background", "none");
        $(".ten").css("color", "#000");
        $(".course").css("background", "none");
        $(".course").css("color", "#000");
        $("#" + type + "Item").show();
        $("." + type).css("background", "transparent url(../../static/css/zh_CN/img/moduleBg.gif) repeat-x 0 0");
        $("." + type).css("color", "#003399");
    }
}
function openVideoLecIn() {
    var videoLectIn = document.getElementById("videoLectIn");
    var videoimg = document.getElementById("videoLecImg");
    if (videoLectIn.style.display == 'none') {
        $("#videoLectIn").show();
        $("#videoLecTit").html("隐藏视频教室介绍")
        videoimg.src = "/images/minus.gif";
    } else {
        $("#videoLecTit").html("什么是视频教室")
        $("#videoLectIn").hide();
        videoimg.src = "/images/plus.gif";

    }
}
function deleteVideoClass(videoClassId, rank) {
    confirm("确实要删除该记录吗?", function() {
        if (rank == 1) {
            window.location = "/leader/admin/manageVideoClass.do?action=delete&" + "vcId=" + videoClassId;
        }
        if (rank == 2) {
            window.location = "/admin/manageVideoClass.do?action=delete&" + "vcId=" + videoClassId;
        }

    });
}

function showDetail(type) {
    $("#myhomeLeft").hide();
    $("#infoDet").hide();
    $("#myActivity").hide();
    $("#" + type).show();
    $("#myhomeLeft1").removeClass("active");
    $("#infoDet1").removeClass("active");
    $("#myActivity1").removeClass("active");

    $("#" + type + "1").addClass("active");

}
function entry(nickName,lessonId){
   ent(nickName,lessonId,0);
}
function ent(nickName,lessonId,classId) {

    var ConfDirPath;
    var app = navigator.appName;
    if (app.indexOf("Microsoft")) {
        alert("请选用IE浏览器!");
        return false;
    }
    if (nickName == "") {
        alert("对不起，您还未<a href='/clubloginForm.do' style='font-weight:bold;color:#FF0000;'>登录</a>或<a href='/clubloginForm.do' style='font-weight:bold;color:#FF0000;'>注册</a>");
        return false;
    }

    try {

        ConfDirPath = testocx.GetRegKeyStringValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\开心英语视频教室", "InstallPath");


    } catch(err) {
        alert("<h3 style='line-height:1.2'>您还没有下载安装视频客户端软件，请点击 <a href='/vcr/downloadClient.do' style='font-weight:bold;color:#FF0000;font-size:large;text-decoration:underline;'>这里</a> 下载。或者您的浏览器阻止了客户端的运行，您可以阅读<a href='/club/clubFoot.do?url=allHelp&step=15' style='font-weight:bold;color:#FF0000;font-size:large;text-decoration:underline;'>常见问题</a>。来解决您遇到的问题</h3>");
        return false;
    }

    if (ConfDirPath == "") {
        ConfDirPath = testocx.GetRegKeyStringValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\kaixinABC Video Classroom", "InstallPath");
    }
    if (ConfDirPath == "") {
        ConfDirPath = "c:\\program files\\开心英语视频教室";
    }
    ConfDir = ConfDirPath + '\\videomeet.exe';

    if (ConfDirPath == "")
    {
        alert("<h3 style='line-height:1.2'>您还没有下载安装视频客户端软件，请点击 <a href='/vcr/downloadClient.do' style='font-weight:bold;color:#FF0000;font-size:large;text-decoration:underline;'>这里</a> 下载" +
              "</h3>");
    }
        confpara = "-h " + "210.83.81.130" + " -P " + "1810" + " -u -1" + " -p '$" + "' -n '$" + nickName + "' -c " + 188 + " -k '$" + "" + "'";
        testocx.RunExe(ConfDir, confpara, ConfDirPath, 1);

}


function entrychat(nickName, lessonId) {
    var ConfDirPath;
    var app = navigator.appName;
    if (app.indexOf("Microsoft")) {
        alert("请选用IE浏览器!");
        return false;
    }
    if (nickName == "") {
        alert("对不起，您还未<a href='/clubloginForm.do' style='font-weight:bold;color:#FF0000;'>登录</a>或<a href='/clubloginForm.do' style='font-weight:bold;color:#FF0000;'>注册</a>");
        return false;
    }

    try {

        ConfDirPath = testocx.GetRegKeyStringValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\开心英语视频教室", "InstallPath");
        //         alert("df");

    } catch(err) {
        alert("<h3 style='line-height:1.2'>您还没有下载安装视频客户端软件，请点击 <a href='/vcr/downloadClient.do' style='font-weight:bold;color:#FF0000;font-size:large;text-decoration:underline;'>这里</a> 下载。或者您的浏览器阻止了客户端的运行，您可以阅读<a href='/club/clubFoot.do?url=allHelp&step=15' style='font-weight:bold;color:#FF0000;font-size:large;text-decoration:underline;'>常见问题</a>。来解决您遇到的问题</h3>");
        return false;
    }

    if (ConfDirPath == "") {
        ConfDirPath = testocx.GetRegKeyStringValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\kaixinABC Video Classroom", "InstallPath");
    }
    if (ConfDirPath == "") {
        ConfDirPath = "c:\\program files\\开心英语视频教室";
    }
    ConfDir = ConfDirPath + '\\videomeet.exe';

    if (ConfDirPath == "")
    {
        alert("<h3 style='line-height:1.2'>您还没有下载安装视频客户端软件，请点击 <a href='/vcr/downloadClient.do' style='font-weight:bold;color:#FF0000;font-size:large;text-decoration:underline;'>这里</a> 下载" +
              "</h3>");
    }

       $.post("/addVideoChatChannelUser.do", {lessonId:lessonId});
        confpara = "-h " + "210.83.81.130" + " -P " + "1810" + " -u -1" + " -p '$" + "' -n '$" + nickName + "' -c " + 188 + " -k '$" + "" + "'";
        testocx.RunExe(ConfDir, confpara, ConfDirPath, 1);
}
//function Agent_load_error()
//{
//    alert("您还没有下载客户端软件，请点击右上角链接下载客户端软件。");
//    return false;
//}
function joinVideoClass(lessonId, userId, price) {
    confirm("确定要报名参加该课程吗？" + "确认后系统从你的帐户中扣除" + price + "个学币，转入开心英语帐户。上完课之后确认支付，系统会把该数量学币转入老师帐户。", function() {
        $.post("/ajax/joinVideoClass.do", {lessonId:lessonId,userId:userId}, function(json) {
            json = eval("(" + json + ")");
            if (json.result == "0") {
                $("#joinInfor" + lessonId).html("您已经报过名了！");
            } else if (json.result == "2") {
                $("#error" + lessonId).show();
                //              $("#joinInfor" + lessonId).html("<div style='color:red;'>您的学币不足,不能参加本次面授课。<a href='/invite.do' style = 'text-decoration:underline;color:red;'>邀请好友</a>可赚取1学币！</div>");
            } else if (json.result == "5") {
                $("#joinInfor" + lessonId).html("<div style='color:red;'>该课程人数已满！您可以参加其它课程！</div>");
            }
            else {
                $("#joinInfor" + lessonId).html("报名成功！");
            }
        });

    });
}
function payForVideoLesson(userId, lessonId, userVideoLessonId) {
    tb_show("支付", "/ajax/payVideoLessonForm.do?width=300&height=250&userVideoLessonId=" + userVideoLessonId, "");
}
function adminEntry(){
   adEn(0);
}
function adEn(classId)
{
    var app = navigator.appName;
    if (app.indexOf("Microsoft")) {
        alert("请选用IE浏览器!");
        return false;
    }
    try {
        ConfDirPath = testocx.GetRegKeyStringValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\开心英语视频教室", "InstallPath");
    } catch(err) {
        alert("<h3 style='line-height:1.2'>您还没有下载安装视频客户端软件，请点击 <a href='/vcr/downloadClient.do' style='font-weight:bold;color:#FF6600;font-size:large;'>这里</a> 下载</h3>");
        return false;
    }
    if (ConfDirPath == "") {
        ConfDirPath = testocx.GetRegKeyStringValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\kaixinABC Video Classroom", "InstallPath");
    }
    ConfDir = ConfDirPath + '\\videomeet.exe';
    if (ConfDirPath == "")
    {
        alert("<h3 style='line-height:1.2'>您还没有下载安装视频客户端软件，请点击 <a href='/vcr/downloadClient.do' style='font-weight:bold;color:#FF6600;font-size:large;'>这里</a> 下载</h3>");
        return false;
    }
    else
    {
        confpara = "-h " + "210.83.81.130" + " -P " + "1810" + " -u " + "91010989600" + " -p '$" + "1" + "' -n '$" + "91010989600" + "' -c " + 188 + " -k '$" + "" + "'";
        testocx.RunExe(ConfDir, confpara, ConfDirPath, 1);
         $.post("/ajax/addClassFeed.do", {classId:classId});
    }
}
function showmgw(divId) {
    $("#mm").hide();
    $("#gg").hide();
    $("#ww").hide();
    $(".mm").removeClass('mmactive');
    $(".gg").removeClass('ggactive');
    $(".ww").removeClass('wwactive');
    $("." + divId).addClass(divId + 'active');
    $("#" + divId).show();
}
var activex = ((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('MSIE') != -1) && (parseInt(navigator.appVersion) >= 4 ));
var CantDetect = ((navigator.userAgent.indexOf('Safari') != -1) || (navigator.userAgent.indexOf('Opera') != -1));
if (typeof(detected) == "undefined" && activex) {
    document.write(
            ['<script language="VBscript">',
                'Function isSkypeInstalled()',
                'on error resume next',
                'Set oSkype = CreateObject("Skype.Detection")',
                'isSkypeInstalled = IsObject(oSkype)',
                'Set oSkype = nothing',
                'End Function',
                '<\/script>'].join("\n")
            );
}
function oopsPopup() {
    var windowName = "oops";
    var URLtoOpen = "http://download.skype.tom.com/Tom-SkypeSetup.exe";

    oopswindow = window.open(URLtoOpen, windowName);
    return false;
}

function skypeCheck() {
    if (CantDetect) {
        return true;
    } else if (!activex) {
        var skypeMime = navigator.mimeTypes["application/x-skype"];
        detected = true;
        if (typeof(skypeMime) == "object") {
            return true;
        } else {
            return oopsPopup();
        }
    } else {
        if (isSkypeInstalled()) {
            detected = true;
            return true;
        }
    }

    detected = true;
    return oopsPopup();
}
function chat(uid, pid, language) {
    if (skypeCheck()) {
        $.post("/ajax/chatNewsFeed.do", {uid:uid,pid:pid,language:language});
        return true;
    }
    else {
        return false;
    }
}
function exitChatPartner(partnerid) {
    confirm("您确实要退出一对一练口语吗？", function() {
        window.location.href = "/chat/exitPartnerPlat.do?pid=" + partnerid;
    });

}
function showAboutMe(divId, temp) {
    if (temp) {
        $("#" + divId + "Img").show();
        $("#" + divId).show();
    } else {
        $("#" + divId).hide();
        $("#" + divId + "Img").hide();
    }
    //    var absoultTop=aObject.css('top');
    //    var absoultLeft=aObject.css('left');
    //    var imgObject=$("#hiddenImg");
    //    imgObject.css("top",(absoultTop+50)+'px') ;
    //    imgObject.css("left",(absoultLeft+1)+'px') ;
}
function hiddenAboutMe(divId) {
    var aObject = $("#" + divId)
    aObject.fadeOut();
}
function getCurrentStyle(obj, cssproperty, csspropertyNS) {
    if (obj.style[cssproperty]) {
        return obj.style[cssproperty];
    }
    if (obj.currentStyle) {// IE5+
        return obj.currentStyle[cssproperty];
    } else if (document.defaultView.getComputedStyle(obj, null)) {// FF/Mozilla
        var currentStyle = document.defaultView.getComputedStyle(obj, null);
        var value = currentStyle.getPropertyValue(csspropertyNS);
        if (!value) {//try this method
            value = currentStyle[cssproperty];
        }
        return value;
    } else if (window.getComputedStyle) {// NS6+
        var currentStyle = window.getComputedStyle(obj, "");
        return currentStyle.getPropertyValue(csspropertyNS);
    }
}
function addPerson(roomNumber) {
    if (skypeCheck()) {
        $.post("/chatRoom/addChatPerson.do", {roomNumber:roomNumber});
        return true;
    } else {
        return false;
    }
}
function changSrc(pid) {
    var img = document.getElementById("skype" + pid);
    img.src = "/imgs/chat/skypeme_on.gif";
}
function recoverSrc(pid) {
    var img = document.getElementById("skype" + pid);
    img.src = "/imgs/chat/skypeme_normal.gif";
}
function addkfPost(commentId, isLogin) {
    if (! isLogin) {
        window.location = "/clubloginForm.do";
    }
    var content = $('#postCommentC').val();
    $.post("/ajax/addPost.do", { commentId:commentId,content:content},
            function(json) {
                json = eval("(" + json + ")");
                var result = json.result;
                if (result == 1) {
                    $("#postComment" + commentId).load("/ajax/postComListkf.do", {commentId:commentId});
                    var textCon = document.getElementById("postCommentC");
                    textCon.value = "";
                } else {
                    $("#error").html(json.msg);
                }
            }
            );

}

function loadPostComment(commentId) {
    if ($("#postComment" + commentId).css("display") == "none") {
        $("#a" + commentId).text("收起回复")
        $("#postComment" + commentId).css("display", "block");
        $("#postComment" + commentId).load("/ajax/postComListkf.do", {commentId:commentId});
    } else {
        $("#a" + commentId).text("展开回复")
        $("#postComment" + commentId).css("display", "none");
    }
}
function loadKFcomment(type, ai) {
    $("#needLiu").hide();
    $("#needJian").hide();
    $('#commentL').show();

    $("#comment1").removeClass('active');
    $("#comment2").removeClass('active');
    $("#comment3").removeClass('active');
    $("#comment4").removeClass('active');
    $("#comment" + ai).addClass('active')
    if (type == 1) {
        $('#commentL').load('/ajax/kfComList.do')
    } else {
        $('#commentL').load('/ajax/kfComList.do?listType=ones')
    }

}
function setCookie(name, value)//两个参数，一个是cookie的名子，一个是值
{
    $('#mail').hide();
    var Days = 1; //此 cookie 将被保存 30 天
    var exp = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
    document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)//取cookies函数
{
    var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
    if (arr != null)
        return unescape(arr[2]);
    return null;
}
function changebackground(divid, type, imgsrc1, imgsrc2) {
    if (type == 0) {
        var imgsrc = '/images/chat/' + imgsrc1;
        $("#" + divid).css("background", " url(" + imgsrc + " ) no-repeat");

    } else {
        var imgsrc = '/images/chat/' + imgsrc2;
        $("#" + divid).css("background", " url(" + imgsrc + ") no-repeat");
    }
}
function onli(classname, type) {
    if (type == 0) {
        $("." + classname + ">a").css('color', 'red');
        $("." + classname + ">img").attr('src', '/images/chat/1.png');
        $("." + classname).css("background", " url( '/images/chat/2.gif' ) ");
    } else {
        $("." + classname + ">a").css('color', '#999999');
        $("." + classname + ">img").attr('src', '/images/chat/2.png');
        $("." + classname).css("background", " url( '' ) ");
    }
}


function getspeaksum(cssid, service, userid) {
    $.getScript(service + "/ajax/chatjs.do?userid=" + userid, function() {
        if (sum == 0) {
        } else {
            $("#" + cssid).html(sum);
        }
    })
}

function setfans(mid, uid, divcss) {
    $.post("/becomefans.do", {mid:mid,uid:uid});
    $("#" + divcss).addClass("fansed")
    $("#" + divcss).html("已成为粉丝");
    $("#" + divcss).attr('onclick', 'javascript:void(0);');
    $("#" + divcss).attr('onmouseover()', '');
}
function writeMsn() {
    tb_show('添加MSN机器人', '/ajax/writeMsn.jsp?height=250&width=400&modal=false');
}
function kaiTong(price, videoClassId) {
    $.post("/ajax/isAddClass.do", {videoClassId:videoClassId}, function(json) {
        json = eval("(" + json + ")");
        var result = json.result;
        if (result == 1) {
            alert("您还未<a href='/kxIndex.do' target='_blank'>注册</a>或者<a href='/clubloginForm.do'target='_blank'>登录</a>网站！");
        } else if (result == 2) {
            alert("你已经添加了此课程，请选择其他课程！");
        } else if(result==3){
             alert("余额不足！请去<a href='/paygold.do?next=form'target='_blank'>充值</a>！");
        } else {
                confirm("您需要支付" + price + "学币开通本课程。确定开通本课程?", function() {
                    window.location.href = "/video/addUserVideoClass.do?price=" + price + "&videoClassId=" + videoClassId;
                });
            }

    });

}

 