﻿/**Begin /Account/RetrievePassWord**/
function ValidateRetrievePwd() {
    var _retrievePwdUserEmail = $.trim($("#txtUserEmail").val());

    var bool_mail = email(_retrievePwdUserEmail);
    if (equStrLength(_retrievePwdUserEmail, 0)) {
        TipMessage(window.EmailIsEmpty);
        return false;
    } else if (bool_mail == false) {
        TipMessage(window.EmialError);
        return false;
    }
    return true;
}

function ValidateRetrievePwdSafeQue() {
    var _SaftyQuestio = $(".windown-content-class .txtSaftyQuestio").val();

    var bool_safeQue = length1_24(_SaftyQuestio);
    if (equStrLength(_SaftyQuestio, 0)) {
        TipMessage(safeQueIsEmpty);
        return false;
    } else if (bool_safeQue == false) {
        TipMessage(safeQueError);
        return false;
    }
    return true;
}
/**end /Account/RetrievePassWord**/
/**Begin Help/FeedBack **/
function ValidateFeedBack() {
    var _feedBackUserEmail = $.trim($("#txtFeedBack").val());
    var _feedBackContent = $.trim($("#txtContent").val());

    var bool_mail = email(_feedBackUserEmail);
    if (equStrLength(_feedBackUserEmail, 0)) {
        TipMessage(EmialIsEmpty);
        return false;
    }
    else if (bool_mail == false) {
        TipMessage(EmialError);
        return false;
    } else if (equStrLength(_feedBackContent, 0)) {
        TipMessage(ContentIsEmpty);
        return false;
    }
    return true;
};
/**End Help/FeedBack **/

/**begin Home/Index**/
function ValidateLogin() {
    var _loginUserEmail = $.trim($("#txtUserEmail").val());
    var _loginUserPwd = $("#txtPwd").val();

    var bool_pwd = pwdLength(_loginUserPwd);
    if (equStrLength(_loginUserEmail, 0)) {
        TipMessage(userEmailAndUserNameIsEmpty);
        return false;
    } else if (equStrLength(_loginUserPwd, 0)) {
        TipMessage(PwsIsEmpty);
        return false;
    } else if (bool_pwd == false) {
        TipMessage(PwdLengthValidate);
        return false;
    } else if (_loginUserEmail.indexOf("@") > -1) {
        var bool_mail = email(_loginUserEmail);
        if (bool_mail == false) {
            TipMessage(EmailError);
            return false;
        }
    } else {
        var bool_nickname = isSafeChar(_loginUserEmail) && length1_24(_loginUserEmail);
        if (bool_nickname == false) {
            TipMessage(UserNameError);
            return false;
        }
    }
    return true;
}

//sign up
function ValidateSingUp() {
    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 _vercode = $.trim($.cookie("VerCode"));

    if (_vercode != null && _vercode.length > 0) {
        _vercode = _vercode.toLowerCase();
        if (_txtSignUpValidateCode != null && _txtSignUpValidateCode.length > 0) {
            _txtSignUpValidateCode = _txtSignUpValidateCode.toLowerCase();
        }
    }

    var bool_Emaul = email(_txtSignUpEamil);
    var bool_pwd = pwdLength(_txtSignUpPwd);

    if (equStrLength(_txtSignUpEamil, 0)) {
        $(".windown-content-class .tipsSignUpError").css("display", "");
        $(".windown-content-class .tipsSignUpError").html(UserEmailIsEmpty);
        return false;
    } else if (bool_Emaul == false) {
        $(".windown-content-class .tipsSignUpError").css("display", "");
        $(".windown-content-class .tipsSignUpError").html(EmailError);
        return false;
    } else if (equStrLength(_txtSignUpPwd, 0)) {
        $(".windown-content-class .tipsSignUpError").css("display", "");
        $(".windown-content-class .tipsSignUpError").html(PwsIsEmpty);
        return false;
    } else if (bool_pwd == false) {
        $(".windown-content-class .tipsSignUpError").css("display", "");
        $(".windown-content-class .tipsSignUpError").html(PwdLengthValidate);
        return false;
    }
    else if (_txtSignUpPwd.toString() != _txtSignUpPwdConfirmation.toString()) {
        $(".windown-content-class .tipsSignUpError").css("display", "");
        $(".windown-content-class .tipsSignUpError").html(PwdInconformity);
        return false;
    } else if (equStrLength(_txtSignUpValidateCode, 0)) {
        $(".windown-content-class .tipsSignUpError").css("display", "");
        $(".windown-content-class .tipsSignUpError").html(CodeIsEmpty);
        return false;
    }
    else if (_vercode != _txtSignUpValidateCode) {
        $(".windown-content-class .tipsSignUpError").css("display", "");
        $(".windown-content-class .tipsSignUpError").html(CodeError);
        return false;
    }
    return true
}

