Index: /trunk/FACT++/src/smartfact.cc
===================================================================
--- /trunk/FACT++/src/smartfact.cc	(revision 14036)
+++ /trunk/FACT++/src/smartfact.cc	(revision 14037)
@@ -3,4 +3,5 @@
 #include <libnova/lunar.h>
 #include <libnova/rise_set.h>
+#include <libnova/transform.h>
 #endif
 
@@ -214,4 +215,7 @@
     double dec;
 
+    double zd;
+    double az;
+
     double disk;
 
@@ -237,4 +241,11 @@
         observer.lng = lon;
         observer.lat = lat;
+
+        //observer.lng.degrees = -5;
+        //observer.lng.minutes = 36;
+        //observer.lng.seconds = 30;
+        //observer.lat.degrees = 42;
+        //observer.lat.minutes = 35;
+        //observer.lat.seconds = 40;
 
         ln_rst_time moon;
@@ -264,4 +275,9 @@
         ln_get_lunar_equ_coords(JD, &pos);
 
+        ln_hrz_posn hrz;
+        ln_get_hrz_from_equ (&pos, &observer, JD, &hrz);
+        az =    hrz.az;
+        zd = 90-hrz.alt;
+
         ra  = pos.ra/15;
         dec = pos.dec;
@@ -326,6 +342,4 @@
 {
 private:
-    const Time fRunTime;
-
     enum states_t
     {
@@ -336,5 +350,9 @@
     // ------------------------- Internal variables -----------------------
 
+    const Time fRunTime;
+
     PixelMap fPixelMap;
+
+    string fDatabase;
 
     Time fLastUpdate;
@@ -407,9 +425,4 @@
     Sun   fSun;
     Moon  fMoon;
-
-    //bool fSunIsVisible;
-    //bool fMoonIsVisible;
-    //Time fTimeOfCivilTwilight;
-    //float fMoonPhase;
 
     // --------------------------- File header ----------------------------
@@ -714,7 +727,12 @@
         ostringstream out;
         out << d.GetJavaDate() << '\n';
-        out << fSun.color << '\t' << fSun.description << '\n';
-        out << setprecision(2);
-        out << (fSun.isday?HTML::kWhite:fMoon.color) << '\t' << fMoon.description << '\n';
+        if (fSun.time.IsValid() && fMoon.time.IsValid())
+        {
+            out << fSun.color << '\t' << fSun.description << '\n';
+            out << setprecision(2);
+            out << (fSun.isday?HTML::kWhite:fMoon.color) << '\t' << fMoon.description << '\n';
+        }
+        else
+            out << "\n\n";
         out << setprecision(3);
         for (int i=0; i<6; i++)
@@ -1652,4 +1670,5 @@
 
         ostringstream out;
+        out << setprecision(3);
         out << fSun.time.JavaDate() << '\n';
         out << HTML::kWhite << '\t' << fSun.fSunRiseDarkTime.GetAsStr("%H:%M") << '\n';
@@ -1667,4 +1686,16 @@
         out << HTML::kWhite << '\t' << fMoon.fMoonSet.GetAsStr("%H:%M") << '\n';
 
+        if (!fMoon.visible)
+            out << HTML::kWhite << "\t&mdash;\n";
+        else
+        {
+            string col = HTML::kGreen;
+            if (fMoon.zd>25)
+                col = HTML::kYellow;
+            if (fMoon.zd>45 && fMoon.zd<85)
+                col = HTML::kRed;
+            out << col << '\t' << fMoon.zd << '\n';
+        }
+
         out << fMoon.color  << '\t' << fMoon.description << '\n';
 
@@ -1672,6 +1703,4 @@
         try
         {
-            const string fDatabase = "readpo:readc0nf1g@10.0.100.21/scheduling";
-
             //static const boost::regex expr("(([[:word:].-]+)(:(.+))?@)?([[:word:].-]+)(:([[:digit:]]+))?(/([[:word:].-]+))?");
             static const boost::regex expr("(([[:word:].-]+)(:(.+))?@)?([[:word:].-]+)(:([[:digit:]]+))?(/([[:word:].-]+))");
@@ -1732,5 +1761,6 @@
         catch (const exception &e)
         {
-            Warn("Source database access: "+string(e.what()));
+            out << '\n';
+            out << HTML::kWhite << '\t' << "ERROR  - "+string(e.what()) << '\n';
         }
 #endif
@@ -2352,5 +2382,6 @@
         }
 
-        fPath = conf.Get<string>("path");
+        fPath     = conf.Get<string>("path");
+        fDatabase = conf.Get<string>("source-database");
 
         ostringstream out;
@@ -2378,6 +2409,7 @@
     po::options_description control("Smart FACT");
     control.add_options()
-        ("pixel-map-file", var<string>("FACTmapV5a.txt"),     "Pixel mapping file. Used here to get the default reference voltage")
-        ("path",           var<string>("www/smartfact/data"), "Output path for the data-files")
+        ("pixel-map-file",  var<string>("FACTmapV5a.txt"),     "Pixel mapping file. Used here to get the default reference voltage")
+        ("path",            var<string>("www/smartfact/data"), "Output path for the data-files")
+        ("source-database", var<string>(), "Database link as in\n\tuser:password@server[:port]/database.")
         ;
 
