/**
 * @author Another
 */
/**
 * Function that send simple requests to server
 */
function SimpleRequest ( request, url, fn )
{						
	$.ajax({
		type: "GET",
		url: url,
		data: request,
		dataType: 'json',
		error: function (XMLHttpRequest, textStatus, errorThrown){
			alert('Ошибка связи или ошибка доступа.')
		},
		success: fn
	});
    return true;
}

function DeleteAward( id )
{
	if (!confirm('Are you sure want delete this award?'))
		return;
	
	var request = 'request=delete_award&id='+id;
	SimpleRequest( request, '/proto.php', function ( msg ) {
		document.location.href=document.location.href;
	});
}

function SearchUser()
{
	var userName = $('#searchName').val();
		userName = userName.slice(1);
		
	document.location.href = '/user/' + userName + '/'; 
}

/**
 * Add manage links to awards
 */
function ManageAwards ()
{
$('.award').each (function () {
		
		var id = $(this).attr('title');
		$(this).aqTip('<a style="color: RED; font-weight: bold;" onclick="DeleteAward('+id+')">Delete</a>', { marginX: -20})
				
	}		
	);
}
