﻿//select excute function
var SelectFun = function (inType) {
    switch (inType) {
        case "10":
            // singUp
            //setTimeout(SingUp, 1000);
            SingUp();
            break;
        case "20":
            // SingUp
            setTimeout(SingUpSucceed, 1000);
            break;
        case "RetPassWord":
            // SingUp
            //setTimeout(SingUpSucceed, 1000);
            //break;
        case "verifyEmail":
            //TipMessageAttestation();
        default:
            break;
    }
}

//$('input=[]').mousedown(function () {
//    alert('按下了鼠标 !');
//});
/**begin Base js**/
$(document).ready(function () {
    $(".small-btn").click(function () {
        if ($(this).next().is(":visible")) {
            $(this).next(".menu_down_box").hide();
        } else {
            $(this).next(".menu_down_box").show();
        }
    });
});

var cancleEnter2 = function (event) {
    if (event.keyCode == 13) {
        //event.keyCode=0; 
        if (_IsIE2() == false) {
            event.preventDefault();
        }
        else {
            event.returnValue = false;
        }
    }
}

var _IsIE2 = function () {
    var browser = navigator.appName;
    if (browser == "Microsoft Internet Explorer") {
        return true;
    }
    else {
        return false;
    }
}
/**end js**/

/*Begin /Account/RetrievePassWord*/
//page js
function RetievePwd() {
    if (ValidateRetrievePwd() == false) return;
    var selValue = $("#selRecover option:selected").val();
    var txtEmail = $("#txtUserEmail").val();
    if (selValue == 10) {
        $.ajax({
            type: "POST",
            url: "/AjaxService/RetPassWord",
            data: "userEmail=" + txtEmail,
            dataType: 'json',
            success: function (data) {
                if (data.success) {
                    TipMessageRetrievePassWord();
                } else {
                    TipMessage(window.EmialError);
                }
            },
            error: function (e) {
                TipMessage(window.EmialError);
                //window.location.href = "/Home/Index/13928"; 
            },
            beforeSend: function (e) {
                tipsWindownBuffer('450', '', '', 'RetPassWord');
            }
        });
    }
    else {
        $.ajax({
            type: "POST",
            url: "/AjaxService/GetSaftyQuestion",
            data: "userEmail=" + txtEmail,
            dataType: 'json',
            success: function (data) {
                if (data.success) {
                    SaftyQuestion(data.safeQueId, data.safeQueName, txtEmail);
                } else {
                    TipMessage(window.EmialOrSafeQueError);
                }
            },
            error: function (e) {
                TipMessage(window.EmialOrSafeQueError);
                //window.location.href = "/Home/Index/13928"; 
            }
        });

    }
}
//ui block
function SaftyQuestion(_safeQueId, _safeQueName, txtEmail) {
    var _content1 = $("#div_SaftyQuestionContent").clone(); //tempalte from Account/RetrievePassWord
    $("#login_xl_input", _content1).html(_safeQueName);
    tipsWindown(window.retrieveTooltip, "", "470", "", "true", "", "true");
    $("#windown-content").html($(_content1).html());
    $("#login_xl_input").html(_safeQueName);
    $("#profinal_big_btn_blue").html(window.password_save);
    $("#profinal_big_btn_blue").click(function () {
        var _SaftyQuestio = $(".windown-content-class .txtSaftyQuestio").val();
        if (ValidateRetrievePwdSafeQue() == false) return;

        $.ajax({
            type: "POST",
            url: "/AjaxService/SaftyQuestionRelPwd",
            data: "safeQueId=" + _safeQueId + " &SaftyQuestion=" + _SaftyQuestio + "&userEmail=" + txtEmail,
            dataType: 'json',
            success: function (data) {
                if (data.success) {
                    window.location.href = "/Account/ChangePassword?Emial=" + txtEmail + "&ValidateCode=" + data.ValidateCode;
                } else {
                    TipMessage(safeQueError);
                }
            },
            error: function (e) {
                TipMessage(safeQueError);
                //window.location.href = "/Home/Index/13928";
            }
        });
    });
}
/*End /Account/RetrievePassWord*/

