diff --git a/indra/llui/lluicolortable.cpp b/indra/llui/lluicolortable.cpp
index f1e3000547d3be73c37d4240e66cb2a8e8687ba7..9be33483d0b0762d660122963057214d3f54941b 100644
--- a/indra/llui/lluicolortable.cpp
+++ b/indra/llui/lluicolortable.cpp
@@ -192,19 +192,27 @@ void LLUIColorTable::clear()
 LLUIColor LLUIColorTable::getColor(const std::string& name, const LLColor4& default_color) const
 {
 	string_color_map_t::const_iterator iter = mUserSetColors.find(name);
+	
 	if(iter != mUserSetColors.end())
 	{
 		return LLUIColor(&iter->second);
 	}
 
 	iter = mLoadedColors.find(name);
-	return (iter != mLoadedColors.end() ? LLUIColor(&iter->second) : LLUIColor(default_color));
+	
+	if(iter != mLoadedColors.end())
+	{
+		return LLUIColor(&iter->second);
+	}
+	
+	return  LLUIColor(default_color);
 }
 
 // update user color, loaded colors are parsed on initialization
 void LLUIColorTable::setColor(const std::string& name, const LLColor4& color)
 {
 	setColor(name, color, mUserSetColors);
+	setColor(name, color, mLoadedColors);
 }
 
 bool LLUIColorTable::loadFromSettings()
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 13c381edaec7d4a5fc0a81ac99e145bc37ac55f8..eb4e914e701cacc49b611b5c7daff75e98159d94 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -445,6 +445,7 @@ set(viewer_SOURCE_FILES
     llviewerassettype.cpp
     llvieweraudio.cpp
     llviewercamera.cpp
+	llviewerchat.cpp
     llviewercontrol.cpp
     llviewercontrollistener.cpp
     llviewerdisplay.cpp
@@ -942,6 +943,7 @@ set(viewer_HEADER_FILES
     llvieweraudio.h
     llviewerbuild.h
     llviewercamera.h
+	llviewerchat.h
     llviewercontrol.h
     llviewercontrollistener.h
     llviewerdisplay.h
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index 2ccd6b7d350555d5fce84c7f03d6dd31d6a95cb0..cc014e3c2885b98b9f72462e69283e35608d73f8 100644
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -330,7 +330,7 @@ LLView* LLChatHistory::getHeader(const LLChat& chat)
 	return header;
 }
 
-void LLChatHistory::appendWidgetMessage(const LLChat& chat, LLStyle::Params& style_params)
+void LLChatHistory::appendWidgetMessage(const LLChat& chat)
 {
 	LLView* view = NULL;
 	std::string view_text;
@@ -370,7 +370,17 @@ void LLChatHistory::appendWidgetMessage(const LLChat& chat, LLStyle::Params& sty
 	appendWidget(p, view_text, false);
 
 	//Append the text message
+	
+	LLColor4 txt_color = LLUIColorTable::instance().getColor("White");
+	LLViewerChat::getChatColor(chat,txt_color);
+	LLFontGL* fontp = LLViewerChat::getChatFont();
+	
 	std::string message = chat.mText + '\n';
+	
+	LLStyle::Params style_params;
+	style_params.color(txt_color);
+	style_params.font(fontp);
+	
 	appendText(message, FALSE, style_params);
 
 	mLastFromName = chat.mFromName;
diff --git a/indra/newview/llchathistory.h b/indra/newview/llchathistory.h
index 3789ebff4e94273e56fd4c2de55c5a9747790ac4..891d9c6c77a5225343736c406c147a58ae80045d 100644
--- a/indra/newview/llchathistory.h
+++ b/indra/newview/llchathistory.h
@@ -34,7 +34,7 @@
 #define LLCHATHISTORY_H_
 
 #include "lltexteditor.h"
-#include "llchat.h"
+#include "llviewerchat.h"
 
 //Chat log widget allowing addition of a message as a widget 
 class LLChatHistory : public LLTextEditor
@@ -111,7 +111,7 @@ class LLChatHistory : public LLTextEditor
 		 * @param time time of a message.
 		 * @param message message itself.
 		 */
-		void appendWidgetMessage(const LLChat& chat, LLStyle::Params& style_params);
+		void appendWidgetMessage(const LLChat& chat);
 
 	private:
 		std::string mLastFromName;
diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp
index 63b9fd8e66c54c70e78ad822b7f9bf5488156869..d2e3247250bc15a100c9f973483bc4ddcd95858d 100644
--- a/indra/newview/llchatitemscontainerctrl.cpp
+++ b/indra/newview/llchatitemscontainerctrl.cpp
@@ -120,10 +120,10 @@ std::string LLNearbyChatToastPanel::appendTime()
 
 
 
-void	LLNearbyChatToastPanel::addText		(const std::string& message)
+void	LLNearbyChatToastPanel::addText	(const std::string& message , const LLStyle::Params& input_params)
 {
 	LLChatMsgBox* msg_text = getChild<LLChatMsgBox>("msg_text", false);
-	msg_text->addText(message);
+	msg_text->addText(message , input_params);
 	mMessages.push_back(message);
 }
 
@@ -134,9 +134,34 @@ void LLNearbyChatToastPanel::init(LLSD& notification)
 	mText = notification["message"].asString();		// UTF-8 line of text
 	mFromName = notification["from"].asString();	// agent or object name
 	mFromID = notification["from_id"].asUUID();		// agent id or object id
+	
 	int sType = notification["source"].asInteger();
     mSourceType = (EChatSourceType)sType;
-
+	
+	std::string color_name = notification["text_color"].asString();
+	
+	mTextColor = LLUIColorTable::instance().getColor(color_name);
+	mTextColor.mV[VALPHA] =notification["color_alpha"].asReal();
+	
+	S32 font_size = notification["font_size"].asInteger();
+	switch(font_size)
+	{
+		case 0:
+			mFont = LLFontGL::getFontSansSerifSmall();
+			break;
+		default:
+		case 1:
+			mFont = LLFontGL::getFontSansSerif();
+			break;
+		case 2:
+			mFont = LLFontGL::getFontSansSerifBig();
+			break;
+	}
+	
+	LLStyle::Params style_params;
+	style_params.color(mTextColor);
+	style_params.font(mFont);
+	
 	std::string str_sender;
 
 	if(gAgentID != mFromID)
@@ -144,13 +169,13 @@ void LLNearbyChatToastPanel::init(LLSD& notification)
 	else
 		str_sender = LLTrans::getString("You");;
 
-	caption->getChild<LLTextBox>("sender_name", false)->setText(str_sender);
+	caption->getChild<LLTextBox>("sender_name", false)->setText(str_sender , style_params);
 	
-	caption->getChild<LLTextBox>("msg_time", false)->setText(appendTime());
+	caption->getChild<LLTextBox>("msg_time", false)->setText(appendTime() , style_params );
 
 
 	LLChatMsgBox* msg_text = getChild<LLChatMsgBox>("msg_text", false);
-	msg_text->setText(mText);
+	msg_text->setText(mText, style_params);
 
 	LLUICtrl* msg_inspector = caption->getChild<LLUICtrl>("msg_inspector");
 	if(mSourceType != CHAT_SOURCE_AGENT)
@@ -171,7 +196,15 @@ void	LLNearbyChatToastPanel::setMessage	(const LLChat& chat_msg)
 	notification["from_id"] = chat_msg.mFromID;
 	notification["time"] = chat_msg.mTime;
 	notification["source"] = (S32)chat_msg.mSourceType;
-
+	
+	std::string r_color_name="White";
+	F32 r_color_alpha = 1.0f; 
+	LLViewerChat::getChatColor( chat_msg, r_color_name, r_color_alpha);
+	
+	notification["text_color"] = r_color_name;
+	notification["color_alpha"] = r_color_alpha;
+	
+	notification["font_size"] = (S32)LLViewerChat::getChatFontSize() ;
 	init(notification);
 
 }
@@ -201,11 +234,17 @@ void	LLNearbyChatToastPanel::setWidth(S32 width)
 	text_box->reshape(width - msg_left_offset - msg_right_offset,100/*its not magic number, we just need any number*/);
 
 	LLChatMsgBox* msg_text = getChild<LLChatMsgBox>("msg_text", false);
+	
+	LLStyle::Params style_params;
+	style_params.color(mTextColor);
+	style_params.font(mFont);
+	
+	
 	if(mText.length())
-		msg_text->setText(mText);
+		msg_text->setText(mText, style_params);
 	
 	for(size_t i=0;i<mMessages.size();++i)
-		msg_text->addText(mMessages[i]);
+		msg_text->addText(mMessages[i] , style_params);
 
 	setRect(LLRect(getRect().mLeft, getRect().mTop, getRect().mLeft + width	, getRect().mBottom));
 	snapToMessageHeight	();
diff --git a/indra/newview/llchatitemscontainerctrl.h b/indra/newview/llchatitemscontainerctrl.h
index 8fb045b6d912f7bac2c2eeba3513093219730977..a65bfedd0964f61786e2a2539d4beeaab7e672ee 100644
--- a/indra/newview/llchatitemscontainerctrl.h
+++ b/indra/newview/llchatitemscontainerctrl.h
@@ -36,7 +36,7 @@
 #include "llpanel.h"
 #include "llscrollbar.h"
 #include "string"
-#include "llchat.h"
+#include "llviewerchat.h"
 #include "lltoastpanel.h"
 
 typedef enum e_show_item_header
@@ -59,7 +59,7 @@ class LLNearbyChatToastPanel: public LLToastPanelBase
 
 	const LLUUID& getFromID() const { return mFromID;}
 	
-	void	addText		(const std::string& message);
+	void	addText		(const std::string& message ,  const LLStyle::Params& input_params = LLStyle::Params());
 	void	setMessage	(const LLChat& msg);
 	void	setWidth		(S32 width);
 	void	snapToMessageHeight	();
@@ -89,6 +89,8 @@ class LLNearbyChatToastPanel: public LLToastPanelBase
 	std::string		mFromName;	// agent or object name
 	LLUUID			mFromID;	// agent id or object id
 	EChatSourceType	mSourceType;
+	LLColor4        mTextColor;
+	LLFontGL*       mFont;
 
 
 	std::vector<std::string> mMessages;
diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp
index 5a2331aa06abb072d6c83d704b3509865b5569f3..2504e1e9168e5cb852aaa097c34e0e4318aec40a 100644
--- a/indra/newview/llimfloater.cpp
+++ b/indra/newview/llimfloater.cpp
@@ -463,7 +463,7 @@ void LLIMFloater::updateMessages()
 
 	if (messages.size())
 	{
-		LLUIColor chat_color = LLUIColorTable::instance().getColor("IMChatColor");
+//		LLUIColor chat_color = LLUIColorTable::instance().getColor("IMChatColor");
 
 		std::ostringstream message;
 		std::list<LLSD>::const_reverse_iterator iter = messages.rbegin();
@@ -476,14 +476,11 @@ void LLIMFloater::updateMessages()
 			LLUUID from_id = msg["from_id"].asUUID();
 			std::string from = from_id != gAgentID ? msg["from"].asString() : LLTrans::getString("You");
 			std::string message = msg["message"].asString();
-			LLStyle::Params style_params;
-			style_params.color(chat_color);
 
 			LLChat chat(message);
 			chat.mFromID = from_id;
 			chat.mFromName = from;
-
-			mChatHistory->appendWidgetMessage(chat, style_params);
+			mChatHistory->appendWidgetMessage(chat);
 
 			mLastMessageIndex = msg["index"].asInteger();
 		}
diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp
index ac806d7106a7aaa01d4422d0dc16d357d99f8130..85db69174d9a97edace9e453bed0b1730eebd5b0 100644
--- a/indra/newview/llnearbychat.cpp
+++ b/indra/newview/llnearbychat.cpp
@@ -132,120 +132,31 @@ void    LLNearbyChat::applySavedVariables()
 	}
 }
 
