// JavaScript Document
<!--
function getMoonAge(year, month, day)
{       
 d = Math.floor(year/19)
 r = year-(d*19) 

 while (r>19)
 {
  r = r-19;
 }

 r = r*11

 while (r>29)
 {
  r = r-30;
 }

 if (month<3) month = month-1
 else month = month-2
 r = r+month+day

 while(r>29) r = r-30
 while(r<0) r = r+30

 return r
}
		
function getMoonPhase(moonAge)
{       
	if (moonAge<1) return "Po nove"
	if (moonAge<3) return "Nov"
	if (moonAge<7) return "Pred prvou štvrťou"
	if (moonAge<11) return "Prvá štvrť"
	if (moonAge<12) return "Po prvej štvrti"
	if (moonAge<14) return "Pred splnom"
	if (moonAge<16) return "Spln"
	if (moonAge<17) return "Po splne"
	if (moonAge<18) return "Pred poslednou štvrťou"
	if (moonAge<23) return "Posledná štvrť"
	if (moonAge<24) return "Po poslednej štvrti"
	if (moonAge<28) return "Pred novom"
	if (moonAge<31) return "Nov"
}

function getMoonPhaseImg(moonAge)
{       
	if (moonAge<3) return "nov"
	if (moonAge<7) return "kosakd"
	if (moonAge<11) return "1stvrt"
	if (moonAge<14) return "neuplnyd"
	if (moonAge<16) return "spln"
	if (moonAge<18) return "neuplnym"
	if (moonAge<23) return "postvrt"
	if (moonAge<28) return "kosakm"
	if (moonAge<31) return "nov"
}


monthNames = new Array(13)
monthNames[1]  = "Január"
monthNames[2]  = "Február"
monthNames[3]  = "Marec"
monthNames[4]  = "Apríl"
monthNames[5]  = "Máj"
monthNames[6]  = "Jún"
monthNames[7]  = "Júl"
monthNames[8]  = "August"
monthNames[9]  = "September"
monthNames[10] = "Október"
monthNames[11] = "November"
monthNames[12] = "December"
		 
dayNames = new Array(8)
dayNames[1]  = "Nedeľa"
dayNames[2]  = "Pondelok"
dayNames[3]  = "Utorok"
dayNames[4]  = "Streda"
dayNames[5]  = "Štvrtok"
dayNames[6]  = "Piatok"
dayNames[7]  = "Sobota"
		 
function getLongDate(dateObj)
{       
	theDay = dayNames[dateObj.getDay()+1]
	theMonth = monthNames[dateObj.getMonth()+1]
	theDate = [dateObj.getDate()+1]
	theYear = dateObj.getYear()
	return ""+theDate+". "+theMonth+" "+theYear+", "+theDay
}
		
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
}
//-->