/*Begin sign up*/
// page js
//---登录 begin----
function LogOn() {
    if (ValidateLogin() == false) return;
    var _txtUserEmail = $("#txtUserEmail").val();
    var _txtPwd = $("#txtPwd").val();
    var _Remember = $("#checkbox").attr("checked");
    $.ajax({
        type: "POST",
        url: "/AjaxService/LogOn",
        data: "nameOrEmail=" + _txtUserEmail + "&Pwd=" + _txtPwd + "&Remember=" + _Remember,
        dataType: 'json',
        success: function (data) {
            if (data.success) {
                if (data.url == "") {
                    var _returnUrl = $.cookie("returnUrl");
                    if (_returnUrl == null || _returnUrl.length < 1) {
                        _returnUrl = "/Personal/Home";
                    }
                    else { $.cookie("returnUrl", null, { path: '/' }) }
                    window.location.href = _returnUrl;
                } else {
                    window.location.href = data.url;
                }
            } else {
                TipMessage(EmailOrNameOrPwdError);
            }
        },
        error: function (e) {
            TipMessage(EmailOrNameOrPwdError);
        }
    });

}
//---end----
function submit_Log(event) {
    event = event || window.event;
    if (event.keyCode == 13) {
        var _txtUserMail = $.trim($("#txtUserEmail").val());
        var _txtPassword = $.trim($("#txtPwd").val());
        if (_txtUserMail.length > 0 && _txtPassword.length > 0) {
            $("#LogOn").click();
        }
        else {
            cancleEnter2(event);
        }
    }
}
$(document).ready(function () {
    //----学习理念 begin ----
    $(".index_btn_vdo").hover(function () {
        $(".vdo_list_box").css("display", "");
    }, function () {
        $(".vdo_list_box").css("display", "none");
    });
    //---end----

    //----登录框隐藏显示 begin ----
    $("#log_btn_bg").click(function () {
        if ($(this).parent().next(".login_list_box").is(":visible")) {
            $("#log_btn").removeClass("log_btn_bg_a");
            $("#log_btn").addClass("log_btn_bg");
            $(this).parent().next(".login_list_box").hide();
        }
        else {
            $("#log_btn").removeClass("log_btn_bg");
            $("#log_btn").addClass("log_btn_bg_a");
            $(this).parent().next(".login_list_box").show();
        }
    });

    $("#button2").click(function () {
        if ($("#log_btn").hasClass("log_btn_bg_a")) {
            $("#log_btn").removeClass("log_btn_bg_a");
            $("#log_btn").addClass("log_btn_bg");
            $(".login_list_box").css("display", "none");
        }
    });
    //---end----

    //----学习语言 begin ----
    $("#LearninLan").click(function () {
        $("#windown-box-two").css("display", "");
    });

    $("#windclose").click(function () {
        $("#windown-box-two").css("display", "none");
    });

    $(".profinal_big_btn_g-two").click(function () {
        $("#windown-box-two").css("display", "none");
    });
    $(".close-Div").click(function () {
        $("#windown-box-two").css("display", "none");
    });
    //---end----
    //----begin----
    $(".index_btn_vdo").click(function () {
        $("#windown-box-three").css("display", "");
        _flow();
    });
    $("#windclose2").click(function () {
        $("#windown-box-three").css("display", "none");
        $("#player").html("");
    });

    $(".profinal_big_btn_g-three").click(function () {
        $("#windown-box-three").css("display", "none");
        $("#player").html("");
    });
    //----end------
});
//ui block
function SingUp(_Code) {
    var _InvationCode = '';
    SignUpFun(_InvationCode);
    return false;
    if (typeof _Code != "undefined" && _Code.length > 0) {
        _InvationCode = _Code;
    }
    else {
        _InvationCode = $.trim(window.InvitationCodeNo);
    }

    $.ajax({
        type: "POST",
        url: "/_WebSvc/wsInvitationCode.asmx/CheckInvitationCodeExist",
        data: "InvitationCode=" + _InvationCode,
        dataType: 'text',
        success: function (data) {
            if (data.indexOf("True") > -1) {
                SignUpFun(_InvationCode);
            }
            else {
                InvitationCodeValidate();
            }
        },
        error: function (e) {
            alert(e);
            //window.location.href = "/Home/Index/13928";
            return false;
        }
    });
}
function SignUpFun(_CardNo) {
    var _content1 = $("#SignUpContent").clone();  //tempalte from home/index
    tipsWindown(window.SignUpBlockTitle, "", "470", "", "true", "", "true");
    $("#windown-content").html(_content1.html());
    $("#profinal_big_btn_blue").html(window.SignUpBoton);
    $("#windown-content-font").css("display", "");
    $("#windown-box").css("top", "200px");
    $("#profinal_big_btn_blue").click(function () {
        SingUpSubmit(_CardNo);
    });
    var _src = $.trim($(".windown-content-class .validimg").prev().val());
    $(".windown-content-class .validimg").click(function () {
        $(".windown-content-class .validimg").attr('src', _src + "?" + Math.random());
    });
    $(".windown-content-class .validimg").attr('src', _src + "?" + Math.random());
}
function SingUpSubmit(_Code) {
    if (ValidateSingUp() == false) return;
    var _txtSignUpEamil = $(".windown-content-class .txtSignUpEamil").val();
    var _txtSignUpPwd = $(".windown-content-class .txtSignUpPwd").val();
    var _txtSignUpPwdConfirmation = $(".windown-content-class .txtSignUpPwdConfirmation").val();
    var _txtSignUpValidateCode = $(".windown-content-class .txtSignUpValidateCode").val();
    var InvitationCodeNo = (typeof _Code != "undefined" && _Code.length > 3) ? _Code : "";
    $.ajax({
        type: "POST",
        url: "/AjaxService/SingUP",
        data: "UserEmail=" + _txtSignUpEamil + "&Pwd=" + _txtSignUpPwd + "&InvitationCodeNo=" + InvitationCodeNo,
        dataType: 'json',
        success: function (data) {
            if (data.success) {
                tipsWindownBuffer("450", "", "", "20");
            } else {
                $(".tipsSignUpError").css("display", "");
                $(".tipsSignUpError").html(data.Mes);
            }
        },
        error: function (e) {
            alert(e);
            //window.location.href = "/Home/Index/13928";
        }
    });

}

function SingUpSucceed() {
    var _content1 = $("#SignUpSuccessTipsContent").html();
    tipsWindown(window.TooltipTitleTips, "", "470", "", "true", "", "true");
    $("#windown-content").html(_content1);
    $("#profinal_big_btn_blue").html(window.SignIn);
    $("#profinal_big_btn_blue").click(function () {
        window.location.href = "/Account/GuideStep1";
    });
}
/*End sign up*/

