var RemoveFriendOverlay = function (id) {
	this.overlay = new Overlay(id, {	width: '350px',
										draggable: true,
										visible: false,
										zindex: 1000,
										fixedcenter: true,
										constraintoviewport: true
	});

	// Identifica un overlay a pił passi
	this.overlay.stepOverlay = true;
	
	this.show = function (anchorShow, text, anchorHide) {
		this.overlay.show(null, this.overlay.generateOverlay(text), null);
	};
	
	this.stepOne = function (overlay, t_pid, t_nick, aaa_fn, iconId, pType) {
		this.overlay.scriptUrl = "http://" + conf.baseUrl + "/overlay_manager/rimuovi_amico";
		var actionString = 'overlay=' + overlay + '&t_profile_id=' + t_pid + '&t_nick=' + t_nick + '&aaa_fn=' + aaa_fn + (iconId ? '&iconId=' + iconId : '') + (pType ? '&pType=' + pType : '');
		
		// definisce cosa fare nello step 2, in realtą chiama step 2
		this.overlay.setContentByAjax(actionString, null, null, this);		
	};
	
	this.stepTwo = function (t_pid, t_nick, iconId, pType) {
		this.overlay.scriptUrl = "http://" + conf.baseUrl + "/gui_manager/rimuovi_amico";
		var actionString = 't_profile_id=' + t_pid + '&t_nick=' + t_nick + (iconId ? '&element_id=' + iconId : '') + (pType ? '&pType=' + pType : '');
		
		this.show(null, this.overlay.loaderContent.body, null);
		this.overlay.getResultByAjax(actionString, this, this.setBodyByResult);
	};
	
	this.setBodyByResult = function (obj, pResult) {
		var responseText = pResult.header + pResult.body;
		var data = pResult.params;
		var success = obj.overlay.isSuccessResponse(pResult.result);
		
		UserActions.modified[data.t_profile_id] = success;
		obj.show(null, responseText, null);
		
		if(success) {
			obj.removeFriend(data.t_profile_id);
			if(data.pType == 'video') obj.changeForVideo(data.t_profile_id, data.t_nick, data.aaa_fn, data.element_id, data.pType);
		}
	};
	
	this.changeForVideo = function (t_pid, t_nick, aaa_fn, elId, pType) {
		YAHOO.util.Dom.get(elId).innerHTML = '<a title="Aggiungi alla buddylist" class="aggiungi" href="javascript:UserActions[\'friendlist_add_on\'](\'' + t_pid + '\', \'' + t_nick + '\', \'' + aaa_fn + '\', \'' + elId + '\', \'' + pType + '\');"><span></span></a>';
	};
	
	this.removeFriend = function (t_pid) {
		var page = location.href.split('/');		
		if(page[page.length - 2] == 'my_friends' || page[page.length - 2] == 'my_blacklist')
			try {
				var box = YAHOO.util.Dom.get('utente_' + t_pid);
				var parent = box.parentNode;
				parent.removeChild(box);
			} catch (e) {}
	};
};