Index: /main/waeup.cas/trunk/waeup/cas/server.py
===================================================================
--- /main/waeup.cas/trunk/waeup/cas/server.py	(revision 10604)
+++ /main/waeup.cas/trunk/waeup/cas/server.py	(revision 10605)
@@ -4,4 +4,5 @@
 import os
 import random
+import re
 import time
 try:
@@ -28,4 +29,7 @@
             'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
             '01234567789-')
+
+#: A regular expression that matches a div tag around a MSG_TEXT
+RE_MSG_TAG = re.compile('\<div id="msg".*MSG_TEXT[^<]*</div>', re.DOTALL)
 
 
@@ -233,9 +237,26 @@
     # show logged-in screen
     html = get_template('login_successful.html')
-    html = html.replace('MSG_TEXT', msg)
+    html = set_message(msg, html)
     resp = Response(html)
     if not sso:
         resp = set_session_cookie(db, resp)
     return resp
+
+
+def set_message(msg, html):
+    """Insert a message box in html template.
+
+    If the message is empty, not only the string `MSG_TEXT` is removed
+    from `html`, but also any encapsulating ``<div>`` tag with id
+    ``msg``.
+
+    This makes it possible to give message boxes certain additional
+    styles that will not show up if there is no message to display.
+    """
+    if not msg:
+        if not '<div id="msg"' in html:
+            return html.replace('MSG_TEXT', '')
+        return RE_MSG_TAG.sub('', html)
+    return html.replace('MSG_TEXT', msg)
 
 
@@ -325,5 +346,5 @@
         html = html.replace('LT_VALUE', lt.ticket)
         html = html.replace('SERVICE_FIELD_VALUE', service_field)
-        html = html.replace('MSG_TEXT', msg)
+        html = set_message(msg, html)
         return Response(html)
 