/*Begin Partners/NativeSpeakers*/
//page js
$(document).ready(function () {
    $(".wrap_content").click(function () {
        //$(".menu_down_box").hide();
    });
});

function ApplyFriendOperate(freindId) {
    if (freindId > 0) {
        $.ajax({
            type: "POST",
            url: "/AjaxService/ApplyFriendOperate",
            data: "FriendId=" + freindId,
            dataType: 'json',
            success: function (data) {
                if (data.success) {
                    TipMessageRefresh(window.OperateSucceed);
                } else {
                    TipMessage(window.OperateFailure);
                }
            },
            error: function (e) {
                TipMessage(window.OperateFailure);
            }
        });
    } else {
        TipMessage(window.OperateFailure);
    }
}
//ui block
//begin set search config
function SearchDefaultConfig() {
    var _content1 = $("#SearchDefaultConfigContent").clone();
    tipsWindown(window.FilterTooltipTitle, "", "470", "", "true", "", "true");
    $("#windown-content").html(_content1.html());
    $("#profinal_big_btn_blue").html(window.saveBotton);
    $("#profinal_big_btn_blue").click(function () {
        var defaultLanId = selectDefaultNativeLanId();
        var onlineStatusId = selectDefaultOnlineStatusId();
        var studyLanIds = selectStudyLanIds();
        $.ajax({
            type: "POST",
            url: "/AjaxService/UpdateUserSearchConfig",
            data: "defaultLanId=" + escape(defaultLanId) + "&onlineStatusId=" + escape(onlineStatusId) + "&studyLanIds=" + escape(studyLanIds),
            dataType: 'json',
            success: function (data) {
                if (data.success) {
                    TipMessageRefresh(window.OperateSucceed);
                } else {
                    TipMessage(window.OperateFailure);
                }
            },
            error: function (e) {
                alert(e);
                //window.location.href = "/Home/Index/13928";
            }
        });
    });
}
var selectDefaultNativeLanId = function () {
    var id = "";
    $(".windown-content-class select[name^='selectFriendNativeLan'] option").each(function () {
        if ($(this).attr("selected") == true) {
            id = $.trim($(this).val());
        }
    });
    return id;
}
var selectDefaultOnlineStatusId = function () {
    var id = "";
    $(".windown-content-class select[name^='selectOnlineStatus'] option").each(function () {
        if ($(this).attr("selected") == true) {
            id = $.trim($(this).val());
        }
    });
    return id;
}
/*begin get language ids */
var selectStudyLanIds = function () {
    var ids = ",";
    var id = "";
    $(".windown-content-class select[name^='selectMyStudyLan'] option").each(function () {
        if ($(this).attr("selected") == true) {
            id = $.trim($(this).val());
            if (ids.indexOf("," + id + ",") < 0) {
                ids += id + ",";
            }
        }
    });
    return ids;
}
/*end get language ids */
//end set search config

function ApplyFriendTooltip(obj) {
    var _content1 = $("#applyFriendContent").clone();
    tipsWindown(window.ApplyTooltipTitle, "", "470", "", "true", "", "true");
    var _nativeLanUserId = $(obj).parents("ul").find("#hdUserId").val();
    var _src = $(obj).parents("ul").find("img")[0].src;
    var _name = $.trim($(obj).parents("ul").find("a.blue").html());
    $("li.parter_img01 img", _content1).attr("src", _src);
    $("li.parter_txt01 b", _content1).html(_name);
    $("#windown-content").html(_content1.html());
    $("#profinal_big_btn_blue").html(window.sendBotton);
    $("#profinal_big_btn_blue").click(function () {
        ApplyFriendOperate(_nativeLanUserId);
    });
}
/*End Partners/NativeSpeakers */
/*Begin Add Friend:/Personal/Profile*/
//add friend
function ApplyFriendTooltip_Profile(obj) {
    var _content1 = $("#applyFriendContent_profile").clone();
    tipsWindown(window.ApplyTooltipTitle, "", "470", "", "true", "", "true");
    var _nativeLanUserId = window.IndexUserId;
    var _src = $("#img_Url")[0].src;
    var _name = $.trim(window.IndexUserRealName);
    $("li.parter_img01 img", _content1).attr("src", _src);
    $("li.parter_txt01 b", _content1).html(_name);
    $("#windown-content").html(_content1.html());
    $("#profinal_big_btn_blue").html(window.sendBotton);
    $("#profinal_big_btn_blue").click(function () {
        ApplyFriendOperate(_nativeLanUserId);
    });
}
//send message
function SendMessageToFriend() {
    var _content1 = $("#applyFriendContent_profile").clone();
    tipsWindown(window.ApplyTooltipTitle, "", "470", "", "true", "", "true");
    var _nativeLanUserId = window.IndexUserId;
    var _src = $("#img_Url")[0].src;
    var _name = $.trim(window.IndexUserRealName);
    $("li.parter_img01 img", _content1).attr("src", _src);
    $("li.parter_txt01 b", _content1).html(_name);
    $("#windown-content").html(_content1.html());
    $("#profinal_big_btn_blue").html(window.sendBotton);
    $("#profinal_big_btn_blue").click(function () {
        ApplyFriendOperate(_nativeLanUserId);
    });
}
/*End Add Friend:/Personal/Profile*/

