<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">

	<head>

		<title>[Neumond / Vollmond]</title>
		
		<!-- Browser speichert keine Seite im Cache -->
		<!-- Browser does not store a page in the cache -->
		<meta http-equiv='cache-control' content='no-cache'>
		<meta http-equiv='expires' content='0'>
		<meta http-equiv='pragma' content='no-cache'>
		
		<style>
		
			/* ******************************
			 * ID des Body Tag Schriftfarbe
			 * und Hintergrundfarbe.
			* ID of the body tag font color
			* and background color.
			 *******************************/
			#b {
				background-color: #293133;
				color: #eadebd;
				border: 0px solid red;
			}
			
			/* ******************************
			 * Tabellenspalten Beschreibung.
			 * Table Columns Description.
			 *******************************/
			#label {
				width: 120px;
				text-align: right;
				font-family: Tahoma,Arial,Helvetica;
				font-size: 14 px;
				font-weight: 500;
			}
			
			/* ******************************
			 * Tabellenspalten Werte.
			 * Table column values.
			 *******************************/
			#value {
				width: 100px;
				text-align: right;
				font-family: Tahoma,Arial,Helvetica;
				font-size: 14 px;
				font-weight: 500;
			}
			
			/* ******************************
			 * Wichtige Werte markieren.
			 * Mark important values.
			 *******************************/
			.color {
				color: red;
			}

			/* ******************************
			 * HTML input-Tag.
			 * HTML-Eingabe-Tag.
			 *******************************/
			input {
				font-family: Tahoma,Arial,Helvetica;
				font-size: 14 px;
				font-weight: 500;
			}
			
			/* ******************************
			 * HTML td-Tag.
			 * HTML-Spalten-Tag der textarea.
			 *******************************/
			#output {
				text-align: center;
			}
			
			/* ******************************
			 * HTML textarea-Tag.
			 * HTML-Textausgabe-Tag.
			 *******************************/
			#text{
				width: 600px;
				height: 300px;
				visibility: hidden;
			}
			
		</style>
		<!-- Muss demarkiert werden, wenn jQuery verwendet werden soll -->
		<!-- Must be demarcated if jQuery is to be used -->
		<script type="text/javascript" src="https://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
		<script>
		
			// Mit der Ausführung warten bis DOM geladen ist.
			// With the execution wait until DOM is loaded.
			document.addEventListener("DOMContentLoaded", function(event) {
				
					/* **************************** Externe Quelldateien Laden *********************************************** */	

					// Funktion zum Einfügen der einzelnen Javascript Dateien.
					// Function to insert the individual Javascript files.
					function include(file) { 
					  var script  = document.createElement('script'); 
					  script.src  = file; 
					  script.type = 'text/javascript'; 
					  script.defer = true; 
					  document.getElementsByTagName('head').item(0).appendChild(script); 
					}
					
					// Variablendefinitionen und Deklarationen ...
					// definitions of variables and declarations ...
					include('./Globale-This.js');
					
					// Keyboard Event Funktionen, die von den Listenern benutzt werden
					// Datei muss hier lokal liegen, da andere Kontrollelemente verwendet werden
					include('./Keyboard.js');
					
					// Keyboard Eventlistener
					// Datei muss hier lokal liegen, da andere Kontrollelemente verwendet werden
					include('./Keyboard-Listener.js');
					
					// Nützliche Funktionen wie Sommerzeit/Winterzeit, Popup Öffnen ...
					// Useful functions like Daylight Savings Time, open popups ...
					include('../../Bibliotheken/Utilities.js');

					// Funktionen zur Berechnungen/Konvertierung des Julianischen Datum
					// Functions for calculations/conversion of the Julian date
					include('../../Bibliotheken/calculateJD.js');

					// Konvertierung von Uhrzeiten
					// Conversion of times
					include('../../Bibliotheken/decTime.js');
					
					// Funktionen für die Mondpositionen
					// Functions for the moon positions
					include('../../Bibliotheken/NewFullMoon.js');
					
					// Funktionen für die Mondpositionen
					// Functions for the moon positions
					include('../../Bibliotheken/Moonpositions.js');
					
					// Funktionen für die Sonnenpositionen
					// Functions for the sun positions
					include('../../Bibliotheken/Sunpositions.js');
					
					// Funktionen für die Sternzeit/Lokale Zeit
					// Functions for the siderial/local time
					include('../../Bibliotheken/SiderialTime.js');
					
					// Funktionen für Sonnen Auf- und Untergang
					// Functions for the sunrise and sunset
					include('../../Bibliotheken/SunRiseSet.js');
					
					// Funktionen für Mond Auf- und Untergang
					// Functions for the moonrise and moonset
					include('../../Bibliotheken/MoonRiseSet.js');
					
					// Funktionen für die Berechnung der Objekthöhe über dem Horizont
					// Functions for calculating the object height above the horizon
					include('../../Bibliotheken/ObjectHeight.js');
				
				// Alles geladen inklusive Bilder.
				// Funktioniert nicht alleine: DOM muss vorher geleden sein und danach erst
				// der Windows Event Load.
				// All loaded including pictures. // Does not work alone: DOM must be leden before and after
				// the Windows Event Load.
				window.addEventListener("load", function(){
					//Füllen der Datumsfelder mit dem aktuellen Datum.
					//Fill the date fields with the current date.
					objDay.value = d.getDate();				// Tag - Day
					objMonth.value = d.getMonth() + 1;	// Monat - Month
					objYear.value = d.getFullYear();		// Jahr - Year
					
					/* ********************** Funktionen die beim Laden ausgeführt werden ************************ */
					/* ******************************** Functions performed at loading ********************************* */
					
					// Teste, ob der Rechner auf Sommer- o. Winterzeit steht ...
					// Test whether the computer is set to summer or winter time . . .
					ISDST = isDST(new Date(objYear.value, objMonth.value, objDay.value, 0, 0, 0, 0));
					// ... und stelle das Ausgabefeld so ein. Sommerzeit = 1, Winterzeit = 0
					// . . . and set the output field like this. DST = 1, winter time = 0
					if (ISDST)objDST.value = 1;	else	objDST.value = 0;
					
					// Ermittle die Zeitzone aus dem Datum des Rechners ...
					// Identify the time zone from the date of the computer.
					TZ = getTZ();
					// ... ist er negativ geht's nach Osten, ansonsten nach Westen und
					// im entsprechenden Ausgabefeld eintragen.
					//
					//. . . is he negative’s going east, otherwise to the west and Enter 
					// in the corresponding output field.
					if (TZ < 0)objTZ.value = Math.abs(TZ);else  objTZ.value = TZ;
					
					
					
					/* ********************** Verwendete/Used Event Listener ************************ */
					
					// Klick auf die Checkbox "Ganzes Jahr" und den Ergebnisstring
					// Löschen und in der Textbox ausgeben.
					// Click on the checkbox “Fully Year” and the result string
 					// Delete  and output in the text box.
					objCalcYear.addEventListener("click", function(){
						// Ausgabe String Löschen und Ausgeben
						//  Output string  delete and output
						s = "";
						objText.value = s;
						// Ausgabe Textarea Aus- und Einblenden
						// Output Textarea  show and hide
						if (objText.style.visibility == "visible"){
							objText.style.visibility = "hidden";
							// Zeigt an, das das Jahr noch nicht berechnet wurde
							// Shows that the year has not yet been calculated
							yearIsCalculated = false;
						}else
							objText.style.visibility = "visible";
					});
					
					// Klick auf den Button "Berechnen" ... Programm startet hier ...
					// Click on the button "Calculate" . . . Program starts here . . .
					objCalc.addEventListener("click", function () {
							// Startet die Berechnung
							// Starts the calculation
							start();
					});
					
					 // Berechnet als Unterfunktion die Neu- und Vollmonde des gesamten Jahres,
					 // wenn die Checkbox aktiviert ist.
					 //  Calculates as a subfunction the new and full moon of the whole year,
 					 //  when the checkbox is activated.
					function calcWholeYear(){
							s += "Monatliche Neu- und Vollmond Berechnung des Jahres: " + objYear.value + "\n";
							s += "Text wird automatisch in der Zwischenablage gespeichert!" + "\n";
							s += "Er kann jederzeit woanders eingefügt werden!" + "\n";
							s += "--------------------------------------------------------\n";
							// ... iteriere durch die Monate des Jahres und berechne für jeden Monat 
							// den Voll- und Neumond ...
							//  ... iterate through the months of the year and work out for each month 
 							// the full and new moon ...
							for(var i = 1; i <= 12; i++){
								// ...nun das Texteingabefeld für den Monat mit Wert 1 .. 12 füllen ...
								//  ...fill the text input field for the month with value 1 .. 12 ...
								objMonth.value = i;
								// ... dann Neu- und Vollmond für den Monat berechnen lassen ...
								//  ... then calculate new and full moon for the month ...
								calcNewFullMoon();
								// ... Ergebnis als Zeile in "s" speichern ...
								// ... Save result as line in “s” ...
								s += "Neumond: " + objNewMoon.value  + " - Vollmond: " + objFullMoon.value + "\n";
								// ... und s in Textarea ausgeben.
								// ... and output s in Textarea.
								objText.value = s;
							}
							// ... Linie als Zeile in "s" speichern ...
							// ... Line as line in “s” ...
							s += "------------------------------------------------------------------------\n";
							// ... und s in Textarea ausgeben.
							// ... and output s in Textarea.
							objText.value = s;
							// Kopiert den Text aus der textArea in die Zwischenablage von Windows
							objText.disabled = false;									// Textfeld editierbar machen.
							objText.focus();													// ... Textfenster im Focus
							objText.select();												// ... dann markieren den gesamten Text ...
							document.execCommand('copy');						// ... und den Text in die Zwischenablage kopieren.
							objText.selectionStart = objText.selectionEnd;	// ... Markierten Text wieder demarkieren.
							objText.disabled = true;									// ... Textfeld nicht mehr editierbar
							
					}// End of calcWholeYear()

					/* ********************************* Programm / Program ******************************* */
					
					// Berechnet als Unterfunktion den Neu- und Vollmond.
					//  Calculates the new and full moon as a subfunction.
					function calcNewFullMoon(){
					
						// ******************************************************** Neumond/ Newmoon ****************************************
									
						// Berechnet das Julianische Datum des Neumondes. Der Wert ist aber nicht das Datum und Uhrzeit
						// des Neumondes. Es ist die Universal Time und muss weiter berechnet werden ...
						// Calculates the Julian date of the new moon. But the value is not the date and time
						// of the New Worlds. It is Universal Time and has to be calculated further. . .
						newmoon = newMoon(objDST.value,  objTZ.value, objDay.value, objMonth.value, objYear.value, objJD, objJD0);
						// ... Wandle das Julianische Datum UT in ein Gegorianisches Datum. Ergebnis im Array
						// mit Index 0 - 2 ...
						// . . . Convert the Julian date UT into a Gegorian date. Result in array 
						// with index 0 - 2 . . .
						dateNewMoon = calcJD2Date(newmoon);
						// ... In dateNewMoon[0] steht der Tag als Dezimalzahl und die Nachkommastellen sind
						// die Uhrzeit ... UT ...
						//. . . In dateNewMoon[0] the day is the decimal number and the decimal places are
						// the time... UT ...
						timeNewMoon = decPart (dateNewMoon[0]);
						// ... Gibt das Datum des Neumonds im Format dd.mm.yyy aus ...
						//. . . Sets the date of the new moon in the format dd. mm. yyy. . .
						objNewMoon.value = LPad(Math.floor(dateNewMoon[0]), 2, "0") + "." + LPad(dateNewMoon[1] , 2, "0")+ "." + LPad(dateNewMoon[2], 4, "0")+ " - ";
						// ... Berechne nun die lokale Zeit aus den Werten der gewandelten Uhrzeit, der 
						// Sommer/Winterzeit, der Zeitzone und dem Datum des
						// berechneten Neumondes. Tag, Monat und Jahr ...
						// ... der Faktor 0.008333 ist die Zeit, die an einer Erdumrundung fehlt, da die sie sich nicht in exakt 24 h
						// dreht ... sie wird der Uhrzeit bei der Berechnung zugeschlagen ...
						//
						// . . . Now calculate the local time from the values of the converted time, the
						// summer/winter time, the time zone and the date of the
						// calculated new moon. Day, month and year . . .
						// . . . the factor 0. 008333 is the time which is missing at one orbit of the earth, because it does not rotate in exactly 24 h
						// . . . it is added to the time in the calculation . . .
						var decLocalTime = ut2LocalTime((timeNewMoon  * 24)+ 0.008333, 0, 0, objDST.value, objTZ.value, Math.floor(dateNewMoon[0]), dateNewMoon[1] , dateNewMoon[2] );
						// ... Danach konvertiere die dezimale Uhrzeit des Neumondes in eine String
						// des Formats hh:mm.ss.ms ...
						//. . . Then convert the decimal time of the new moon into a string
						// of the format hh:mm. ss. ms . . .
						var  strDate = dectime2Time(decLocalTime, "string");
						// und hänge den String an das Datum im Ausgabefeld an.
						// and attach the string to the date in the output field.
						objNewMoon.value +=  strDate;
						
						// ******************************************************** Vollmond/ Fullmoon ****************************************
						
						// Berechnet das Julianische Datum des Vollmondes. Der Wert ist aber nicht das Datum und Uhrzeit
						// des Vollmondes. Es ist die Universal Time und muss weiter berechnet werden ...
						// Calculates the Julian date of the full moon. But the value is not the date and time
						// of the full moon. It is Universal Time and has to be calculated further. . .
						fullmoon = fullMoon(objDST.value,  objTZ.value, objDay.value, objMonth.value, objYear.value, objJD, objJD0);
						// ... Wandle das Julianische Datum UT in ein Gegorianisches Datum. Ergebnis im Array
						// mit Index 0 - 2 ...
						// . . . Convert the Julian date UT into a Gegorian date. Result in array 
						// with index 0 - 2 . . .
						dateFullMoon = calcJD2Date(fullmoon);
						// ... In dateFullMoon[0] steht der Tag als Dezimalzahl und die Nachkommastellen sind
						// die Uhrzeit ... UT ...
						//. . . In dateFullMoon[0] the day is the decimal number and the decimal places are
						// the time... UT ...
						timeFullMoon = decPart (dateFullMoon[0]);
						// ... Gibt das Datum des Neumonds im Format dd.mm.yyy aus ...
						//. . . Sets the date of the new moon in the format dd. mm. yyy. . .
						objFullMoon.value = LPad(Math.floor(dateFullMoon[0]), 2, "0") + "." + LPad(dateFullMoon[1] , 2, "0")+ "." + LPad(dateFullMoon[2], 4, "0")+ " - ";
						// ... Berechne nun die lokale Zeit aus den Werten der gewandelten Uhrzeit, der 
						// Sommer/Winterzeit, der Zeitzone und dem Datum des
						// berechneten Vollmondes. Tag, Monat und Jahr ...
						// ... der Faktor 0.008333 ist die Zeit, die an einer Erdumrundung fehlt, da die sie sich nicht in exakt 24 h
						// dreht ... sie wird der Uhrzeit bei der Berechnung zugeschlagen ...
						//
						// . . . Now calculate the local time from the values of the converted time, the
						// summer/winter time, the time zone and the date of the
						// calculated full moon. Day, month and year . . .
						// . . . the factor 0. 008333 is the time which is missing at one orbit of the earth, because it does not rotate in exactly 24 h
						// . . . it is added to the time in the calculation . . .
						var decLocalTime = ut2LocalTime((timeFullMoon  * 24)+ 0.008333, 0, 0, objDST.value, objTZ.value, Math.floor(dateFullMoon[0]), dateFullMoon[1] , dateFullMoon[2] );
						// ... Danach konvertiere die dezimale Uhrzeit des Neumondes in eine String
						// des Formats hh:mm.ss.ms ...
						//. . . Then convert the decimal time of the new moon into a string
						// of the format hh:mm. ss. ms . . .
						var  strDate = dectime2Time(decLocalTime, "string");
						// und hänge den String an das Datum im Ausgabefeld an.
						// and attach the string to the date in the output field.
						objFullMoon.value +=  strDate;
					
					}// End of calcNewFullMoon()
					
					// Berechnungsstart - Start the calculation
					//
					function start(){
					
						// Prüfe vor dem Berechnungsbeginn noch einmal, ob nicht eine falsche Eingabe des Tages,
						// in Hinblick auf ein Schaltjahr und den Monat Februar, vorgenommen wurde. Dazu kann man
						// die Callback Funktion des Eventlisteners des Tages für die Änderung benutzen.
						// Check again before the calculation starts, if there is a wrong entry of the day, 
						// with regard to a leap year and the month February. To do this, you can use
						// the callback function of the event listener of the day for the change.
						keydownChangeDay(objDay, objMonth, objLeapYear);
						keydownChangeMonth(objMonth);
						keydownChangeYear(objYear, objLeapYear);
						keydownChangeDST(objDST);
						keydownChangeTZ(objTZ);
						
						// Mit der Funktion isLeapYear() und dem Parameter des
						// Berechnungsjahres (objYear.value) , wird festgestellt ob
						// es sich um ein Schaltjahr handelt und dies Ausgegeben.
						//
						// With the function isLeapYear () and the parameter of the
						// Calculation year (objYear. value), is determined whether
						// it is a leap year and this is output.
						if (isLeapYear(objYear.value))objLeapYear.value = "Ja";	else objLeapYear.value = "Nein";
					
						if ( (saveMonth != objMonth.value) || (saveYear != objYear.value) || (saveDay != objDay.value) || (yearIsCalculated == false) ){
							saveDay = parseInt(objDay.value);
							saveMonth = parseInt(objMonth.value);
							saveYear = parseInt(objYear.value);
							// Berechne Neu- und Vollmond ...
							// Calculate the newMoon and fullMoon
							calcNewFullMoon();
							// ... wenn die Checkbox für "Berechnung des ganzen Jahres" markiert ist, dann 
							// berechne alle 12 Monate und gebe das Ergebnis in der Textarea aus...
							//  ...  if the checkbox is marked for “Calculation of the whole year”, then 
							// calculate every 12 months and output the result in the text area...
							if (objCalcYear.checked == true && yearIsCalculated == false) {
									calcWholeYear();
									yearIsCalculated = true;
							} 
							
						} 
						
					}// End of start()

				}); // Ende alles geladen - End of all things loaded
				
			}); // Ende DOM geladen - End of DOM loaded

		</script>
		
	</head>
	
	<body id="b">
	
		<table border="0">
		
			<tr>
				<th id="label" colspan="8">
					<center>Berechnung des Neu- und Vollmond</center>
				</th>
			</tr>
			<tr>
				<td colspan="8">
					 
				</td>
			</tr>
			<tr>
				<td id="label">
						Tag:
				</td>
				
				<td id="value">
					<input id="day" type="text" maxlength="2" value="1"></input>
				</td>

				<td id="label">
					Monat:
				</td>
				
				<td id="value">
						<input id="month" type="text" maxlength="2" value="11"></input>
				</td>

				<td id="label">
					Jahr:
				</td>
				
				<td id="value">
					<input id="year" type="text" maxlength="4" value="2020"></input>
				</td>

				<td id="label" title="Ermittelt automatisch, ob das Jahr ein Schaltjahr ist">
					Schaltjahr:
				</td>
				
				<td id="value">
					<input id="leapyear" title="Ermittelt automatisch, ob das Jahr ein Schaltjahr ist" type="text" value="" disabled="disabled"></input>
				</td>

			</tr>

			<tr>
			
				<td id="label">
					<label title="Daylight Saving Time (Sommer/Winterzeit)">DST:</label>
				</td>
				
				<td  id="value">
					<input title="Daylight Saving Time (Sommer/Winterzeit)" id="dst" type="text" maxlength="1" value="1" ></input>
				</td>
				
				<td id="label">
					<label title="Timezone (Westlich -, Östlich +)">TZ:</label>
				</td>
				
				<td  id="value">
					<input title="Timezone (Westlich -, Östlich +)" id="tz" type="text" maxlength="3" value="0" ></input>
				</td>

			</tr>
			
			<tr>
			
				<td id="label">
					<label title="Julianisches Datum des eingegebenen Datums">JD:</label>
				</td>
				
				<td  id="value">
					<input title="Julianisches Datum des eingegebenen Datums" id="jd" type="text" value="" disabled="disabled"></input>
				</td>
			
				<td id="label">
					<label title="Julianisches Datum des Startdatums der Berechnung">JD<sub>0</sub>:</label>
				</td>
				
				<td  id="value">
					<input title="Julianisches Datum des Startdatums der Berechnung" id="jd0" type="text" value="" disabled="disabled"></input>
				</td>
				
				<td id="label">
					<label title="Datum des Neumonds">Neumond:</label>
				</td>
				
				<td id="value">
					<input class="color"  title="Datum des Neumonds" id="newmoon" type="text" value="dd.mm.yyyy - hh:mm:ss.ms" disabled="disabled"></input>
				</td>
			
				<td id="label">
					<label title="">Vollmond:</label>
				</td>
				
				<td id="value">
					<input  class="color"  title="Datum des Vollmonds" id="fullmoon" type="text" value="dd.mm.yyyy - hh:mm:ss.ms" disabled="disabled"></input>
				</td>
			
			</tr>
			
			<tr>
				<td colspan="8">
					 
				</td>
			</tr>
			
			<tr>
				<td colspan="3">
					 
				</td>
				<td>
					<center><input id="calc" title="Berechnet Neu- und Vollmond anhand des Datums" class="calc" type="button" value="Berechnen"></input></center>
				</td>
				<td >
					<center><input title="Berechnet für jeden Monat Neu- und Vollmond" id="calcyear" class="calcyear" type="checkbox" >Ganzes Jahr</input></center>
				</td>
				<td colspan="3">
					 
				</td>
			</tr>
			
			<tr>
				<td colspan="8">
					 
				</td>
			</tr>
			
			<tr>
				<td id="label" colspan="8">
					<center>Sonnen Auf- und Untergang nach Peter Duffett-Smith und Jonathan Zwart - Practical Astronomy with your Calculator and Spreadsheet</center>
				</td>
			</tr>
			
			<tr>
				<td colspan="8">
					 
				</td>
			</tr>
			
			<tr>
				<td id="output" colspan="8">
					<textarea title="Ausgabe von Neu- und Vollmond für das ganze Jahr"id="text" class="text" disabled="disabled"></textarea>
				</td>
			</tr>
		
		</table>

	</body>

</html>