-LLColor4 nearbychat_get_text_color(const LLChat& chat)
-{
-	LLColor4 text_color;
-
-	if(chat.mMuted)
-	{
-		text_color.setVec(0.8f, 0.8f, 0.8f, 1.f);
-	}
-	else
-	{
-		switch(chat.mSourceType)
-		{
-		case CHAT_SOURCE_SYSTEM:
-			text_color = LLUIColorTable::instance().getColor("SystemChatColor"); 
-			break;
-		case CHAT_SOURCE_AGENT:
-		    if (chat.mFromID.isNull())
-			{
-				text_color = LLUIColorTable::instance().getColor("SystemChatColor");
-			}
-			else
-			{
-				if(gAgentID == chat.mFromID)
-				{
-					text_color = LLUIColorTable::instance().getColor("UserChatColor");
-				}
-				else
-				{
-					text_color = LLUIColorTable::instance().getColor("AgentChatColor");
-				}
-			}
-			break;
-		case CHAT_SOURCE_OBJECT:
-			if (chat.mChatType == CHAT_TYPE_DEBUG_MSG)
-			{
-				text_color = LLUIColorTable::instance().getColor("ScriptErrorColor");
-			}
-			else if ( chat.mChatType == CHAT_TYPE_OWNER )
-			{
-				text_color = LLUIColorTable::instance().getColor("llOwnerSayChatColor");
-			}
-			else
-			{
-				text_color = LLUIColorTable::instance().getColor("ObjectChatColor");
-			}
-			break;
-		default:
-			text_color.setToWhite();
-		}
-
-		if (!chat.mPosAgent.isExactlyZero())
-		{
-			LLVector3 pos_agent = gAgent.getPositionAgent();
-			F32 distance = dist_vec(pos_agent, chat.mPosAgent);
-			if (distance > gAgent.getNearChatRadius())
-			{
-				// diminish far-off chat
-				text_color.mV[VALPHA] = 0.8f;
-			}
-		}
-	}
-
-	return text_color;
-}
-
-void LLNearbyChat::add_timestamped_line(const LLChat& chat, const LLColor4& color)
-{
-	S32 font_size = gSavedSettings.getS32("ChatFontSize");
-
-	const LLFontGL* fontp = NULL;
-	switch(font_size)
-	{
-	case 0:
-		fontp = LLFontGL::getFontSansSerifSmall();
-		break;
-	default:
-	case 1:
-		fontp = LLFontGL::getFontSansSerif();
-		break;
-	case 2:
-		fontp = LLFontGL::getFontSansSerifBig();
-		break;
-	}
-
-	LLStyle::Params style_params;
-	style_params.color(color);
-	style_params.font(fontp);
-	LLUUID uuid = chat.mFromID;
-	std::string from = chat.mFromName;
-	std::string message = chat.mText;
-	mChatHistory->appendWidgetMessage(chat, style_params);
-}
-
 void	LLNearbyChat::addMessage(const LLChat& chat)
 {
-	LLColor4 color = nearbychat_get_text_color(chat);
-	
 	if (chat.mChatType == CHAT_TYPE_DEBUG_MSG)
 	{
 		if(gSavedSettings.getBOOL("ShowScriptErrors") == FALSE)
 			return;
 		if (gSavedSettings.getS32("ShowScriptErrorsLocation")== 1)// show error in window //("ScriptErrorsAsChat"))
 		{
+
+			LLColor4 txt_color;
+
+			LLViewerChat::getChatColor(chat,txt_color);
+			
 			LLFloaterScriptDebug::addScriptLine(chat.mText,
 												chat.mFromName, 
-												color, 
+												txt_color, 
 												chat.mFromID);
 			return;
 		}
 	}
 	
-	// could flash the chat button in the status bar here. JC
 	if (!chat.mMuted)
-		add_timestamped_line(chat, color);
+	{
+		mChatHistory->appendWidgetMessage(chat);
+	}
 }
 
 void LLNearbyChat::onNearbySpeakers()
