// static
void LLFloaterAvatarInfo::showFromProfile(const LLUUID &avatar_id, LLRect rect)
{
	if (avatar_id.isNull())
	{
		return;
	}

	LLFloaterAvatarInfo *floater;
	if (gAvatarInfoInstances.checkData(avatar_id))
	{
		// ...bring that window to front
		floater = gAvatarInfoInstances.getData(avatar_id);
	}
	else
	{
		floater =  new LLFloaterAvatarInfo("avatarinfo", FAI_RECT, 
										   avatar_id);
		floater->translate(rect.mLeft - floater->getRect().mLeft + 16,
						   rect.mTop - floater->getRect().mTop - 16);
		floater->mPanelAvatarp->setAvatarID(avatar_id, LLStringUtil::null, ONLINE_STATUS_NO);
	}
	if (floater)
	{
		floater->open();
	}
}
static void on_avatar_name_show_profile(const LLUUID& agent_id, const LLAvatarName& av_name, bool web)
{
	if (gSavedSettings.getString("WebProfileURL").empty() || !(web || gSavedSettings.getBOOL("UseWebProfiles")))
	{
		LLFloaterAvatarInfo* floater = LLFloaterAvatarInfo::getInstance(agent_id);
		if(!floater)
		{
			floater = new LLFloaterAvatarInfo(av_name.getCompleteName()+" - "+LLTrans::getString("Command_Profile_Label"), agent_id);
			floater->center();
		}

		// ...bring that window to front
		floater->open();	/*Flawfinder: ignore*/
	}
	else
	{
		std::string username = av_name.mUsername;
		if (username.empty())
		{
			username = LLCacheName::buildUsername(av_name.mDisplayName);
		}

		llinfos << "opening web profile for " << username << llendl;
		std::string url = getProfileURL(username);

		// PROFILES: open in webkit window
		LLFloaterWebContent::Params p;
		p.url(url).
			id(agent_id.asString());
		LLFloaterWebProfile::showInstance(get_profile_floater_name(agent_id), p);
	}
}
// static
void LLFloaterAvatarInfo::callbackLoadAvatarName(const LLUUID& id,
												 const LLAvatarName& avatar_name)
{
	LLFloaterAvatarInfo *floater = gAvatarInfoInstances.getIfThere(id);

	if (floater)
	{
		// Build a new title including the avatar name.
		// Always show "Display Name [Legacy Name]" for security reasons
		std::ostringstream title;
		title << avatar_name.getNames() << " - " << floater->getTitle();
		floater->setTitle(title.str());
	}
}
// static
void LLFloaterAvatarInfo::callbackLoadAvatarName(const LLUUID& id,
										  const LLAvatarName& av_name)
{
	LLFloaterAvatarInfo *floater = gAvatarInfoInstances.getIfThere(id);

	if (floater)
	{
		// Build a new title including the avatar name.
		std::ostringstream title;
		//title << first << " " << last << " - " << floater->getTitle();
		title << av_name.getCompleteName()<< " - " << floater->getTitle();
		floater->setTitle(title.str());
	}
}
static void on_avatar_name_show_profile(const LLUUID& agent_id, const LLAvatarName& av_name, bool web)
{
	static LLCachedControl<std::string> web_profile_url("WebProfileURL");
	static LLCachedControl<bool> use_web_profiles("UseWebProfiles");

	std::string wpu = web_profile_url;
	if (wpu.empty() || !(web || use_web_profiles))
	{
		LLFloaterAvatarInfo* floater = LLFloaterAvatarInfo::getInstance(agent_id);
		if(!floater)
		{
			floater = new LLFloaterAvatarInfo(av_name.getCompleteName()+" - "+LLTrans::getString("Command_Profile_Label"), agent_id);

			// I'd rather have it remember its position ...
			static LLCachedControl<bool> floater_centers("RtyFloaterProfileCenters");
			if(floater_centers)
			{
				floater->center();
			}
			else
			{
				floater->center_right();
			}
		}

		// ...bring that window to front
		floater->open();	/*Flawfinder: ignore*/
	}
	else
	{
		std::string url = getProfileURL(av_name.getAccountName());

		// PROFILES: open in webkit window
		LLFloaterWebContent::Params p;
		p.url(url).id(agent_id.asString());
		LLFloaterWebProfile::showInstance(get_profile_floater_name(agent_id), p);
	}
}
// static
LLFloaterAvatarInfo* LLFloaterAvatarInfo::show(const LLUUID &avatar_id)
{
	if (avatar_id.isNull())
	{
		return NULL;
	}

	LLFloaterAvatarInfo *floater;
	if (gAvatarInfoInstances.checkData(avatar_id))
	{
		// ...bring that window to front
		floater = gAvatarInfoInstances.getData(avatar_id);
		floater->open();	/*Flawfinder: ignore*/
	}
	else
	{
		floater =  new LLFloaterAvatarInfo("avatarinfo", FAI_RECT, 
			avatar_id );
		floater->center();
		floater->open();	/*Flawfinder: ignore*/
	}
	return floater;
}