

var friendId = 0;
var friendName = '';

function do_request_friendship()
{
	var pars = 'friendId='+friendId;
	new Ajax.Request(
		'/actions/request_friendship.php', 
		{
			parameters: pars,
			method: 'post',
			onComplete: function() 
			{
				openAlertDialog('Sådär, meddelandet är skickat. Så fort '+js2html(friendName)+' svarat så får du ett meddelande om att ni är vänner!');
			}
		});
	return false;
}

	
function request_friendship(theFriendId, theFriendName)
{
	friendId = theFriendId;
	friendName = theFriendName;
	openYesNoDialogQuestionmark('<p><strong>Bekräfta vänskap</strong> <br />Vill du bli vän med '+js2html(theFriendName)+'?</p>', do_request_friendship, null);
	return false;
} 



function do_break_friendship()
{
	var pars = 'friendId='+friendId;
	new Ajax.Request(
		'/actions/break_friendship.php', 
		{
			parameters: pars,
			method: 'post',
			onComplete: function() 
			{
				location.href = location.href;
			}
		});
	return false;
}



function break_friendship(theFriendId, theFriendName)
{
	friendId = theFriendId;
	openYesNoDialogQuestionmark('<p>Är du säker på att du inte vill vara vän med '+js2html(theFriendName)+' längre?', do_break_friendship, null);
	return false;
}


function confirm_friendship(theFriendId, theUserName)
{
	var pars = 'friendId='+theFriendId;
	new Ajax.Request(
		'/actions/confirm_friendship.php', 
		{
			parameters: pars,
			method: 'post',
			onComplete: function() 
			{
				location.href= '/'+theUserName+'/handelser';
			}
		});
	return false;
}


function deny_friendship(theFriendId, theUserName)
{
	var pars = 'friendId='+theFriendId;
	new Ajax.Request(
		'/actions/deny_friendship.php', 
		{
			parameters: pars,
			method: 'post',
			onComplete: function() 
			{
				location.href= '/'+theUserName+'/handelser';
			}
		});
	return false;
}


