
function setFriend (userId, userLogin) {
	$.ajax ({
		url:  baseURI + '/users/ajax_set_friend/' + userId + '?scode=' + scode,
		type: 'GET',
		dataType: 'xml',
		error: function () { new Error ('Произошла ошибка!'); },
		success: function (xml) {
			var result = $(xml).find('result').text();
			
			if (result == '1') {
				$('#user_friend').find('img').attr('src',  baseURI + '/images/big-plus-red.png');
				$('#mail_friend').find('a').attr('href',  baseURI + '/messages/write/' + userLogin);
				$('#mail_friend').find('img').attr('src',  baseURI + '/images/big-send-mail-active.png');
			} else if (result == '-1') {
				$('#user_friend').find('img').attr('src',  baseURI + '/images/big-plus-green.png');
				$('#mail_friend').find('img').attr('src',  baseURI + '/images/big-send-mail-not-active.png');
				$('#mail_friend').find('a').attr('href', '');
			} else {
				new Error ('Произошла ошибка!');
				return;
			}
		}
	});
}

function voteUser (userId, isGood) {
	$.ajax ({
		url:  baseURI + '/users/ajax_user_rating/' + userId + '/' + isGood + '?scode=' + scode,
		type: 'GET',
		dataType: 'xml',
		error: function () { new Error ('Произошла ошибка!'); },
		success: function (xml) {
			
			var errorMsg = $(xml).find('error').text();
			
			if (errorMsg != '') {
				new Error (errorMsg);
			} else {
				$('#rating_number').text ($(xml).find('rating').text());
				
				$('#arrow_up_rating').click(function () {
					new Error ('Нельзя голосовать повторно!');
				});
				$('#arrow_down_rating').click(function () {
					new Error ('Нельзя голосовать повторно!');
				});
				
				if (isGood == 1) {
					$('#arrow_down_rating').css({color: '#cecece'});
				} else {
					$('#arrow_up_rating').css({color: '#cecece'});
				}
				
				new Message ('Вы проголосовали за пользователя!');
			}
		}
	});
}