window.__Relation = {
	userID	: 0,

	req	: new Ajax('', {
		method: 'get',
		autoCancel : true
	}),

	set	: function(type, current, control) {
		this.req.url = '/js/user/' + ( current ? 'un' : '' ) + type + '/' + this.userID + '?DEBUG_MODE=0';
		this.req.setOptions({
			onComplete : function(response) {
				if ( 1 == response ) {
					$(control).removeEvents().setStyle('color', '#AAA').removeProperty('href').removeProperty('onclick');

					var mess = $E('.__message', control.getParent());
					$ES('span', mess).setStyle('display', 'none');

					$ES('span._st_'+(current?'un':'')+type, mess).setStyle('display', 'inline');

					if ( mess.hasClass('popup') ) {
						mess.setPosition = function() {
							var coords = $(control).getCoordinates();
							delete coords.width, coords.height;
							coords.top += 20;
							this.setStyles(coords);
						}

						Float.toggle(mess.id);
					} else {
						mess.setStyle('display', 'block');
					}
				}

				this.$events.onComplete = [];
			}
		});
		this.req.request();
		return false;
	},

	setForNews	: function(type, userID, control) {
		this.req.url = '/js/user/' + type + '/' + userID + '?DEBUG_MODE=0';
		this.req.setOptions({
			onComplete : function(response) {
				if ( 1 == response ) {
					$(control).getParent().getParent().getParent().getParent().remove();
				}

				this.$events.onComplete = [];
			}
		});
		this.req.request();

		return false;
	},


	groupAccept	: function(type, group, control) {
		this.req.url = '/js/group_confirm/' + type + '/' + group + '?DEBUG_MODE=0';
		this.req.setOptions({
			onComplete : function(response) {
				if ( 1 == response ) {
					$(control).getParent().getParent().getParent().getParent().remove();
				}

				this.$events.onComplete = [];
			}
		});
		this.req.request();

		return false;
	},


	groupApprove	: function(type, group, user, control) {
		this.req.url = '/js/group_confirm/' + type + '/' + group + '/' + user + '?DEBUG_MODE=0';
		this.req.setOptions({
			onComplete : function(response) {
				if ( 1 == response ) {
					$(control).getParent().getParent().getParent().getParent().remove();
				}

				this.$events.onComplete = [];
			}
		});
		this.req.request();

		return false;
	}
}