Index: trunk/FACT++/www/shift/calendar.js
===================================================================
--- trunk/FACT++/www/shift/calendar.js	(revision 13685)
+++ trunk/FACT++/www/shift/calendar.js	(revision 13687)
@@ -359,4 +359,10 @@
             };
 
+            var sp = document.createElement("span");
+            sp.appendChild(document.createTextNode("*"));
+            sp.style.color="darkred";
+            sp.style.display="none";
+            td.appendChild(sp);
+
             tr.appendChild( td );
         }
@@ -380,4 +386,5 @@
 
         requestAll(this.yy, this.mm);
+        requestAllComments(this.yy, this.mm);
         if (this.year==this.yy && this.month==this.mm)
             requestComment(this.year, this.month, this.date);
@@ -432,5 +439,5 @@
                 return;
 
-            while (td.childNodes.length>1)
+            while (td.childNodes.length>2)
                 td.removeChild(td.lastChild);
 
@@ -454,5 +461,5 @@
             }
 
-            if (td.childNodes.length>1)
+            if (td.childNodes.length>2)
                 td.className += " enabled";
             else
@@ -486,10 +493,11 @@
         var m = c.getAttribute("data-m");
         var d = c.getAttribute("data-d");
-
-        var uri = "calendar.php?y="+y+"&m="+m+"&d="+d+"&c="+encodeURIComponent(c.value);
+        var v = c.value;
+
+        var uri = "calendar.php?y="+y+"&m="+m+"&d="+d+"&c="+encodeURIComponent(v);
 
         var xmlHttp = new XMLHttpRequest();
         xmlHttp.open('POST', uri, true);
-        xmlHttp.onload = function ()
+        xmlHttp.onload = function()
         {
             if (xmlHttp.status!=200)
@@ -499,5 +507,19 @@
             }
 
-            alert("Comment inserted successfully.")
+            alert("Comment inserted successfully.");
+
+            var td = document.getElementById(m+"-"+d);
+            alert(td.childNodes[1]+"/"+v);
+            if (v=="")
+            {
+                td.childNodes[1].style.display="none";
+                td.title="Click to select this date.";
+            }
+            else
+            {
+                td.childNodes[1].style.display="";
+                td.title=v;
+            }
+
         };
 
@@ -527,9 +549,19 @@
             }
 
+            var td = document.getElementById(mm+"-"+dd);
+
             c.color="#888";
             if (xmlHttp.responseText=="")
+            {
                 c.value="enter comment here";
+                td.childNodes[1].style.display="none";
+                td.title="";
+            }
             else
+            {
                 c.value = xmlHttp.responseText;
+                td.childNodes[1].style.display="";
+                td.title=xmlHttp.responseText;
+            }
 
             c.setAttribute("data-y", yy);
@@ -585,4 +617,41 @@
     }
 
+    function requestAllComments(yy, mm)
+    {
+        var uri = "calendar.php?comment&y="+yy+"&m="+mm;
+        var xmlHttp = new XMLHttpRequest();
+        xmlHttp.open('POST', uri, true);
+        xmlHttp.onload = function ()
+        {
+            if (xmlHttp.status!=200)
+            {
+                alert("ERROR - HTTP request: "+xmlHttp.statusText+" ["+xmlHttp.status+"]");
+                return;
+            }
+
+            if (xmlHttp.responseText<4)
+                return;
+
+            var pos = 6;
+
+            while (pos<xmlHttp.responseText.length)
+            {
+                var len = parseInt(xmlHttp.responseText.substr(pos-6, 4), 10);
+                var dd  = parseInt(xmlHttp.responseText.substr(pos-2, 2), 10);
+                var com = xmlHttp.responseText.substr(pos, len);
+                pos += len+6;
+
+                if (com!="")
+                {
+                    var td = document.getElementById(mm+"-"+dd);
+                    td.childNodes[1].style.display="";
+                    td.title=com;
+                }
+            }
+        };
+
+        xmlHttp.send();
+    }
+
     this.setDate = function()
     {
Index: trunk/FACT++/www/shift/calendar.php
===================================================================
--- trunk/FACT++/www/shift/calendar.php	(revision 13685)
+++ trunk/FACT++/www/shift/calendar.php	(revision 13687)
@@ -81,10 +81,7 @@
 if (isset($_GET['comment']))
 {
-    if (!isset($_GET['d']))
-        return;
-
-    $d = $_GET['d'];
-
-    $query = "SELECT c FROM Comments WHERE y=".$y." AND m=".$m." AND d=".$d;
+    $query = "SELECT d, c FROM Comments WHERE y=".$y." AND m=".$m;
+    if (isset($_GET['d']))
+        $query .= " AND d=".$_GET['d'];
 
     $result = mysql_query($query);
@@ -92,7 +89,15 @@
         return header('HTTP/1.0 500 '.mysql_error());
 
-    $row = mysql_fetch_array($result, MYSQL_NUM);
+    if (isset($_GET['d']))
+    {
+        $row = mysql_fetch_array($result, MYSQL_NUM);
+        print($row[1]);
+        return;
+    }
 
-    print($row[0]);
+    while ($row = mysql_fetch_array($result, MYSQL_NUM))
+    {
+        printf("%04d%02d%s", strlen($row[1]), $row[0], $row[1]);
+    }
 
     return;
