Index: trunk/FACT++/www/smartfact/index.js
===================================================================
--- trunk/FACT++/www/smartfact/index.js	(revision 14208)
+++ trunk/FACT++/www/smartfact/index.js	(revision 14401)
@@ -35,4 +35,7 @@
         xmlLoad.onload = function()
         {
+            if (xmlLoad.status==401)
+                login("");
+
             if (xmlLoad.status!=200)
             {
@@ -40,6 +43,7 @@
                 //return;
             }
-            if (xmlLoad.responseText.length>0)
-                alert(xmlLoad.responseText);
+
+            if (xmlLoad.status==200)
+                login(xmlLoad.responseText);
         };
         xmlLoad.send(null);
@@ -88,4 +92,18 @@
 }
 
+function login(user)
+{
+    var z = $("body").visiblePage;
+    var l = $("login"+z);
+
+    $("body").user = user;
+
+    if (l)
+    {
+        l.setAttribute("style", "background-position:-"+(user?"720":"755")+"px 50%;");
+        l.alt = user;
+    }
+}
+
 function onresize()
 {
@@ -153,4 +171,7 @@
     xmlCmd.onload = function ()
     {
+        if (xmlCmd.status==401)
+            login("");
+
         if (xmlCmd.status!=200)
         {
@@ -166,5 +187,8 @@
 
         var txt = xmlCmd.responseText.split('\n');
-        switch (txt[0])
+
+        login(txt[0]);
+
+        switch (txt[1])
         {
         case "1": alert("dimctrl unreachable."); break;
@@ -172,5 +196,5 @@
         default: alert("Return code '"+txt[0]+"' unknown."); break;
         }
-        if (txt.length>1)
+        if (txt.length>2)
             alert(xmlCmd.responseText);
     };
@@ -251,4 +275,5 @@
     var htd4 = $new("td");
     var htd5 = $new("td");
+    var htd6 = $new("td");
     htd0.setAttribute("class", "tcell1");
     htd1.setAttribute("class", "tcell2");
@@ -259,4 +284,6 @@
     htd4.setAttribute("width", "1px");
     htd5.setAttribute("width", "1px");
+    htd6.setAttribute("width", "1px");
+    hhtr.appendChild(htd6);
     hhtr.appendChild(htd4);
     hhtr.appendChild(htd3);
@@ -266,4 +293,5 @@
     hhtr.appendChild(htd5);
 
+    var div0 = $new("div");
     var div1 = $new("div");
     var div2 = $new("div");
@@ -271,12 +299,17 @@
     var div4 = $new("div");
     var div5 = $new("div");
+    div0.id = "login"+z;
+    div0.alt = $("body").user;
     div4.id = "warn"+z;
     div5.id = "speaker"+z;
+    div0.setAttribute("class", "icon_login");
     div2.setAttribute("class", "icon_white");
     div4.setAttribute("class", "icon_color");
     div5.setAttribute("class", "icon_color");
+    div0.setAttribute("style", "background-position:-"+($("body").user?"720":"755")+"px 50%;");
     div2.setAttribute("style", "background-position:-396px 50%;");
-    div4.setAttribute("style", "background-position:-12px -12px;display:none;");
+    div4.setAttribute("style", "background-position:-12px -13px;display:none;");
     div5.setAttribute("style", "background-position:-189px -57px;");
+    div0.onclick = function () { sendCommand("logout"); };
     div2.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage(fname,   z, -dz); };
     div4.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('error', z,  +1); };
@@ -328,4 +361,5 @@
     htd0.appendChild(sp2);
 
+    htd6.appendChild(div0);     // Login
     htd1.appendChild(div1);
     if (dz!=0/* && z+dz!=0*/)
@@ -333,5 +367,5 @@
     htd3.appendChild(div3);     // home
     htd4.appendChild(div4);     // Warning
-    htd5.appendChild(div5);     // Warning
+    htd5.appendChild(div5);     // Speaker
 
     // ==================================================================
@@ -916,5 +950,5 @@
         if (xmlText.status!=200)
         {
-            alert("ERROR[1] - HTTP request '"+fname+".data': "+xmlText.statusText+" ["+xmlText.status+"]");
+            alert("ERROR[2] - HTTP request '"+fname+".data': "+xmlText.statusText+" ["+xmlText.status+"]");
             timeoutText = setTimeout(refresh_text, 10000);
             return;
@@ -1081,5 +1115,5 @@
         if (xmlGfx.status!=200)
         {
-            alert("ERROR[2] - Request '"+fname+"': "+xmlGfx.statusText+" ["+xmlGfx.status+"]");
+            alert("ERROR[3] - Request '"+fname+"': "+xmlGfx.statusText+" ["+xmlGfx.status+"]");
             timeoutGraphics = setTimeout(refresh_graphics, 10000);
             //****** invalidate ******
