// Azione
var UserActions = {
	// Overlay
	modified: new Array(),

	generic_message_on: function (t_pid, t_nick, aaa_fn, t_gender, t_avatar) {
		// OverlayManager.show('sendmessage', 'message', aaa_fn, t_nick, t_pid);
		OverlayManager.show('send', t_pid, t_nick, aaa_fn, t_gender, t_avatar);
	},
	
	friendlist_add_on: function (t_pid, t_nick, aaa_fn, elId) {
		OverlayManager.show('addfriend', t_pid, t_nick, aaa_fn, elId);
	},
	
	friendlist_remove_on: function (t_pid, t_nick, aaa_fn, elId) {
		OverlayManager.show('removefriend', t_pid, t_nick, aaa_fn, elId);
	},
	
	blacklist_add_on: function (t_pid, t_nick, aaa_fn, elId, pType) {
		OverlayManager.show('addblacklist', t_pid, t_nick, aaa_fn, elId, pType);
	},
	
	blacklist_remove_on: function (t_pid, t_nick, aaa_fn, elId, pType) {
		OverlayManager.show('removeblacklist', t_pid, t_nick, aaa_fn, elId, pType);
	},
	
	abusereport_on: function (t_pid, t_nick, abuse_id, id, abuse_type) {
		OverlayManager.show('abusereport', t_pid, t_nick, abuse_id, id, abuse_type);
	},
	
	kiss_on: function (t_pid, t_nick, aaa_fn, t_gender, t_avatar) {
		OverlayManager.show('kiss', t_pid, t_nick, aaa_fn, t_gender, t_avatar);
	},
	
	chat_on: function (t_pid, t_nick, aaa_fn) {
		// Utilities.openChat(profile_id, application_id);
		var callback = {
		    success : function (o) {				
				var res = Utilities.parseHybridResponse(o.responseText);
			
				 if(res.result == 'LP') {
						
					 OverlayConfiguration.genericMessage.overlay.hide();
					 if(res.enc_profile_id) OverlayManager.show('lp', res.lp, res.enc_profile_id);
						else OverlayManager.show('lp', res.lp);
				 }
				 else if(!res[0]){
					 
					 Utilities.openChat(t_pid, t_nick, aaa_fn);
				 }
				 else if(res[0].result == "KO"){
					 
					 OverlayConfiguration.genericMessage.showPlain('', res[1], 'rosso', 300); 			
				 }
		    },
		    failure : function (o) { }
		};

		var actionString = 't_pid=' + t_pid + '&t_nick=' + t_nick + '&aaa_fn=' + aaa_fn;
		YAHOO.util.Connect.asyncRequest('POST', 'http://' + conf.baseUrl + '/gui_manager/chat', callback, actionString);	
	},
	
	generic_message_off: function () {
		UserActions._showNotAllowed('Invia messaggio');
	},
	
	friendlist_add_off: function () {
		UserActions._showNotAllowed('Aggiungi un amico');
	},
	
	friendlist_remove_off: function () {
		UserActions._showNotAllowed('Togli un amico dalla tua lista');
	},
	
	abusereport_off: function () {
		UserActions._showNotAllowed('Segnala abuso');
	},
	
	kiss_off: function () {
		UserActions._showNotAllowed('Bacia');
	},
	
	chat_off: function (t_pid, t_nick, aaa_fn) {
		// OverlayManager.show('genericMessage', 'Chatta', 'Non ti č permesso utilizzare questa funzionalitą', 'rosso');
		UserActions._showNotAllowed('Chatta');
	},
	
	_showNotAllowed: function (action) {
		OverlayManager.show('genericMessage', action, 'Non ti č permesso utilizzare questa funzionalitą', 'rosso');
	},
	
	// Notification panel
	acceptChat: function (nid, tpid, tnick) {
		Utilities.openChat(tpid, tnick);
		DwrManager.consumeChatRequest(nid);
		notifies.removeNotify(nid, "chat");
	},
	
	rejectChat: function (nid) {
		DwrManager.consumeChatRequest(nid);
		notifies.removeNotify(nid, "chat");
	},
	
	readMessage: function (nid, t_pid) {
		DwrManager.consumeMessageRequest(nid);
		// location.href = Utilities.getUserUrl(my_profile.nick) + '/message/inbox';
		location.href = Utilities.getUserUrl(my_profile.nick) + '/message/chronology/' + t_pid + '/1';		
	},
	
	deleteMessage: function (nid) {
		alert('Cancella messaggio');
		DwrManager.consumeMessageRequest(nid);
	},
	
	readKiss: function (nid) {
		DwrManager.consumeMessageRequest(nid);
		location.href = Utilities.getUserUrl(my_profile.nick) + '/message/kisses';	
	},
	
	rejectKiss: function (nid) {
		alert('Bacio rifiutato');
		DwrManager.consumeKissRequest(nid);
	}
};