/*Begin Partners/MyPartners */
//page js
$(document).ready(function () {
    $(".showDiv").click(function () {
        if ($(this).next(".menu_down_box").is(":visible")) {
            $(this).next(".menu_down_box").hide();
        } else {
            $(".menu_down_box").hide();
            $(this).next(".menu_down_box").show();
        }
    });
});

function DelFriend(userFriendId) {
    if (userFriendId > 0) {
        $.ajax({
            type: "POST",
            url: "/AjaxService/DelFriend",
            data: "UserFriendId=" + userFriendId,
            dataType: 'json',
            success: function (data) {
                if (data.success) {
                    TipMessageRefresh(OperateSuccess);

                } else {
                    TipMessageRefresh(OperateFailure);
                }
            },
            error: function (e) {
                TipMessageRefresh(OperateFailure);
            }
        });
    }
}


/*End Partners/MyPartners */

/*Begin Delete Friend /Personal/Profile*/
function DelMyPartnersTooltip_profile(userFriendId, obj) {
    var _content1 = $("#applyFriendContent_profile").clone();
    tipsWindown(window.TooltipTitle, "", "470", "", "true", "", "true");
    var _src = $("#img_Url")[0].src;
    var _name = $.trim(window.IndexUserRealName);
    $("li.parter_img01 img", _content1).attr("src", _src);
    $("li.parter_txt01 b", _content1).html(_name);
    $("#windown-content").html(_content1.html());
    $("#profinal_big_btn_blue").html(window.ConfirmBotton);
    $("#profinal_big_btn_blue").click(function () {
        DelFriend(userFriendId);
    });
}
/*End Delete Friend /Personal/Profile*/

/*Begin To Message /Personal/Profile*/
function SendMessage(obj, recieveUsersId) {
    var recieveUserId = recieveUsersId;
    var message = $("#" + obj).val();
    if (recieveUsersId > 0) {
        $.ajax({
            type: "POST",
            url: "/Messages/SendMessage",
            data: "msg=" + message + "&receiveUserId=" + recieveUserId,
            dataType: 'json',
            success: function (data) {
                $(".divSendMsg").hide();
                TipMessageRefresh(OperateSuccess);
            },
            error: function (e) {
                $(".divSendMsg").hide();
                TipMessageRefresh(OperateFailure);
            }
        });
    }
}
/*End To Message /Personal/Profile*/


/*Begin /Apps/AppCenter*/
//page js
function addApps(appsId) {
    if (appsId > 0) {
        $.ajax({
            type: "POST",
            url: "/AjaxService/AddApps",
            data: "AppsId=" + appsId,
            dataType: 'json',
            success: function (data) {
                if (data.success) {
                    TipMessageRefresh(OperateSuccess);
                } else {
                    TipMessageRefresh(OperateFailure);
                }
            },
            error: function (e) {
                TipMessageRefresh(OperateFailure);
            }
        });
    }
}
//ui block
function addAppsTooltip(appsId, obj) {
    var _content1 = $("#AddAppsContent").clone();
    tipsWindown(window.TooltipTitle, "", "470", "", "true", "", "true");
    var _src = $(obj).parents("ul").find("img")[0].src;
    var _name = $(obj).parents("ul").find("li.application_txt dl dt").html();
    var _describe = $(obj).parents("ul").find("dd.describe").html();
    var _developerName = $(obj).parents("ul").find("span").html();
    $("li.parter_img02 img", _content1).attr("src", _src);
    $("li.parter_txt01 b", _content1).html(_name);
    $("li.parter_txt01 code", _content1).html(_describe);
    $("li.parter_txt01 span", _content1).html(_developerName);
    $("#windown-content").html(_content1.html());
    $("#profinal_big_btn_blue").html(window.AddBotton);
    $("#profinal_big_btn_blue").click(function () {
        addApps(appsId);
    });
}
/*End /Apps/AppCenter*/

/*Begin /Apps/MyApps */
//page js
function DelApps(appsId) {
    if (appsId > 0) {
        $.ajax({
            type: "POST",
            url: "/AjaxService/DelApps",
            data: "AppsId=" + appsId,
            dataType: 'json',
            success: function (data) {
                if (data.success) {
                    TipMessageRefresh(OperateSuccess);
                } else {
                    TipMessageRefresh(OperateFailure);
                }
            },
            error: function (e) {
                TipMessageRefresh(OperateFailure);
                //window.location.href = "/Home/Index/13928";
            }
        });
    }
}
//ui block
function DelAppsTooltip(appsId, obj) {
    var _content1 = $("#DelAppsContent").clone();
    tipsWindown(window.TooltipTitle, "", "470", "", "true", "", "true");
    var _src = $(obj).parents("ul").find("img")[0].src;
    var _name = $(obj).parents("ul").find("li.application_txt dl dt").html();
    var _describe = $(obj).parents("ul").find("dd.describe").html();
    var _developerName = $(obj).parents("ul").find("span").html();
    $("li.parter_img02 img", _content1).attr("src", _src);
    $("li.parter_txt01 b", _content1).html(_name);
    $("li.parter_txt01 code", _content1).html(_describe);
    $("li.parter_txt01 span", _content1).html(_developerName);
    $("#windown-content").html(_content1.html());
    $("#profinal_big_btn_blue").html(window.DelBotton);
    $("#profinal_big_btn_blue").click(function () {
        DelApps(appsId);
    });
}
/*End /Apps/MyApps */
/*Begin /Messages/Partner*/
//page js
function CheckAll() {
    var m = document.getElementsByName('cbox');
    for (var i = 0; i < m.length; i++) {
        m[i].checked == true
                        ? m[i].checked = true
                        : m[i].checked = true;
    }
    $("#selvalue").html("全部");
};

