
function getMoonAge(year, month, day)
{       
        d = Math.floor(year/20)
        r = year-(d*20) //r is the remainder of (year/20)

        while (r>9)
        {       
                r = r-19
        }

        r = r*11
        
r= Math.round(r - (Math.floor(r/29.5)*29.5))

      

        if (month<3)
        {       
                month = month+2
        }
       


        r = r+month+day

       
                r = r-8.3
     

            
r= Math.round(r - (Math.floor(r/29.5)*29.5))

       
        return r
}
                
function getMoonPhase(moonAge)
{       
        if (moonAge<2) return "New"
        if (moonAge<5) return "Waxing Crescent"
        if (moonAge<11) return "First Quarter"
        if (moonAge<13) return "Waxing Gibbous"
        if (moonAge<16) return "Full"
        if (moonAge<20) return "Waning Gibbous"
        if (moonAge<24) return "Last Quarter"
        if (moonAge<29) return "Waning Crescent"
        if (moonAge<30) return "New"
}

function getMoonPhaseImg(moonAge)
{       
        if (moonAge<2) return "images/moonnew"
        if (moonAge<5) return "images/waxingcrescent"
        if (moonAge<11) return "images/firstquarter"
        if (moonAge<13) return "images/waxinggibbous"
        if (moonAge<16) return "images/moonfull"
        if (moonAge<20) return "images/waninggibbous"
        if (moonAge<24) return "images/lastquarter"
        if (moonAge<29) return "images/waningcrescent"
        if (moonAge<30) return "images/moonnew"
}


monthNames = new Array(13)
monthNames[1]  = "January"
monthNames[2]  = "February"
monthNames[3]  = "March"
monthNames[4]  = "April"
monthNames[5]  = "May"
monthNames[6]  = "June"
monthNames[7]  = "July"
monthNames[8]  = "August"
monthNames[9]  = "September"
monthNames[10] = "October"
monthNames[11] = "November"
monthNames[12] = "December"
                 
monthValue = new Array(13)
monthValue[1]  = 1
monthValue[2]  = 2
monthValue[3]  = 3
monthValue[4]  = 4
monthValue[5]  = 5
monthValue[6]  = 6
monthValue[7]  = 7
monthValue[8]  = 8
monthValue[9]  = 9
monthValue[10] = 10
monthValue[11] = 11
monthValue[12] = 12


dayNames = new Array(8)
dayNames[1]  = "Sunday"
dayNames[2]  = "Monday"
dayNames[3]  = "Tuesday"
dayNames[4]  = "Wednesday"
dayNames[5]  = "Thursday"
dayNames[6]  = "Friday"
dayNames[7]  = "Saturday"
                 
function getDate(dateObj)
{       
        theDay = dayNames[dateObj.getDay()+1]
        theMonth = monthNames[dateObj.getMonth()+1]
        theDate = dateObj.getDate()
        theYear = 2000+dateObj.getYear()
        return ""+theDay+", "+theMonth+" "+theDate+", "+theYear
}
 

function getMyDate(dateObj)
{       
        theDay = dayNames[dateObj.getDay()+1]
        theMonth = monthValue[dateObj.getMonth()+1]
        theDate = dateObj.getDate()
        theYear = 2000+dateObj.getYear()
        return theMonth
}

     


               
function getShortDate(dateObj)
{       
        theDay = dayNames[dateObj.getDay()+1]
        theMonth = monthNames[dateObj.getMonth()+1]
        theDate = dateObj.getDate()
        theYear = 2000+dateObj.getYear()
        return ""+theMonth+" "+theDate+" "
}

                
function getNextFull(moonAge)
{       
        currMilSecs = (new Date()).getTime()
        daysToGo = 14.75 - moonAge
    while(daysToGo<2)
        {       
                daysToGo = daysToGo+29.5
        }    
        milSecsToGo = daysToGo*24*60*60*1000
        nextMoonTime = currMilSecs+milSecsToGo
        nextMoonDate = new Date(nextMoonTime)
        return nextMoonDate 
}
                
function getNextNew(moonAge)
{       
        currMilSecs = (new Date()).getTime()
        daysToGo = 29.5 - moonAge
    while(daysToGo<2)
        {       
                daysToGo = daysToGo+29.5
        }    
        milSecsToGo = daysToGo*24*60*60*1000
        nextMoonTime = currMilSecs+milSecsToGo
        nextMoonDate = new Date(nextMoonTime)
        return nextMoonDate
}
//-->

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

