var friend = {

	hideBox: function() {
		var hide = true;
		$('.friendInvitation').each(function() {
	        if ($(this).css('display') != 'none') 
	        {
	        	hide = false;
	        }
	    });
	    
	    if (hide == true)
	    {
	    	$('#friendInvList').css('display', 'none');
	    }
		
		
	},
	
	accept: function(id) {

		$.post("/ajax/friend.php", { 
									'do': 'accept',
									'user': id
									},
						function(data){
							$('#friendInv'+id).text(t('Invitation accepted'));
							setTimeout(function(){
								$('#friendInv'+id).fadeOut('slow', function(){
									friend.hideBox();
								});
							}, 2000);
						},
				"json");
	},
	
	reject: function(id) {

		$.post("/ajax/friend.php", { 
									'do': 'deny',
									'user': id
									},
						function(data){
							$('#friendInv'+id).text(t('Invitation rejected'));
							setTimeout(function(){
								$('#friendInv'+id).fadeOut('slow', function(){
									friend.hideBox();
								});
							}, 2000);
						},
				"json");
	}
	
};