diff --git a/indra/newview/llnearbychat.h b/indra/newview/llnearbychat.h
index cb4654654a952562b21b252153de284759ad3516..3303c388afe631b72ee2774848ac9557b3c7ebb5 100644
--- a/indra/newview/llnearbychat.h
+++ b/indra/newview/llnearbychat.h
@@ -35,7 +35,7 @@
 
 #include "lldockablefloater.h"
 #include "llscrollbar.h"
-#include "llchat.h"
+#include "llviewerchat.h"
 
 class LLResizeBar;
 class LLChatHistory;
@@ -47,8 +47,7 @@ class LLNearbyChat: public LLDockableFloater
 	~LLNearbyChat();
 
 	BOOL	postBuild			();
-	void	addMessage			(const LLChat& message);
-	
+	void	addMessage			(const LLChat& message);	
 	void	onNearbyChatContextMenuItemClicked(const LLSD& userdata);
 	bool	onNearbyChatCheckContextMenuItem(const LLSD& userdata);
 
@@ -64,7 +63,6 @@ class LLNearbyChat: public LLDockableFloater
 	void	getAllowedRect		(LLRect& rect);
 
 	void	onNearbySpeakers	();
-	void	add_timestamped_line(const LLChat& chat, const LLColor4& color);
 	
 
 private:
diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp
index e10c506f0866a3f4185d0d3de8c10a782f99108e..d1cd92ad68b56b8eaa4619990c35414ec1ad1141 100644
--- a/indra/newview/llnearbychathandler.cpp
+++ b/indra/newview/llnearbychathandler.cpp
@@ -351,7 +351,14 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg)
 		notification["time"] = chat_msg.mTime;
 		notification["source"] = (S32)chat_msg.mSourceType;
 		notification["chat_type"] = (S32)chat_msg.mChatType;
-
+		
+		std::string r_color_name = "White";
+		F32 r_color_alpha = 1.0f; 
+		LLViewerChat::getChatColor( chat_msg, r_color_name, r_color_alpha);
+		
+		notification["text_color"] = r_color_name;
+		notification["color_alpha"] = r_color_alpha;
+		notification["font_size"] = (S32)LLViewerChat::getChatFontSize() ;
 		channel->addNotification(notification);	
 	}
 	
diff --git a/indra/newview/llnotificationtiphandler.cpp b/indra/newview/llnotificationtiphandler.cpp
index 823c92a94e377f8813dd28868b8b7f86462d1f29..60a27d51544dff805a151b0d6f29eaf923915f82 100644
--- a/indra/newview/llnotificationtiphandler.cpp
+++ b/indra/newview/llnotificationtiphandler.cpp
@@ -91,6 +91,7 @@ bool LLTipHandler::processNotification(const LLSD& notify)
 		if(nearby_chat)
 		{
 			LLChat chat_msg(notification->getMessage());
+			chat_msg.mSourceType = CHAT_SOURCE_SYSTEM;
 			nearby_chat->addMessage(chat_msg);
 
 			// don't show toast if Nearby Chat is opened
diff --git a/indra/newview/llviewerchat.cpp b/indra/newview/llviewerchat.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d65a060bbc12b0a79350a37388d0b7130d26f540
--- /dev/null
+++ b/indra/newview/llviewerchat.cpp
@@ -0,0 +1,203 @@
+/** 
+ * @file llviewerchat.cpp
+ * @brief Builds menus out of items.
+ *
+ * $LicenseInfo:firstyear=2002&license=viewergpl$
+ * 
+ * Copyright (c) 2002-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+#include "llviewerchat.h" 
+
+// newview includes
+#include "llagent.h" 	// gAgent		
+#include "lluicolortable.h"
+#include "llviewercontrol.h" // gSavedSettings
+
+// LLViewerChat
+
+//static 
+void LLViewerChat::getChatColor(const LLChat& chat, LLColor4& r_color)
+{
+	if(chat.mMuted)
+	{
+		r_color= LLUIColorTable::instance().getColor("LtGray");
+	}
+	else
+	{
+		switch(chat.mSourceType)
+		{
+			case CHAT_SOURCE_SYSTEM:
+				r_color = LLUIColorTable::instance().getColor("SystemChatColor"); 
+				break;
+			case CHAT_SOURCE_AGENT:
+				if (chat.mFromID.isNull())
+				{
+					r_color = LLUIColorTable::instance().getColor("SystemChatColor");
+				}
+				else
+				{
+					if(gAgentID == chat.mFromID)
+					{
+						r_color = LLUIColorTable::instance().getColor("UserChatColor");
+					}
+					else
+					{
+						r_color = LLUIColorTable::instance().getColor("AgentChatColor");
+					}
+				}
+				break;
+			case CHAT_SOURCE_OBJECT:
+				if (chat.mChatType == CHAT_TYPE_DEBUG_MSG)
+				{
+					r_color = LLUIColorTable::instance().getColor("ScriptErrorColor");
+				}
+				else if ( chat.mChatType == CHAT_TYPE_OWNER )
+				{
+					r_color = LLUIColorTable::instance().getColor("llOwnerSayChatColor");
+				}
+				else
+				{
+					r_color = LLUIColorTable::instance().getColor("ObjectChatColor");
+				}
+				break;
+			default:
+				r_color.setToWhite();
+		}
+		
+		if (!chat.mPosAgent.isExactlyZero())
+		{
+			LLVector3 pos_agent = gAgent.getPositionAgent();
+			F32 distance = dist_vec(pos_agent, chat.mPosAgent);
+			if (distance > gAgent.getNearChatRadius())
+			{
+				// diminish far-off chat
+				r_color.mV[VALPHA] = 0.8f;
+			}
+		}
+	}
+}
+
+
+//static 
+void LLViewerChat::getChatColor(const LLChat& chat, std::string& r_color_name, F32& r_color_alpha)
+{
+	if(chat.mMuted)
+	{
+		r_color_name = "LtGray";
+	}
+	else
+	{
+		switch(chat.mSourceType)
+		{
+			case CHAT_SOURCE_SYSTEM:
+				r_color_name = "SystemChatColor";
+				break;
+				
+			case CHAT_SOURCE_AGENT:
+				if (chat.mFromID.isNull())
+				{
+					r_color_name = "SystemChatColor";
+				}
+				else
+				{
+					if(gAgentID == chat.mFromID)
+					{
+						r_color_name = "UserChatColor";
+					}
+					else
+					{
+						r_color_name = "AgentChatColor";
+					}
+				}
+				break;
+				
+			case CHAT_SOURCE_OBJECT:
+				if (chat.mChatType == CHAT_TYPE_DEBUG_MSG)
+				{
+					r_color_name = "ScriptErrorColor";
+				}
+				else if ( chat.mChatType == CHAT_TYPE_OWNER )
+				{
+					r_color_name = "llOwnerSayChatColor";
+				}
+				else
+				{
+					r_color_name = "ObjectChatColor";
+				}
+				break;
+			default:
+				r_color_name = "White";
+		}
+		
+		if (!chat.mPosAgent.isExactlyZero())
+		{
+			LLVector3 pos_agent = gAgent.getPositionAgent();
+			F32 distance = dist_vec(pos_agent, chat.mPosAgent);
+			if (distance > gAgent.getNearChatRadius())
+			{
+				// diminish far-off chat
+				r_color_alpha = 0.8f; 
+			}
+			else
+			{
+				r_color_alpha = 1.0f;
+			}
+		}
+	}
+	
+}
+
+
+//static 
+LLFontGL* LLViewerChat::getChatFont()
+{
+	S32 font_size = gSavedSettings.getS32("ChatFontSize");
+	LLFontGL* fontp = NULL;
+	switch(font_size)
+	{
+		case 0:
+			fontp = LLFontGL::getFontSansSerifSmall();
+			break;
+		default:
+		case 1:
+			fontp = LLFontGL::getFontSansSerif();
+			break;
+		case 2:
+			fontp = LLFontGL::getFontSansSerifBig();
+			break;
+	}
+	
+	return fontp;
+	
+}
+
+//static
+S32 LLViewerChat::getChatFontSize()
+{
+	return gSavedSettings.getS32("ChatFontSize");
+}
diff --git a/indra/newview/llviewerchat.h b/indra/newview/llviewerchat.h
new file mode 100644
index 0000000000000000000000000000000000000000..d8840d5dd2466d9727602dc9de6c27db2a59177e
--- /dev/null
+++ b/indra/newview/llviewerchat.h
@@ -0,0 +1,53 @@
+/** 
+ * @file llviewerchat.h
+ * @brief wrapper of LLChat in viewer
+ *
+ * $LicenseInfo:firstyear=2002&license=viewergpl$
+ * 
+ * Copyright (c) 2002-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLVIEWERCHAT_H
+#define LL_LLVIEWERCHAT_H
+
+#include "llchat.h"
+#include "llfontgl.h"
+#include "v4color.h"
+
+
+class LLViewerChat 
+{
+public:
+	static void getChatColor(const LLChat& chat, LLColor4& r_color);
+	static void getChatColor(const LLChat& chat, std::string& r_color_name, F32& r_color_alpha);
+	static LLFontGL* getChatFont();
+	static S32 getChatFontSize();
+	
+
+
+};
+
+#endif
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index a90790c59a85f4ef976906c342cdf4156b91c13c..921868d44891aad19b86b4339108576f89268b2e 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -43,7 +43,7 @@
 #include "llfloaterbump.h"
 #include "llassetstorage.h"
 #include "llcachename.h"
-#include "llchat.h"
+
 #include "lldbstrings.h"
 #include "lleconomy.h"
 #include "llfilepicker.h"
@@ -115,6 +115,7 @@
 #include "llui.h"			// for make_ui_sound
 #include "lluploaddialog.h"
 #include "llviewercamera.h"
+#include "llviewerchat.h"
 #include "llviewergenericmessage.h"
 #include "llviewerinventory.h"
 #include "llviewermenu.h"
@@ -2232,7 +2233,7 @@ void process_decline_callingcard(LLMessageSystem* msg, void**)
 
 void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
 {
-	LLChat		chat;
+	LLChat	chat;
 	std::string		mesg;
 	std::string		from_name;
 	U8			source_temp;
@@ -2832,7 +2833,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**)
 			// Chat the "back" SLURL. (DEV-4907)
 			LLChat chat("Teleport completed from " + gAgent.getTeleportSourceSLURL());
 			chat.mSourceType = CHAT_SOURCE_SYSTEM;
- 			LLFloaterChat::addChatHistory(chat);
+ 		    LLFloaterChat::addChatHistory(chat);
 
 			// Set the new position
 			avatarp->setPositionAgent(agent_pos);
@@ -4604,7 +4605,7 @@ void notify_cautioned_script_question(const LLSD& notification, const LLSD& resp
 		if (caution)
 		{
 			LLChat chat(notice.getString());
-			LLFloaterChat::addChat(chat, FALSE, FALSE);
+	//		LLFloaterChat::addChat(chat, FALSE, FALSE);
 		}
 	}
 }