﻿
FriendsObj = {
    AddFriend: function(userid) {
        CreateComDiv();
        var mycomdiv = document.getElementById("divCommon");
        mycomdiv.style.display = "";
        mycomdiv.style.width = "300px";
        mycomdiv.style.height = "120px";
        // alert(commonBodyWidth);
        // alert(commonBodyHeight);
        dleft1 = (commonBodyWidth - 300) / 2;
        dtop1 = (commonBodyHeight - 120) / 2;
        // alert(dtop1);
        // alert(dleft1);
        fixedPosition(mycomdiv, dtop1, dleft1);
        mycomdiv.innerHTML = "正在添加.....";
        if (UserIsLogined == 0) {
            mycomdiv.innerHTML = "您还没有登录&nbsp;&nbsp;&nbsp;" + "<input type=button value='关闭' style='border:solid 1px;' onclick='document.getElementById(\"divCommon\").style.display=\"none\";'/>";
            return;
        }

        $.ajax(
            {
                type: "GET",
                url: "/AsyncPg/user.aspx",
                data: "typepar=4&userid=" + userid,
                //                dataType: "html",
                cache: false,
                success: function(str) {
                    var inputStr = "<input type=button value='关闭' style='border:solid 1px;' onclick='document.getElementById(\"divCommon\").style.display=\"none\";'/>";
                    switch (parseInt(str)) {
                        case 1:
                            document.getElementById("divCommon").innerHTML = "添加成功" + "&nbsp;&nbsp;&nbsp;" + inputStr;
                            break;
                        case 2:
                            document.getElementById("divCommon").innerHTML = "不能添加自己" + "&nbsp;&nbsp;&nbsp;" + inputStr;
                            break;
                        case 3:
                            document.getElementById("divCommon").innerHTML = "不能重复添加" + "&nbsp;&nbsp;&nbsp;" + inputStr;
                            break;
                        case 4:
                            document.getElementById("divCommon").innerHTML = "对不起添加失败，免费用户添加商业伙伴不能超过10条" + "&nbsp;&nbsp;&nbsp;" + inputStr;
                            break;
                    }
                },
                error: function(str) {

                }

            }
        );
    }
}
