Index: /trunk/FACT++/www/smartfact/index.js
===================================================================
--- /trunk/FACT++/www/smartfact/index.js	(revision 14030)
+++ /trunk/FACT++/www/smartfact/index.js	(revision 14031)
@@ -49,4 +49,5 @@
         case "max":     $("body").displayMax     = true; continue;
         case "noslide": $("body").displayNoslide = true; continue;
+        case "sound":   $("body").sound          = true; continue;
         }
 
@@ -61,4 +62,6 @@
         }
     }
+
+    $("audio").date = new Date();
 
 
@@ -227,4 +230,5 @@
     var htd3 = $new("td");
     var htd4 = $new("td");
+    var htd5 = $new("td");
     htd0.setAttribute("class", "tcell1");
     htd1.setAttribute("class", "tcell2");
@@ -234,4 +238,5 @@
     htd3.setAttribute("width", "1px");
     htd4.setAttribute("width", "1px");
+    htd5.setAttribute("width", "1px");
     hhtr.appendChild(htd4);
     hhtr.appendChild(htd3);
@@ -239,4 +244,5 @@
     hhtr.appendChild(htd1);
     hhtr.appendChild(htd2);
+    hhtr.appendChild(htd5);
 
     var div1 = $new("div");
@@ -244,9 +250,13 @@
     var div3 = $new("div");
     var div4 = $new("div");
+    var div5 = $new("div");
     div4.id = "warn"+z;
+    div5.id = "speaker"+z;
     div2.setAttribute("class", "icon_white");
     div4.setAttribute("class", "icon_color");
+    div5.setAttribute("class", "icon_color");
     div2.setAttribute("style", "background-position:-396px 50%;");
-    div4.setAttribute("style", "display:none;background-position:-12px -12px;");
+    div4.setAttribute("style", "background-position:-12px -12px;display:none;");
+    div5.setAttribute("style", "background-position:-189px -57px;");
     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); };
@@ -301,6 +311,7 @@
     if (dz!=0/* && z+dz!=0*/)
         htd2.appendChild(div2); // back
-    htd3.appendChild(div3); // home
+    htd3.appendChild(div3);     // home
     htd4.appendChild(div4);     // Warning
+    htd5.appendChild(div5);     // Warning
 
     // ==================================================================
@@ -661,4 +672,20 @@
     table.appendChild(tf);
 
+    // ==================================================================
+    /*
+    var audio = $new("AUDIO");
+
+    audio.autoplay = true;
+    audio.date     = new Date();
+    audio.id       = "audio"+z;
+
+    var ogg = $new("SOURCE");
+    var mp3 = $new("SOURCE");
+    audio.appendChild(ogg);
+    audio.appendChild(mp3);
+
+    $("body").appendChild(audio);
+    */
+
     $("body").appendChild(table);
 
@@ -888,4 +915,5 @@
 var date0 = null;
 
+var test = 0;
 function update_text(fname, result)
 {
@@ -908,5 +936,5 @@
 
     // File corrupted / should we remove the date?)
-    if (header.length!=3 && header.length!=2 && header.length!=1 && header[0].length!=13)
+    if ((header.length>5 || header.length==2 || header.length==0) && header[0].length!=13)
     {
         // we ignore corrupted files for one minute
@@ -934,8 +962,41 @@
     // ----------------------------------------------------
 
-    $("warn"+z).style.display = header.length>=2 && header[1]=='1' ? "" : "none";
-
-    if (header.length==3)
-        $("cmd"+z).style.backgroundColor = header[2]=='1' ? "darkgreen" : "darkred";
+    $("warn"+z).style.display = header.length>=4 && header[3]=='1' ? "" : "none";
+
+    if (header.length>=5)
+        $("cmd"+z).style.backgroundColor = header[4]=='1' ? "darkgreen" : "darkred";
+
+    if (header.length>=3 && $("body").sound)
+    {
+        $("speaker"+z).style.display ="none";
+
+        var audio = $("audio");
+
+        var audio_date = new Date();
+        audio_date.setTime(header[1]);
+
+        // Time stamp of audio file must be newer than page load
+        //  or last audio play respecitvely
+        if (audio_date>audio.date)
+        {
+            audio.date = audio_date;
+
+            var name_ogg = "audio/"+header[2]+".ogg";
+            var name_mp3 = "audio/"+header[2]+".mp3";
+
+            var ogg = $new("SOURCE");
+            var mp3 = $new("SOURCE");
+            ogg.type = "audio/ogg";
+            mp3.type = "audio/mp3";
+            ogg.src  = name_ogg;
+            mp3.src  = name_mp3;
+
+            if (audio.firstChild.src!=ogg.src)
+            {
+                audio.replaceChild(ogg, audio.firstChild);
+                audio.replaceChild(mp3, audio.lastChild);
+            }
+        }
+    }
 
     // ----------------------------------------------------