function CancelCheck() {
    var m = document.getElementsByName('cbox');
    for (var i = 0; i < m.length; i++) {
        m[i].checked == false
                        ? m[i].checked = false
                        : m[i].checked = false;
    }
    $("#selvalue").html("无");
};

function CancelSelectAll() {
    var _cboxs = $("input[name^='cbox']");
    var userIds = "";
    $(_cboxs).each(function () {
        if (this.checked == true) {
            userIds += $(this).val() + ",";
        }
    });
    if (userIds != "") {
        $.ajax({
            type: "POST",
            url: "/AjaxService/HideSelectAll",
            data: "UserIds=" + userIds,
            dataType: 'json',
            success: function (data) {
                if (data.success) {
                    TipMessageRefresh(OperateSuccess);
                } else {
                    TipMessage(OperateFailure);
                }
            },
            error: function (e) {
                TipMessage(OperateFailure);
                //window.location.href = "/Home/Index/13928";
            }
        });
    }
};

function AddFriend(friendId) {
    if (friendId > 0) {
        $.ajax({
            type: "POST",
            url: "/AjaxService/AddFriend",
            data: "FriendId=" + friendId,
            dataType: 'json',
            success: function (data) {
                if (data.success) {
                    TipMessageRefresh(OperateSuccess);
                } else {
                    TipMessage(OperateFailure);
                }
            },
            error: function (e) {
                TipMessage(OperateFailure);
                //window.location.href = "/Home/Index/13928";
            }
        });
    }
};

function ElideFriend(friendId) {
    if (friendId > 0) {
        $.ajax({
            type: "POST",
            url: "/AjaxService/ElideFriend",
            data: "FriendId=" + friendId,
            dataType: 'json',
            success: function (data) {
                if (data.success) {
                    TipMessageRefresh(OperateSuccess);
                } else {
                    TipMessage(OperateFailure);
                }
            },
            error: function (e) {
                TipMessage(OperateFailure);
                //window.location.href = "/Home/Index/13928";
            }
        });
    }
};

function HideFriend(friendId) {
    if (friendId > 0) {
        $.ajax({
            type: "POST",
            url: "/AjaxService/HideFriend",
            data: "FriendId=" + friendId,
            dataType: 'json',
            success: function (data) {
                if (data.success) {
                    TipMessageRefresh(OperateSuccess);
                } else {
                    TipMessage(OperateFailure);
                }
            },
            error: function (e) {
                TipMessage(OperateFailure);
                //window.location.href = "/Home/Index/13928";
            }
        });
    }
};
//ui block
function AddFriendTooltip(friendId, obj) {
    AddFriend(friendId);
}

function ElideFriendTooltip(friendId, obj) {
    var _content1 = $("#ElideFriendContent").clone();
    tipsWindown(window.userTooltipTitle, "", "470", "", "true", "", "true");
    var _src = $(obj).parents("ul").find("img")[0].src;
    var _name = $(obj).parents("ul").find("a.blue").html();
    $("li.parter_img01 img", _content1).attr("src", _src);
    $("li.parter_txt01 b", _content1).html(_name);
    $("#windown-content").html(_content1.html());
    $("#profinal_big_btn_blue").html(window.ConfirmBotton);
    $("#profinal_big_btn_blue").click(function () {
        ElideFriend(friendId);
    });
}

/*End /Messages/Partner*/

/*Begin News*/
function setenceHover(obj) {
    var _id = $.trim($(obj).attr("rel"));
    getImg(_id, "sentence", "img", this);
}
function sentenceHide(obj) {
    $(".div_Imge img").attr("src", "" + "?r=" + Math.random());
    $(".div_Imge").hide();
}
function sentenceClick(obj) {
    var _id = $.trim($(obj).attr("rel"));
    getImg(_id, "sentence", "audio", this);
}
function GetMoreNews(obj, dialogId, sentenceId) {
    var _template = "#RoleName#：<a rel='#SentenceId#' onmouseover='setenceHover(this)' onmouseout='sentenceHide(this)' onclick='sentenceClick(this)' class='a_sentence'><u>#Text#</u>";
    $.ajax({
        type: "POST",
        url: '/_WebSvc/_wsUpdateUserActiveDate.asmx/GetMoreNews',
        data: "dialogId=" + dialogId + "&sentenceId=" + sentenceId + "&isDesc=false",
        dataType: 'text',
        success: function (d) {
            var _htmlResult = "";
            var _data = eval('(' + d + ')');
            var _dataList = _data.SentenceModelList;
            if (typeof _dataList != "undefined") {
                for (var i = 0; i < _dataList.length; i++) {
                    var _tmp = _template;
                    _tmp = _tmp.replace("#RoleName#", _dataList[i].RoleName);
                    _tmp = _tmp.replace("#SentenceId#", _dataList[i].SentenceId);
                    _tmp = _tmp.replace("#Text#", _dataList[i].Text);
                    _htmlResult += _tmp;
                    if (i != _dataList.length - 1) {
                        _htmlResult += "<br />";
                    }
                }
            }
            $(obj).before(_htmlResult);
            $(obj).hide();
        },
        error: function (e) {
            alert(e);
            //TipMessageRefresh(SubmitFailure);
            //window.location.href = "/Home/Index/13928"; 
        }
    });
}
/*End News*/

