var AddBlacklistOverlay = 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.wrapper = function (overlay, args) {
		var params = {
			overlay: overlay,
			aaa_fn: args[2],
			t_nick: args[1],
			t_profile_id: args[0],
			iconId: args[3]
		};
		
		this.stepOne(params);
	}
	
	this.show = function (anchorShow, text, anchorHide) {
		this.overlay.show(null, this.overlay.generateOverlay(text), null);
	};
	
	this.stepOne = function (params) {
		this.overlay.scriptUrl = "http://" + conf.baseUrl + "/overlay_manager/aggiungi_blacklist";
		this.overlay.setContentByAjax(Utilities.createActionString(params), null, null, this);
	};
	
	this.stepTwo = function (t_pid, t_nick, iconId, pType) {
		this.overlay.scriptUrl = "http://" + conf.baseUrl + "/gui_manager/aggiungi_blacklist";
		
		var params = {
			t_profile_id: t_pid,
			t_nick: t_nick,
			iconId: iconId
		};
		
		this.show(null, this.overlay.loaderContent.body, null);
		this.overlay.getResultByAjax(Utilities.createActionString(params), this, this.setBodyByResult);
	};
	
	this.setBodyByResult = function (obj, pResult) {
		var data = pResult.params;
		var responseText = pResult.header + pResult.body;
		
		UserActions.modified[data.t_profile_id] = obj.overlay.isSuccessResponse(pResult.result);
		obj.show(null, responseText, null);
		
		if(obj.overlay.isSuccessResponse(pResult.result) && YAHOO.util.Dom.get(data.iconId)) obj.change(data.t_profile_id, data.t_nick, 'buddy.add', data.iconId, data.pType);
	};
	
	this.change = function (t_pid, t_nick, aaa_fn, elId, pType) {
		YAHOO.util.Dom.get(elId).innerHTML = '<a id="removeBlackAction" title="Togli dalla blacklist" class="unlock" href="javascript:UserActions[\'blacklist_remove_on\'](\'' + t_pid + '\', \'' + t_nick + '\', \'' + aaa_fn + '\', \'' + elId + '\', \'' + pType + '\');"><span></span></a>';				
	};
};

OverlayConfiguration.addblacklist = new AddBlacklistOverlay('textOverlay');
OverlayManager.addblacklist = function (args) {
	OverlayConfiguration.addblacklist.wrapper('addblacklist', args);
};