<!--

var moonSize = 1;

var tzone = -5; 
var Lat   = 41.02;
var Lon   = -73.35;


var ie4  = document.all && !document.getElementById;
var ns4  = document.layers;
var DOM2 = document.getElementById;

if(ie4 || DOM2)
   document.write('<div id="moon"></div>');

show_moon();  
  
function show_moon()
{
  var text = calc_moon();  
  
  if(DOM2) 
     document.getElementById("moon").innerHTML=text;
  else if(ie4)
     document.all.innerHTML=text;
  else if(ns4) {
     document.write(text);
     document.close(); }
  
  setTimeout("show_moon()", 60000);
}

function calc_moon() 
{
 
 var now     = new Date();
 var year    = now.getYear();
 var month   = now.getMonth()+1;
 var day     = now.getDate();
 var hours   = now.getHours();
 var minutes = now.getMinutes();
 var seconds = now.getSeconds();
 var text    = "";
 var i;
	
  if(year < 2000) year+=1900;

  //------------------------------------
  // draw the current moon illumination
  //------------------------------------
  //return seconds;
  
//  var mp = MoonPhase(year,month,day);
//  if(Math.round(mp[1]) < 100) {
//     var black = "images/black.gif";
//     var white = "images/white.gif";
//     var left, right, il;
//     il = mp[1] = Math.round(mp[1]);
//     if(mp[0] >= 0) {
//        left  = black;
//        right = white; }
//     else {
//        il    = 100 - mp[1];
//        left  = white;
//        right = black; }
	
//     text += "<table><tr><td align=\"center\">";
//     var width;
//     for(i=-(moonSize-1); i<moonSize; ++i) {
//        width = 2*Math.round(Math.sqrt((moonSize*moonSize)-(i*i)));
//        text += "<img src="+left+" height=1 width="+(width*((101-il)/101))+">";
//        text += "<img src="+right+" height=1 width="+(width*((il)/101))+"><br>"; 
//     }
  
//     text += "</td></tr></table>"; 
//   }
   //--------------
   // write output
   //--------------
//   hours += (minutes+seconds/60.0)/60.0;

//  text += "<div style=\"position:absolute; left:"+(moonSize*2+10)+"; top:0;\">";
  text += "<font face=\"verdana\" size=\"-2\">";
	
//   document.write(month+"."+day+"."+year+"<br>");

   // Moon rise and set
   var mrs = MoonRise(year,month,day,Lat,Lon);
	
   // current altitude
   hours += tzone;
   if(hours < 0)       hours+=24;
   else if(hours >=24) hours-=24;

   var mpos   = MoonPos(year,month,day,hours);
   var obspos = radtoaa(mpos[0],mpos[1],year,month,day,hours,Lat,Lon);
   obspos[0]  = Math.round(obspos[0]); // altitude
   obspos[1]  = Math.round(obspos[1]); // azimuth

   // output rise, set, altitude and azimuth
   if(mrs[0] >= 0 && mrs[1] >= 0) {
      text += "The Moon rises at "+dt_hms(mrs[0]-tzone);
      text += " and sets at "+dt_hms(mrs[1]-tzone)+".<br>"; }
   else if(mrs[0] >= 0 && mrs[1] < 0)     
      text += "The Moon rises at "+dt_hms(mrs[0]-tzone)+" and does not set today.<br>";
   else if(mrs[1] >= 0 && mrs[0] < 0)    
      text += "The Moon sets at "+dt_hms(mrs[1]-tzone)+" and is not rising today.<br>";
   else if(mrs[1] < 0 && mrs[0] < 0) {
      if(obspos[0] >= 0) text += "The Moon is up all day today.<br>"; 
      else               text += "The Moon is not rising today.<br>"; }

   text += "<b>Altitude:</b> "+obspos[0]+"&deg; <b>Azimuth:</b> "+azimuth(obspos[1])+".<br>";
//   text += "The disk is now "+mp[1]+"% illuminated.<br>";
	  
 // next new and full moon
//   var mfn = moons(year);
//   var jdg = julian(year,month,day,12);
//   var ifirst=0, ilast=28;
   // for the full year delete the next 6 lines
//   for(i=0; i<=28; i++)
//      if(mfn[i] > jdg) {
 //        ifirst = (i>=2) ? i-i%2:0;
  //       ilast  = (i==ifirst) ? ifirst+1:ifirst+3;
  //       break; }
	  	  
  // var nextm;
   //var j;
  // for(j=0, i=ifirst; j<2 && i<=ilast; i++) {
   //   nextm = jdtocd(mfn[i]-tzone/24.0);
     // if(nextm[0]==year && nextm[1] <= month && nextm[2] < day ) continue;
     // j++;
   // text += (i%2)==0 ? "Next new Moon on ":"Next full Moon on ";
    //  text += nextm[2] + " " + monthname(nextm[1]) + " " + (nextm[0]!=year ? (" "+nextm[0]):"");
 //text += " at "+ (nextm[4]<10 ? "0":"") + nextm[4];
  //   text += nextm[1]+".<br>"; }

 // text += "</font></div>";		
  
 return text; 
}

-->