/**Begin Help/FeedBack**/
//page js
function FeedBackSubmit() {
    if (ValidateFeedBack() == false) return;
    var URLString = document.referrer;
    var feedBackUserEmail = $("#txtFeedBack").val();
    var selFeedBackTypeId = $("#selFeedBack option:selected").val();
    var feedBackContent = $("#txtContent").val();
    $.ajax({ type: "POST",
        url: "/AjaxService/SubmitFeedBack",
        data: "FeedBackUserEmail=" + feedBackUserEmail + "&FeedbackTypeId=" + selFeedBackTypeId + "&FeedbackContent=" + feedBackContent + "&URLString=" + URLString,
        dataType: 'json',
        success: function (data) {
            if (data.success) {
                TipMessageRefresh(SubmitSucceed);
            } else {
                TipMessageRefresh(SubmitFailure);
            }
        },
        error: function (e) {
            TipMessageRefresh(SubmitFailure);
            //window.location.href = "/Home/Index/13928"; 
        }
    });
}
/**End Help/FeedBack**/


/**begin  Account/PassWordAndSafty **/
//page js
function updatePassword() {
    if (ValidateAlterPassWord() == false) return;
    var _Password = $("#txtSignInPassword").val();
    var _PasswordConfirmation = $("#txtSignPasswordConfirmation").val();

    $.ajax({
        type: "POST",
        url: "/AjaxService/SignInUpdatePassWord",
        data: "password=" + _Password,
        dataType: 'json',
        success: function (data) {
            if (data.success) {
                TipMessageRefresh(SaveSuccess);
            } else {
                TipMessageRefresh(SaveFailure);
            }
        },
        error: function (e) {
            TipMessageRefresh(SaveFailure);
            //window.location.href = "/Home/Index/13928"; 
        }
    });
}

function updateSafeQue() {
    if (ValidateSafeQue() == false) return;
    var _txtOldAnswer = $("#txtOldAnswer").val();
    var _selNewAnswer = $("#selNewAnswer option:selected").val();
    var _txtNewAnswer = $("#txtNewAnswer").val();
    var _txtQueContent = $("#txtQueContent").val();

    $.ajax({
        type: "POST",
        url: "/AjaxService/UpdateSafeQue",
        data: "OldAnswerName=" + _txtOldAnswer + "&newSafeQueId=" + _selNewAnswer + "&newAnswerContent=" + _txtNewAnswer + "&DefinedSafeQue=" + _txtQueContent,
        dataType: 'json',
        success: function (data) {
            if (data.success) {
                TipMessageRefresh(OperateSuccess);
            } else {
                TipMessage(OperateFailure);
            }
        },
        error: function (e) {
            TipMessage(OperateFailure);
        }
    });
}
/**end  Account/PassWordAndSafty **/

/***Begin VerifyEmail***/
function VerifyEmail(_userEmail, obj) {
    if (ValidateEmail() == false) return;
    $.ajax({
        type: "POST",
        url: "/AjaxService/VerifyEmail",
        data: "Useremail=" + _userEmail,
        dataType: 'json',
        success: function (data) {
            $("#windown-box").remove();
            if (data.success) {
                TipMessageAttestation(obj);
            } else {
                TipMessage(data.msg);
            }
        },
        error: function (e) {
            TipMessage(ValidateFailure);
        },
        beforeSend: function (e) {
            tipsWindownBuffer('450', '', '', 'verifyEmail');
        }
    });
}
/**End VerifyEmail***/

/**Begin Messages/System **/
//page js
function SetSafeQue(safeQueId, answersContent, _txtQueContent) {
    if (ValidateSystemSafeQue() == false) return;
    $.ajax({
        type: "POST",
        url: "/AjaxService/UpdateSafeQue",
        data: "newSafeQueId=" + safeQueId + "&newAnswerContent=" + answersContent + "&DefinedSafeQue=" + _txtQueContent,
        dataType: 'json',
        success: function (data) {
            if (data.success) {
                TipMessageRefresh(OperateSuccess)
            } else {
                TipMessage(OperateFailure);
            }
        },
        error: function (e) {
            TipMessage(OperateFailure);
            //window.location.href = "/Home/Index/13928"; 
        }
    });
}

function HideMessage(MesId) {
    $.ajax({
        type: "POST",
        url: "/AjaxService/HideMessage",
        data: "MessageId=" + MesId,
        dataType: 'json',
        success: function (data) {
            if (data.success) {
                TipMessageRefresh(OperateSuccess)
            } else {
                TipMessage(OperateFailure);
            }
        },
        error: function (e) {
            TipMessage(OperateFailure);
            //window.location.href = "/Home/Index/13928"; 
        }
    });
}

