$(function () {
    PageLoadTrees();
    $("#myPageAlert").hide();
    manageObj. getmyselfpara();
});

//初始化绑定回调
function AsyncGetMySelfParaResult(jsonResult) {
	if (jsonResult.success) {
	    var topFriend = false;
	    var groupQuick = false;
	    var friendDoc = true;//初始值
        if (jsonResult.data.length > 0) {
            for (i in jsonResult.data) {
                if (jsonResult.data[i].key.indexOf("bisphonefriendtop") != -1) {
                    topFriend = jsonResult.data[i].valus == "1" ? true : false;
                } else if (jsonResult.data[i].key.indexOf("bisrobatgroupquick") != -1) {
                    groupQuick = jsonResult.data[i].valus == "1" ? true : false;
                } else if (jsonResult.data[i].key.indexOf("bisrobatfrienddoc") != -1) {
                    friendDoc = jsonResult.data[i].valus == "1" ? true : false;;
                }
                $("#topFriend").prop("checked", topFriend);
                $("#crowdIsOpen").prop("checked", groupQuick);
                $("#FriendDoc").prop("checked", friendDoc);
            }
        }
    } else {
        ShowError("myPageAlert", "获取参数异常：" + jsonResult.error);
    }
    $(".loadingcover").hide();
    $(".loading").hide();
}
//修改参数设置
function UpdateParameter() {
    $(".loadingcover").show();
    $(".loading").show();

    //是否开启好友置顶同步到手机端
    var friendsSetTop = $("#topFriend").is(":checked") ? "1" : "0";
    var friends = {};
    friends.key = "bisphonefriendtop";
    friends.val = friendsSetTop;

    //是否开启群关键字回复
    var GroupAutomaticReply = $("#crowdIsOpen").is(":checked") ? "1" : "0";
    var crowdsReply = {};
    crowdsReply.key = "bisrobatgroupquick";
    crowdsReply.val = GroupAutomaticReply;

    var FriendDoc = $("#FriendDoc").is(":checked") ? "1" : "0";
    var ShowFriendDoc = {};
    ShowFriendDoc.key = "bisrobatfrienddoc";
    ShowFriendDoc.val = FriendDoc;
    //初始是否显示好友档案
    var count = [];
    count.push(friends);
    count.push(crowdsReply);
    count.push(ShowFriendDoc);
    var strParaJson = $.toJSON({
        para: count
    });
    manageObj.setresetnewmyself(strParaJson);
}
//保存参数设置回调
function AsyncSetResetNewMyselfResult(jsonResult) {
    if (jsonResult.success) {
        ShowMsg("myPageAlert", "操作成功！");
    } else {
        ShowError("myPageAlert", "保存数据异常：" + jsonResult.error);
    }
    $(".loadingcover").hide();
    $(".loading").hide();
}

function PageLoadTrees() {
    $(".left-list-l").css({
        height: $(window).height() - 40
    });

    $(".talklist-m").css({
        height: $(window).height() - 130
    });
    $("#right").css({
        height: $(window).height() - 40
    });
    $("#left").css({
        height: $(window).height() - 40
    });

    initTree();
}
$(window).resize(function () {
    PageLoadTrees();
});