function AddFriend(obj,sTextToAddBefore,sUserName,userId,icon,container) {
	if (!protectMembers()) return false;

	var sUser = (sUserName || sUsername);
	icon=icon || "~";
	
	if (obj.innerHTML.toLowerCase().replace(/<a>/gi,"").replace(/<\/a>/gi,"").indexOf("confirm friend") > -1)
	{
	   $.ajax({
		   type: "POST",
		   url: ROOT_URL+"pro-friends.asp",
		   data: {act:"confirmFriend",id:userId},
		   success: function(msg){
				MessageBox(396,105,"Got it! close this message","<span>You are now friends with <span class=\"color3\">~</span>"+sUser+".</span>",true,null,true);
				if (sTextToAddBefore != null)
				{
					obj.innerHTML = sTextToAddBefore + (sUserName!=null?"R":"r")+"emove friend";
				} else {
					obj.innerHTML = "<div class=\"nav nav2\"></div>remove friend";
				}
		   }
	   });
		
	} else if (obj.innerHTML.toLowerCase().replace(/<a>/gi,"").replace(/<\/a>/gi,"").indexOf("remove friend") > -1)
	{
	
		MessageBox(396,119,"Yes! remove this friend","<span>Are you sure you want to remove <span class=\"color3\">~</span>"+sUser+" from your friends list? (press the X button to cancel)</span>",true,function() {
		
		   $.ajax({
			   type: "POST",
			   url: ROOT_URL+"pro-friends.asp",
			   data: {act:"delete",id:userId},
			   success: function(msg){
					if (sTextToAddBefore != null)
					{
						obj.innerHTML = sTextToAddBefore + (sUserName!=null?"A":"a")+"dd to friends";
					} else {
						obj.innerHTML = "<div class=\"nav nav2\"></div>add to friends";
					}
			   }
		   });

		},true);
				

	} else {
	   $.ajax({
		   type: "POST",
		   url: ROOT_URL+"pro-friends.asp",
		   data: {act:"sendRequest",id:userId},
		   success: function(msg){
				MessageBox(396,105,"Got it! close this message","<span>A friend request has been sent to <span class=\"color3\">~</span>"+sUser+"</span>",true,null,true);
				if (sTextToAddBefore != null)
				{
					obj.innerHTML = sTextToAddBefore + (sUserName!=null?"A":"a")+"waiting confirmation";
					container.onclick=container.onmouseover=null;
				} else {
					obj.innerHTML = "<div class=\"nav nav2\"></div>awaiting confirmation";
				}
		   }
	   });
	}
}

function AddFriendNov(Params,fFunc) {
	if (!protectMembers()) return false;

	Params.status = Params.status.toLowerCase();
	var Act = null;
	switch (Params.status)
	{
		case "add to friends": Act = "sendRequest"; break;
		case "confirm friend": Act = "confirmFriend"; break;
		case "remove friend": Act = "delete"; break;
	}

	if (Act != null)
	{
	   $.ajax({
		   type: "POST",
		   url: ROOT_URL+"pro-friends.asp",
		   data: {act:Act,id:Params.UserId},
		   success: function(msg){
				if (fFunc)
					fFunc(Params);
		   }
	   });
	}

}