function HideSelectAll() {
    var _cboxs = $("input[name^='cbox']");
    var MesIds = "";
    $(_cboxs).each(function () {
        if (this.checked == true) {
            MesIds += $(this).val() + ",";
        }
    });
    if (MesIds != '') {
        HideMessage(MesIds);
    } else {
        TipMessage(_delOption);
    }
}
//ui block
function ImmediatelyAttestationTooltip() {
    var _content1 = $("#ImmediatelyAttestationContent").clone();
    tipsWindown(window.TooltipTitle, "", "470", "", "true", "", "true");
    $("#windown-content").html(_content1.html());
    $("#profinal_big_btn_blue").html(window.SendEmail);
    $("#profinal_big_btn_blue").click(function () {
        var _userEmail = $(".windown-content-class .txtUserEmail").val();
        VerifyEmail(_userEmail, this);
    });
}

function SetSafeQueTooltip() {
    var _content1 = $("#SetSafeQueContent").clone();
    tipsWindown(window.TipTitle, "", "470", "", "true", "", "true");
    $("#windown-content").html(_content1.html());
    $("#profinal_big_btn_blue").html(window.SaveBotton);
    $("#profinal_big_btn_blue").click(function () {
        var _safeQueId = GetSafeQueId();
        var _answersContent = $(".windown-content-class .txtSaftyQuestio").val();
        var _txtQueContent = $(".windown-content-class .txtQueContent").val();
        SetSafeQue(_safeQueId, _answersContent, _txtQueContent);
    });
}

var GetSafeQueId = function () {
    var id = "";
    $(".windown-content-class select[name^='selectSafeQue'] option").each(function () {
        if ($(this).attr("selected") == true) {
            id = $.trim($(this).val());
        }
    });
    return id;
}
/**End Messages/System **/

/**begin Account/ChangePassword**/
function UpdatePwd() {
    if (ValidateChangePassword() == false) return;
    var _password = $("#txtPassword").val();
    var _userEmail = $("#userEmail").val();
    var _validateCode = $("#validateCode").val();
    var _asswordConfirmation = $("#txtPasswordConfirmation").val();
    $.ajax({
        type: "POST",
        url: "/AjaxService/RelUpdatePassword",
        data: "Password=" + _password + "&Email=" + _userEmail + "&ValidateCode=" + _validateCode,
        dataType: 'json',
        success: function (data) {
            if (data.success) {
                TipMessageRedirect(SaveSuccess, "/home/signin");
            } else {
                TipMessage(SaveFailure);
            }
        },
        error: function (e) {
            TipMessage(SaveFailure);
            //window.location.href = "/Home/Index/13928"; 
        }
    });

}
/**end Account/ChangePassword**/

/***begin Personal/Profile **/
function UserComment_Add(uid) {
    if (ValidateUserComment() == false) return;
    var _userContent = $("#txtCommentContent").val();
    var indexUserId = uid;
    $.ajax({
        type: "POST",
        url: "/AjaxService/UserCommentAdd",
        data: "Content=" + _userContent + "&IndexUserId=" + indexUserId,
        dataType: 'json',
        success: function (data) {
            if (data.success) {
                TipMessageRedirect(OperateSuccess, FriendsDomain + "/Comment/UserComment.aspx?uid=" + uid);
            } else {
                TipMessage(OperateFailure);
            }
        },
        error: function (e) {
            alert(e);
            TipMessage(OperateFailure);
            //window.location.href = "/Home/Index/13928"; 
        }
    });
}

/** end Personal/Profile **/

/*open selfstudy dialog*/
function OpenSelfStudyDialog(_url) {
    var content = _url;
    tipsWindown(window.BuyCourseTooltipTitle, "", "800", "", "true", "", "true");
    //$("#profinal_big_btn_blue").html("去付款");
    $("#profinal_big_btn_blue").parent().css("display", "none");
    $(".login_footer").css("display", "none")
    $("#windown-box").css("width", "800").css("position", "absolute").css("margin-left", "150").css("top", "100").css("left", "100").css("margin-top", "0");
    $("#windown-content").ajaxStart(function () {
        //$(this).html("<img src='" + loadingImgSrc + "' class='loading' alt='Wordoor' />");
    });
    $.ajax({
        error: function () {
            $("#windown-content").html("<p class='windown-error'>" + content2 + "</p>");
        },
        success: function (html) {
            $("#windown-content").html("<iframe src=\"" + content + "\" width=\"100%\"  height=\"430\" id=\"iframes1\"  scrolling=\"auto\" frameborder=\"0\" onLoad=\"TuneHeight()\"  marginheight=\"0\" marginwidth=\"0\"></iframe>");
            $("#windown-content iframe").attr("src", content);
        },
        beforeSend: function (e) {
            $("#windown-content").html('<img width="16" height="16" src="/_Images/u164.gif" style="vertical-align: middle;margin-left:380px;">');
        }
    });
}

function CancelSelfStudyDialog(msgId, _obj) {

    $.ajax({
        type: "POST",
        url: "/_WebSvc/wsSelfStudy.asmx/DeleteSelfStudyMsg",
        data: "msgId=" + msgId,
        dataType: 'json',
        success: function (data) {
            if (typeof data != "undefined" && parseInt(data) == 1) {
                //TipMessage(SaveSuccess);
                var _val = $.trim($("#system-mark").html());
                if (typeof _val != "undefined" && parseInt(_val) > 0) {
                    _val = parseInt(_val) - 1;
                    if (parseInt(_val) == 0) {
                        $("#system-mark").css("display", "none")
                    }
                    $("#system-mark").html(_val);
                }
                else if (typeof _val != "undefined" && parseInt(_val) == 0) {
                    $("#system-mark").css("display", "none")
                }
                $(_obj).parents(".person_pop_content").remove();
            } else {
                //TipMessage(SaveFailure);
            }
        },
        error: function (e) {
            TipMessage(SaveFailure);
            //window.location.href = "/Home/Index/13928"; 
        }
    });
}

