
function makeprivate(id)
{
	$.ajax({
		url: '/link-makeprivate/id,' + id.toString(),
		type: 'GET',
		dataType: 'html',
		error: function() {
			alert('Wystąpił błąd. Spróbuj ponownie.');
		},
		success: function(html) {
			$('#st_publ_' + id.toString()).css('display', 'none');
			$('#st_priv_' + id.toString()).css('display', 'inline');
		}
	});
}
function makepublic(id)
{
	$.ajax({
		url: '/link-makepublic/id,' + id.toString(),
		type: 'GET',
		dataType: 'html',
		error: function() {
			alert('Wystąpił błąd. Spróbuj ponownie.');
		},
		success: function(html) {
			$('#st_publ_' + id.toString()).css('display', 'inline');
			$('#st_priv_' + id.toString()).css('display', 'none');
		}
	});
}

function remove(id,t)
{
	if(confirm('Czy na pewno chcesz usunąć ten link?'))
	{
		$.ajax({
			url: '/link-remove/id,' + id.toString(),
			type: 'GET',
			dataType: 'html',
			error: function () {
				alert('Wystąpił błąd. Spróbuj ponownie.');
			},
			success: function() {
				var refcount = parseInt($('#refcount_' + id.toString()).text());
				if(refcount <= 1)
				{
					if(t == 0)
						window.location.href = '/link-saved';
					else
						$('#page_' + id.toString()).css('display', 'none');
				}
				else if(t == 2)
					$('#page_' + id.toString()).css('display', 'none');
				else
					window.location.reload();
			}
		});
	}
}

function addfriend(login)
{
	$.ajax({
		url: '/profile-addfriend/user,' + login,
		type: 'GET',
		dataType: 'html',
		error: function() {
			alert('Wystąpił błąd. Spróbuj ponownie.');
		},
		success: function(html) {
			$('#friendstatus').html(html);
		}
	});
}
function removefriend(login)
{
	$.ajax({
		url: '/profile-removefriend/user,' + login,
		type: 'GET',
		dataType: 'html',
		error: function() {
			alert('Wystąpił błąd. Spróbuj ponownie.');
		},
		success: function(html) {
			$('#friendstatus').html(html);
		}
	});
}


