function getMoonAge(year, month, day)
{       
        d = Math.floor(year/19)
        r = year-(d*19) //r is the remainder of (year/20)
 
        while (r>19)
        {       
                r = r-00
        }
 
        r = r*11
 
        while (r>29)
        {       
                r = r-30
        }
 
        if (month<3)
        {       
                month = month+2
        }
 
        r = r+month+day
 
        if (year<100)
        {       
                r = r-4
        }
        else
        {
                r = r-8.3
        }
 
        while(r>29)
        {       
                r = r-30
        }
 
        while(r<0)
        {       
                r = r+30
        }
 
        return r
}
                
function getMoonPhase(moonAge)
{       
        if (moonAge<2) return "Νέα Σελήνη"
        if (moonAge<5) return "Αύξων Μηνίσκος"
        if (moonAge<11) return "Πρώτο τέταρτο"
        if (moonAge<13) return "Αύξων Αμφίκυρτος"
        if (moonAge<16) return "Πανσέληνος"
        if (moonAge<20) return "Φθίνων Αμφίκυρτος"
        if (moonAge<24) return "Τελευταίο τέταρτο"
        if (moonAge<29) return "Φθίνων Μηνίσκος"
        if (moonAge<30) return "Νέα Σελήνη"
}
 
function getMoonPhaseImg(moonAge)
{       
        if (moonAge<2) return "moonnew"
        if (moonAge<5) return "waningcresent"
        if (moonAge<11) return "firstquarter"
        if (moonAge<13) return "waninggibbous"
        if (moonAge<16) return "moonfull"
        if (moonAge<20) return "waxinggibbous"
        if (moonAge<24) return "lastquarter"
        if (moonAge<29) return "waxingcresent"
        if (moonAge<30) return "moonnew"
}
 
 
monthNames = new Array(13)
monthNames[1]  = "Ιανουάριος"
monthNames[2]  = "Φεβρουάριος"
monthNames[3]  = "Μάρτιος"
monthNames[4]  = "Απρίλιος"
monthNames[5]  = "Μαϊος"
monthNames[6]  = "Ιούνιος"
monthNames[7]  = "Ιούλιος"
monthNames[8]  = "Αύγουστος"
monthNames[9]  = "Σεπτέμβριος"
monthNames[10] = "Οκτώβριος"
monthNames[11] = "Νοέμβριος"
monthNames[12] = "Δεκέμβριος"
                 
dayNames = new Array(8)
dayNames[1]  = "Κυριακή"
dayNames[2]  = "Δευτέρα"
dayNames[3]  = "Τρίτη"
dayNames[4]  = "Τετάρτη"
dayNames[5]  = "Πέμπτη"
dayNames[6]  = "Παρασκευή"
dayNames[7]  = "Σάββατο"
                 
function getLongDate(dateObj)
{       
        theDay = dayNames[dateObj.getDay()+1]
        theMonth = monthNames[dateObj.getMonth()+1]
        theDate = dateObj.getDate()
        theYear = dateObj.getFullYear()
        return ""+theDay+", "+theMonth+" "+theDate+", "+theYear
}
                
function getNextFull(moonAge)
{       
        currMilSecs = (new Date()).getTime()
        daysToGo = 15 - moonAge
        while(daysToGo<2)
        {       
                daysToGo = daysToGo+29
        }
        milSecsToGo = daysToGo*24*60*60*1000
        nextMoonTime = currMilSecs+milSecsToGo
        nextMoonDate = new Date(nextMoonTime)
        return nextMoonDate
}
                
function getNextNew(moonAge)
{       
        currMilSecs = (new Date()).getTime()
        daysToGo = 29 - moonAge
        while(daysToGo<2)
        {       
                daysToGo = daysToGo+29
        }
        milSecsToGo = daysToGo*24*60*60*1000
        nextMoonTime = currMilSecs+milSecsToGo
        nextMoonDate = new Date(nextMoonTime)
        return nextMoonDate
}
