diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp
index 8efa814a2eb1b95f38eda7f252634e73571610ad..1f92686a43606edd7f9712be798612367f493b8b 100644
--- a/indra/newview/llchiclet.cpp
+++ b/indra/newview/llchiclet.cpp
@@ -1137,7 +1137,7 @@ void im_chiclet_callback(LLChicletPanel* panel, const LLSD& data){
 	S32 unread = data["participant_unread"].asInteger();
 
 	LLIMFloater* im_floater = LLIMFloater::findInstance(session_id);
-	if (im_floater && im_floater->getVisible())
+	if (im_floater && im_floater->getVisible() && im_floater->hasFocus())
 	{
 		unread = 0;
 	}
diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp
index f0e195c37a8f7ed3832e5e532308f5f77d49033f..91f4f57e54458b55e673b3b743bc21a4af6d2a51 100644
--- a/indra/newview/llimfloater.cpp
+++ b/indra/newview/llimfloater.cpp
@@ -128,6 +128,11 @@ void LLIMFloater::onFocusReceived()
 	LLIMModel::getInstance()->setActiveSessionID(mSessionID);
 
 	LLBottomTray::getInstance()->getChicletPanel()->setChicletToggleState(mSessionID, true);
+
+	if (getVisible())
+	{
+		LLIMModel::instance().sendNoUnreadMessages(mSessionID);
+	}
 }
 
 // virtual
@@ -609,7 +614,16 @@ void LLIMFloater::updateMessages()
 	bool use_plain_text_chat_history = gSavedSettings.getBOOL("PlainTextChatHistory");
 
 	std::list<LLSD> messages;
-	LLIMModel::instance().getMessages(mSessionID, messages, mLastMessageIndex+1);
+
+	// we shouldn't reset unread message counters if IM floater doesn't have focus
+	if (hasFocus())
+	{
+		LLIMModel::instance().getMessages(mSessionID, messages, mLastMessageIndex+1);
+	}
+	else
+	{
+		LLIMModel::instance().getMessagesSilently(mSessionID, messages, mLastMessageIndex+1);
+	}
 
 	if (messages.size())
 	{
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 6ce06adc80f4edb1f1659037da09276d9659f2a2..7a4febec20069d2bda6c74db2dc07fda6e527f00 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -608,10 +608,10 @@ bool LLIMModel::clearSession(const LLUUID& session_id)
 	return true;
 }
 
-void LLIMModel::getMessages(const LLUUID& session_id, std::list<LLSD>& messages, int start_index)
+void LLIMModel::getMessagesSilently(const LLUUID& session_id, std::list<LLSD>& messages, int start_index)
 {
 	LLIMSession* session = findIMSession(session_id);
-	if (!session) 
+	if (!session)
 	{
 		llwarns << "session " << session_id << "does not exist " << llendl;
 		return;
@@ -619,7 +619,7 @@ void LLIMModel::getMessages(const LLUUID& session_id, std::list<LLSD>& messages,
 
 	int i = session->mMsgs.size() - start_index;
 
-	for (std::list<LLSD>::iterator iter = session->mMsgs.begin(); 
+	for (std::list<LLSD>::iterator iter = session->mMsgs.begin();
 		iter != session->mMsgs.end() && i > 0;
 		iter++)
 	{
@@ -628,6 +628,16 @@ void LLIMModel::getMessages(const LLUUID& session_id, std::list<LLSD>& messages,
 		messages.push_back(*iter);
 		i--;
 	}
+}
+
+void LLIMModel::sendNoUnreadMessages(const LLUUID& session_id)
+{
+	LLIMSession* session = findIMSession(session_id);
+	if (!session)
+	{
+		llwarns << "session " << session_id << "does not exist " << llendl;
+		return;
+	}
 
 	session->mNumUnread = 0;
 	session->mParticipantUnreadMessageCount = 0;
@@ -639,6 +649,13 @@ void LLIMModel::getMessages(const LLUUID& session_id, std::list<LLSD>& messages,
 	mNoUnreadMsgsSignal(arg);
 }
 
+void LLIMModel::getMessages(const LLUUID& session_id, std::list<LLSD>& messages, int start_index)
+{
+	getMessagesSilently(session_id, messages, start_index);
+
+	sendNoUnreadMessages(session_id);
+}
+
 bool LLIMModel::addToHistory(const LLUUID& session_id, const std::string& from, const LLUUID& from_id, const std::string& utf8_text) {
 	
 	LLIMSession* session = findIMSession(session_id);
diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h
index e7404074e0475878f12468804819d99df8142734..f1693d0e17564b64843e5bc6a1d2b3183a76eac3 100644
--- a/indra/newview/llimview.h
+++ b/indra/newview/llimview.h
@@ -177,6 +177,17 @@ class LLIMModel :  public LLSingleton<LLIMModel>
 	 */
 	bool clearSession(const LLUUID& session_id);
 
+	/**
+	 * Populate supplied std::list with messages starting from index specified by start_index without
+	 * emitting no unread messages signal.
+	 */
+	void getMessagesSilently(const LLUUID& session_id, std::list<LLSD>& messages, int start_index = 0);
+
+	/**
+	 * Sends no unread messages signal.
+	 */
+	void sendNoUnreadMessages(const LLUUID& session_id);
+
 	/**
 	 * Populate supplied std::list with messages starting from index specified by start_index
 	 */