function TuneHeight() {
    var frm = document.getElementById("iframes1");
    var subWeb = document.frames ? document.frames["iframes1"].document : frm.contentDocument;
    if (frm != null && subWeb != null) {
        frm.height = subWeb.body.scrollHeight;
    }
}

//validate invitation code
function InvitationCodeValidate() {
    var _content1 = $("#div_InvitationCode").clone();  //tempalte from home/index
    tipsWindown(window.InvitationCode, "", "470", "", "true", "", "true");
    $("#windown-content").html(_content1.html());
    $("#profinal_big_btn_blue").html(window.NextStep);
    $("#windown-content-font").html("");
    $("#windown-content-font").html(window.NoInvitationDesc);
    $(".a_footer").click(function () {
        ApplyInvitationCode();
    });
    $("#windown-content-font").css("display", "");
    $("#windown-box").css("top", "200px");
    $("#profinal_big_btn_blue").click(function () {
        InvitationCodeSubmit();
    });
}

function ApplyInvitationCode() {
    var _content1 = $("#divApplyRegister").clone();  //tempalte from home/index
    tipsWindown(window.ApplyInvitationDesc, "", "470", "", "true", "", "true");
    $("#windown-content").html(_content1.html());
    $("#profinal_big_btn_blue").html(window.SubmitingDesc);
    $("#windown-content-font").hide();
    $("#windown-box").css("top", "200px");
    $("#profinal_big_btn_blue").click(function () {
        var PersonName = $("#windown-content .txtVisitorUserRealName").val();
        var PersonEmail = $("#windown-content .txtVisitorUserEmail").val();
        var PersonContent = $("#windown-content .textareaCotent").html();
        if (PersonEmail.indexOf("@") > -1) {
            var bool_mail = email(PersonEmail);
            if (bool_mail == false) {
                alert(EmailError);
                return false;
            }
        }
        else {
            alert(EmailError);
            return false;
        }
        $.ajax({
            type: "POST",
            url: "/_WebSvc/wsInvitationCode.asmx/AddRegisteringPerson",
            data: "UserEmail=" + PersonEmail + "&PersonName=" + PersonName + "&PersonContent=" + PersonContent,
            dataType: 'text',
            success: function (data) {
                TipMessage(window.ApplyInvitationSuccess);
            },
            error: function (e) {
                alert(e);
                //window.location.href = "/Home/Index/13928";
                return false;
            }
        });
    });
}

function InvitationCodeSubmit() {
    var _code = $(".windown-content-class .InvitationCode").val();
    $.ajax({
        type: "POST",
        url: "/_WebSvc/wsInvitationCode.asmx/CheckInvitationCodeExist",
        data: "InvitationCode=" + _code,
        dataType: 'text',
        success: function (data) {
            if (data.indexOf("True") > -1) {
                SingUp(_code);
            }
            else {
                alert(window.InvitationCodeHadUsed);
            }
        },
        error: function (e) {
            alert(e);
            //window.location.href = "/Home/Index/13928";
            return false;
        }
    });
}
function CheckInvitationCodeExist(_code) {


}

function SendInvitationCodeNo(Ctl, CodeNo) {
    var _content1 = $("#div_SendInvitationTemplate").clone();  //tempalte from home/index
    tipsWindown(window.SendInvitationTitle, "", "470", "", "true", "", "true");
    var _Html = _content1.html();
    _Html = _Html.replace("#CodeNo#", CodeNo);
    _Html = _Html.replace("#CodeNo#", CodeNo);
    $("#windown-content").html(_Html);
    $("#profinal_big_btn_blue").html(window.SendInvitationTitle);
    $("#windown-content-font").css("display", "none");
    $("#windown-box").css("top", "200px");
    $("#profinal_big_btn_blue").click(function () {
        var Email = $.trim($(".windown-content-class .txtFriendEmail").val());
        var EmailContent = $.trim($(".windown-content-class .textareaSendContent").val());
        SendInvitationEmail(Email, CodeNo, EmailContent);
    });
}
function SendInvitationEmail(_Email, _CodeNo, EmailContent) {
    _code = _CodeNo;
    $.ajax({
        type: "POST",
        url: "/_WebSvc/wsInvitationCode.asmx/SendInvitationCodeEmail",
        data: "CodeNO=" + _code + "&Email=" + _Email + "&EmailContent=" + escape(EmailContent),
        dataType: 'text',
        success: function (data) {
            if (data.indexOf("True") > -1) {
                TipMessage(window.SendInvitationSuccess);
                return true;
            }
            else {
                return false;
            }
        },
        error: function (e) {
            alert(e);
            //window.location.href = "/Home/Index/13928";
            return false;
        }
    });
}

function copyInvitationCode(obj) {
    var _Ctl = $(obj).prev();
    copyToClipboard(_Ctl);
    var CopySuccess = window.CopySuccess;
    TipMessage(CopySuccess);
}