function UserEamilExist(SignUpEamil) {
    $.ajax({
        type: "POST",
        url: "/AjaxService/ExistUserEamil",
        data: "userEmail=" + SignUpEamil,
        dataType: 'json',
        success: function (data) {
            if (data.success) {
                return false;

            }
        }
    });
    return false;
}
/**end Home/Index**/

/**Begin Account/PassWordAndSafty **/
function ValidateAlterPassWord() {
    var _userPassWord = $("#txtSignInPassword").val();
    var _userPassWordConfig = $("#txtSignPasswordConfirmation").val();

    var bool_mail = pwdLength(_userPassWord);
    if (equStrLength(_userPassWord, 0)) {
        TipMessage(PwdIsEmpty);
        return false;
    } else if (_userPassWord != _userPassWordConfig) {
        TipMessage(PwdInconformity);
        return false;
    } else if (bool_mail == false) {
        TipMessage(PwdLengthValidate);
        return false;
    }
    return true;
}

function ValidateSafeQue() {
    var IsSafeQue = $("#IsSafeQue").val();
    var _userOldAnswer = $("#txtOldAnswer").val();
    var _userNewAnswer = $("#txtNewAnswer").val();
    var _txtQueContent = $("#txtQueContent").val();

    var bool_userNewAnswer = length1_24(_userNewAnswer);
    var bool_userOldAnswer = length1_24(_userOldAnswer);
    if (IsSafeQue == "True") {
        if (equStrLength(_userOldAnswer, 0)) {
            TipMessage(OldAnswerIsEmpty);
            return false;
        }
        else if ($.trim(_userOldAnswer).length < 1 || $.trim(_userOldAnswer).length >= 100) {
            TipMessage(AnswerContentLength);
            return false;
        }
    }
    if (SelQueId() == 6) {
        if (equStrLength(_txtQueContent, 0)) {
            TipMessage(QueIsEmpty);
            return false;
        } else if ($.trim(_txtQueContent).length < 1 || $.trim(_txtQueContent).length >= 100) {
            TipMessage(QueError);
            return false;
        }
    }
    if (equStrLength(_userNewAnswer, 0)) {
        TipMessage(AnswerContentIsEmpty);
        return false;
    } else if (bool_userNewAnswer == false) {
        TipMessage(AnswerContentIsEmpty);
        return false;
    }
    return true;
}
/**End Account/PassWordAndSafty **/

/**begin /Account/ChangePassword **/
function ValidateChangePassword() {
    var _password = $("#txtPassword").val();
    var _asswordConfirmation = $("#txtPasswordConfirmation").val();

    var bool_mail = pwdLength(_password);
    if (equStrLength(_password, 0)) {
        TipMessage(PwdIsEmpty);
        return false;
    } else if (_password != _asswordConfirmation) {
        TipMessage(PwdInconformity);
        return false;
    } else if (bool_mail == false) {
        TipMessage(PwdLengthValidate);
        return false;
    }
    return true;
}
/**End /Account/ChangePassword **/


/**begin /Messages/Ststem **/
function ValidateEmail() {
    var _userEmail = $.trim($(".windown-content-class .txtUserEmail").val());

    var bool_mail = email(_userEmail);
    if (equStrLength(_userEmail, 0)) {
        TipMessage(window.EmailIsEmpty);
        return false;
    } else if (bool_mail == false) {
        TipMessage(window.EmialError);
        return false;
    }
    return true;
}

function ValidateSystemSafeQue() {
    var _SaftyQuestio = $(".windown-content-class .txtSaftyQuestio").val();
    var _txtQueContent = $(".windown-content-class .txtQueContent").val();

    var bool_safeQue = length1_24(_SaftyQuestio);
    var bool_QueError = length1_24(_txtQueContent);
    if (SelQueId() == 6) {
        if (equStrLength(_txtQueContent, 0)) {
            TipMessage(QueIsEmpty);
            return false;
        } else if (bool_QueError == false) {
            TipMessage(QueError);
            return false;
        }
    }
    if (equStrLength(_SaftyQuestio, 0)) {
        TipMessage(safeQueIsEmpty);
        return false;
    } else if (bool_safeQue == false) {
        TipMessage(safeQueError);
        return false;
    }
    return true;
}

/*** End /Messages/Ststem  **/

/*** begin Profile**/
function ValidateUserComment() {
    var _userContent = $.trim($("#UcDialogueComment_SubmitPanel .txtCommentContent").val());
    if ($.trim(_userContent.length) < 1 || $.trim(_userContent).length > 140) {
        TipMessage(CharLengthError);
        return false;
    }
    return true;
}

/*** end Profile**/
