//
// friends
//


//
// del friends
//
function bcFriendsDel(iMID,sUsername) {

	if (confirm("Are you sure you want to remove " + sUsername.toUpperCase() + 
	            " from your list?\n\nYou will be removed from his list and all " + 
	            "mutual comments will\nalso be removed from both profiles.")) {
	            
        $.getJSON("../_api/friends_json.ashx?method=201&id="+iMID+"&ts="+(new Date().getTime()), function(json,textStatus){
            if (textStatus=="success") {
				var iStatus = parseInt(json[0].status);
				if (iStatus > 0) {
					window.location.reload(true);
				} else {
					//error: try std page
					return true;
				}
            } else {
		        //error:
    		    return true;     
            }                   
        });
        	            	            	            		
	}
	return false;
}


//
// del comment
//
function bcFriendsDelComment(iID) {
	if (confirm("Are you sure you wan to delete this comment?")) {
	
        $.getJSON("../_api/friends_json.ashx?method=200&id="+iID+"&ts="+(new Date().getTime()), function(json,textStatus){
            if (textStatus=="success") {
				var iStatus = parseInt(json[0].status);
				if (iStatus > 0) {
					window.location.reload(true);
				} else {
					//error: try std page
					return true;
				}
            } else {
		        //error:
    		    return true;     
            }                   
        });	
	
	}
	return false;
}


//
// add comment 
//
function bcFriendsAddComment(iMID) {
    // modal?
    if ($.fn.colorbox) {
        // modal
        var sUrl = "../friends/postcomment_pop.aspx?id=" + iMID;
        return bcShowModal({ href: sUrl, innerWidth: 500, innerHeight: 500 });
    } else {
        // std popup
        var oWin = window.open("../friends/postcomment_pop.aspx?id=" + iMID, "BCFDSCMT", "width=480,height=504,top=0,left=0,toolbar=0,directories=0,menubar=0,status=1,location=0,scrollbars=1,resizable=1,resizeable=1");
        if (oWin == null) { return true; } else { return false; }    
    }
	return false;
}


//
// add friend
//
function bcFriendsAdd(sUsername) {
    // modal?
    if ($.fn.colorbox) {
        // modal
        var sUrl = "../friends/add_pop.aspx?un=" + sUsername;
        return bcShowModal({ href: sUrl, innerWidth: 500, innerHeight: 500 });
    } else {
        // std popup
        if (sUsername == null) { sUsername = ""; }
        var oWin = window.open("../friends/add_pop.aspx?un=" + sUsername, "BCFDSADD", "width=480,height=408,top=0,left=0,toolbar=0,directories=0,menubar=0,status=1,location=0,scrollbars=0,resizable=1,resizeable=1");
        if (oWin == null) {
            alert("Your popup blocker prevented the friend invite window from opening.\nPlease disable your popup blocker to use this feature.");
        }
    }
    return false;
}


//
// send bulletin
//
function bcPopBulletin() {
    _bcPage.Enotes.disableAutoRef = true;
    return bcShowModal({ href: "../enotes/sendbulletin_pop.aspx", innerWidth: 500, innerHeight: 500 });
}

//
// bcShowModal (in master.js)
//