﻿/** about friends **/
function addFriend(friName) {
    if (friName.length > 0) {
        $("#btnFriend").attr("disabled", "disabled");
        $.ajax({
            url: "/ajax/friends/Add_Friends.ashx",
            type: "POST",
            dataType: "xml",
            data: { friName: friName, date: new Date() },
            success: function(xml) {
                $(xml).find("result").each(function() {
                    alert($(this).text());
                });
                $("#btnFriend").attr("disabled", "");
            },
            error: function() {
                alert("文件载入错误，请稍后重试！");
                $("#btnFriend").attr("disabled", "");
            }
        });
    } else {
        alert("请输入要添加的好友");
    }
}
function deleteFriend(friID) {
    if (confirm("您确定要删除该好友吗？这是不可恢复的操作！")) {
        if (friID>0){
            $.ajax({
                url: "/ajax/friends/Delete_Friends.ashx",
                type: "POST",
                dataType: "xml",
                data: { id: friID, date: new Date() },
                success: function(xml) {
                    $(xml).find("result").each(function() {
                        alert($(this).text());
                        if ($(this).attr("flag") == "1") {
                            location.href = location.href;
                        }
                    });
                },
                error: function() {
                    alert("文件载入错误，请稍后重试！");
                }
            });
        }else{
            alert("请选择要删除的好友！");
        }
    }
}
//audit friend
function friAudit(friID) {
    //authorFriend.ashx
    $.ajax({
    url: "/ajax/friends/Audit_Friends.ashx",
        type: "POST",
        dataType: "xml",
        data: { id: friID, date: new Date() },
        success: function(xml) {
            $(xml).find("result").each(function() {
                alert($(this).text());
                if ($(this).attr("flag") == "1") {
                    location.href = location.href;
                }
            });
        },
        error: function() {
            alert("文件载入错误，请稍后重试！");
        }
    });
}
/** end of friends **/


/** about attention **/
function addAttention(attName) {
    if (attName.length > 0) {
        $("#btnAttention").attr("disabled", "disabled");
        $.ajax({
            url: "/ajax/attention/Add_Attention.ashx",
            type: "POST",
            dataType: "xml",
            data: { attName: attName, date: new Date() },
            success: function(xml) {
                $(xml).find("result").each(function() {
                    alert($(this).text());
                });
                $("#btnAttention").attr("disabled", "");
            },
            error: function() {
                alert("文件载入错误，请稍后重试！");
                $("#btnAttention").attr("disabled", "");
            }
        });
    } else {
        alert("请输入要添加的好友");
    }
}
function deleteAttention(friID) {
    if (confirm("您确定要删除该好友吗？这是不可恢复的操作！")) {
        if (friID>0){
            $.ajax({
                url: "/ajax/friends/Delete_Friends.ashx",
                type: "POST",
                dataType: "xml",
                data: { id: friID, date: new Date() },
                success: function(xml) {
                    $(xml).find("result").each(function() {
                        alert($(this).text());
                        if ($(this).attr("flag") == "1") {
                            location.href = location.href;
                        }
                    });
                },
                error: function() {
                    alert("文件载入错误，请稍后重试！");
                }
            });
        }else{
            alert("请选择要删除的好友！");
        }
    }
}
/** end of attention **/

