/*
	Berechnung der Mondparameter zur Berechnung der Mondposition und
	weitere Daten wie größe am Himmel und Entfernung.
	
	Calculation of the lunar parameters to calculate the lunar position; and
	other data such as size in the sky and distance.
*/

// Globale variablen ... Global variables ...

// Array der lokale Zeiten für Mondauf- und Untergang
// Array of locale times or moonrise and -set
var LCTR = [];
var LCTS = [];
// Julianisches Datum für den Mondauf- und Untergang
// Juliane date fot moonrise and -set
var jdMoonRise = 0.0;
var jdMoonSet = 0.0;
// Julianisches Datum für Mondauf- und Untergang ohne Nachkommaanteil = Tageszeit
// Julian date for moonrise and -set without decimal point = time of day
var jdMoonRiseDate = 0.0;
var jdMoonSetDate = 0.0;
// Azimuth und Altitude des Mondauf- und Untergangs
// Azimuth and altitude of moonrise and moonset
var moonRiseAzDec = [];
var moonSetAzDec = [];
// Entfernung Erde - Mond in Km
// Distance Earth - Moon in Km
var moonDist = 0.0;
// Durchmesser des Mondes am Himmel in Grad
// Diameter of the moon in the sky in degrees
var moonDia = 0.0;
// ... Ausgabe der korregierten Länge des Mondes
// ... Output of the corrected length of the Moon
var LStrich = 0.0;
// ... Ausgabe des korregierten Längengrades des Knoten des Mondes N'
// ... Output of the corrected longitude of the node of the Moon N'
var NStrich = 0.0;
// ... Ausgabe der korregierten durchschnittlichen Anomalie des Mondes
// ... Output of the corrected average anomaly of the Moon
var mStrichM = 0.0;
// Berechne den arctan von X/Y (ecliptic Längengrad)und korregiere ihn mit 180/360 Grad um Ihn in den bewünschten
// Bereich zu bekommen
// Calculate the arctan of X/Y (ecliptic longitude)and correct it with 180/360 degrees around it in the desired
// To get area
var LDM = 0.0;
// Berechne den ecliptic Breitengrad des Mondes
// Calculate the ecliptic latitude of the moon
var BM = 0.0;
function moonParameters(jdlt, ra, dec, dst, tz, longitude, latitude, /*moonArray,*/ what){
	var JDLT	=	Number(jdlt);		// Julianisches Datum der Berechnung mit TZ=0 und DST=0,
													// also die lokale Zeit der Berechnung am Beobachtungsort
													// Julian date of calculation with TZ=0 and DST=0,
													// i.e. the local time of the calculation at the observation site
	var daysSinceEpoch = 0.0;		// Anzahl der Tage von der letzten Epoche bis zum aktuellen Datum
													// Number of days from last epoch to current date
	var CENTURY = [];					// Array für den dezimalen Anteil des vergangenen Jahrhunderts
													// Array for the decimal fraction of the past century
	var jdDate = [];						// Array für die einzelnen Datumsdaten des JD, Tag,Zeit, Monat und Jahr 
													// Array for the individual date data of the JD, day,time, month and year
	var jdTime = [];						// Array für die einzelnen Uhrzeiten des JD , Stunde, Minute, Sekunde und Millisekunde
													// Array for the individual times of the JD , hour, minute, second and millisecond
	var jdDay = 0;							// Datumsdaten aus dem JD des Berechnungsdatums
	var jdMonth = 0;						// Date data from the JD of the calculation date
	var jdYear = 0;
	var jdHour = 0;
	var jdMinute = 0;
	var jdSecond = 0;
	var jdMsecond = 0;
	var moonArray = [];					// Array mit den berechneten Daten an bestimmten Indizes. Siehe
													// an den Speicherpunkten unten
													// Array with the calculated data at certain indices. See
													// at the memory points below
	// Aus dem JD des Berechnungsdatums die einzelnen Datums Daten errechnen,
	// indem das JD in ein Datum konvertiert wird, der Tag hat als Dezimalstellen die
	// Uhrzeit ...
	// Calculate the individual date data from the JD of the calculation date,
	// by converting the JD to a date, the day has as decimal places the
	// Time ...
	jdDate = julianDate2Date(JDLT);
	// jdDate[0] ist der Tag als Ganzzahlanteil, mit der Uhrzeit des Tages als Nachkommaanteil ...
	// jdDate[0] is the day as an integer fraction, with the time of the day as a decimal fraction ...
	jdDay = parseInt(jdDate[0] - decPart(jdDate[0]));
	jdMonth = parseInt(jdDate[1]);
	jdYear = parseInt(jdDate[2]);
	// Aus dem JD des Berechnungsdatums die einzelnen Uhrzeit Daten errechnen,
	// indem der jdDate[0] Nachkommaanteil in die Uhrzeit des Tages konvertiert wird ...
	// Calculate the individual time data from the JD of the calculation date,
	// by converting the jdDate[0] decimal portion to the time of day ...
	jdTime = percentageOfDecimal2Time(decPart(jdDate[0]), "array");
	jdHour = parseInt(jdTime[0]);
	jdMinute = parseInt(jdTime[1]);
	jdSecond = parseInt(jdTime[2]);
	jdMsecond = parseInt(jdTime[3]);
	// ... und aus den gerade ermittelten Einzeldaten des Berechnungsdatums die UT berechnen ...
	// dazu wird Sommer/winterzeit und Zeitzone benötigt und eingerechnet ...
	// ... and calculate the UT from the just determined individual data of the calculation date ...
	// summer/winter time and time zone are required and included ...
	var jdDateUT = calcJD(jdDay, jdMonth, jdYear, jdHour,jdMinute, jdSecond, jdMsecond, dst, tz);
	// NICHT AKTIVIERT
	// Wenn der Tag geändert ist, dann berechne diesen Bereich einmal neu ...
	// NOT ENABLED
	// If the tag is changed, then recalculate this area once more ...
	//if ( jdDay != LCTR[3] ){
			//
			// **********************************  Mondaufgang / Moon rise  ********************************************
			//
			// ... und berechne dann den neuen Mond Aufgang ...
			// . . . and then work out the new moon up . . .
			LCTR = moonriseLocalTime(jdDay, jdMonth, jdYear, 
														dst, tz, longitude, latitude);										
			// ... in Index 1 ist der Status der Konvertierung von GST nach UT. Werte sind "Warnung" + "OK ...
			// --- in Index 2 ist der Status des Mondaufgangs und -Untergangs enthalten. Werte sind "OK",
			// "Nie Sichtbar" und "Immer Sichtbar" ...
			// . . . in Index 1 is the conversion status from GST to UT. Values are “Warning” + “OK . . .
			// --- Index 2 includes the status of the moon’s rise and set. Values are “OK”,
			// “Never Visible” and “Always Visible” . . .
			var statGSTandUT_LCTR = LCTR[1].toLowerCase();
			var statRise_LCTR = LCTR[2].toLowerCase();
			// ... und den Monduntergang, bevor die Sonderfälle berechnet werden ...
			// . . . and the moonset before the special cases are calculated . . .
			LCTS = moonsetLocalTime(jdDay, jdMonth, jdYear, 
														dst, tz, longitude, latitude);
			// ... in Index 1 ist der Status der Konvertierung von GST nach UT. Werte sind "Warnung" + "OK ...
			// --- in Index 2 ist der Status des Mondaufgangs und -Untergangs enthalten. Werte sind "OK",
			// "Nie Sichtbar" und "Immer Sichtbar" ...
			// . . . in Index 1 is the conversion status from GST to UT. Values are “Warning” + “OK . . .
			// --- Index 2 includes the status of the moon’s rise and set. Values are “OK”,
			// “Never Visible” and “Always Visible” . . .
			var statGSTandUT_LCTS = LCTS[1].toLowerCase();
			var statSet_LCTS = LCTS[2].toLowerCase();
			// Array zur Sicherung des aktuellen Aufgangszeit, um festzustellen, ob die Berechnung
			// durchgeführt werden muss, wenn etwas Anderes als das Datum geändert wurde ...
			// Array to save the current rise time to determine whether the calculation
			// must be performed if something other than the date has been changed ...
			saveLCTS = LCTS;
			// ... nun das Julianisches Datum des Mondaufgangs ermitteln ...
			// . . . now determine the Julian date of moonrise . . .
			jdMoonRise = calcJD(LCTR[3], LCTR[4], LCTR[5], LCTR[0], 0, 0, 0, 0, 0);
			// ... und nur das Datum des Mondaufgangs, ohne die Tageszeit ermitteln ...
			// ... and only the date of the moonrise, without the time of day ...
			jdMoonRiseDate = jdMoonRise - decPart(jdMoonRise);
			// ... nun das Julianisches Datum des Monduntergangs in Greenwich ermitteln ...
			// . . . now determine the Julian date of the moonset in Greenwich . . .
			jdMoonSet = calcJD(LCTS[3], LCTS[4], LCTS[5], LCTS[0], 0, 0, 0, 0, 0);
			// ... und nur das Datum des Monduntergangs, ohne die Tageszeit ermitteln ...
			// ... and only the date of the moonset, without the time of day ...
			jdMoonSetDate = jdMoonSet - decPart(jdMoonSet);
			// ... im Array LCTR[0] steht der Zeitpunkt des Mondaufgangs als String Dezimalwert, diesen
			// in einen String mit dem Format hh:mm:ss.ms konvertieren und Ausgeben, wenn die Konvertierung
			// von GST nach UT OK ist ...
			// ... im Array LCTR[ 3 - 5] steht Tag, Monat und Jahr des Mondaufgangs ...
			//
			// . . . the array LCTR[0] contains the time of moonrise as a string decimal value, convert this 
			// into a string with the format hh:mm:ss. ms and output . . . 
			// . . . the array LCTR[ 3 - 5] contains day, month and year of moonrise
			if ( (statGSTandUT_LCTR == "ok") &&  (statGSTandUT_LCTS == "ok")||
					 ((statGSTandUT_LCTR == "warnung")||  (statGSTandUT_LCTS == "warnung")  )){
				if ( statRise_LCTR == "ok"){
					if (what == "manual")
						objMoonRiseTime.value = LCTR[3] + "." + LCTR[4] + "." + LCTR[5] + "  "  +  dectime2Time(Number(LCTR[0]), "string");
					else
						// Index 0 = Zeit des Mondaufgangs
						// Index 0 = Time of moonrise
						moonArray.push(LCTR[3] + "." + LCTR[4] + "." + LCTR[5] + "  "  +  dectime2Time(Number(LCTR[0]), "string"));
				// Mond am Südpol
				// Moon at the South Pole
				}else if  ( statRise_LCTR == "nie sichtbar")
					if (what == "manual")
						objMoonRiseTime.value = "Nie Sichtbar";
					else
						// Index 0 = Zeit des Mondaufgangs
						// Index 0 = Time of moonrise
						moonArray.push("Nie Sichtbar");
				// Mond am Nordpol
				// Moon at the Morth Pole
				else if (statRise_LCTR == "immer sichtbar")
					if (what == "manual")
						objMoonRiseTime.value = "Immer Sichtbar";
					else
						moonArray.push("Immer sichtbar")
			}
			// ... im Array LCTR[1] = Sternzeitkonvertierung (GST2UT) + LCTR[2] = Sichtbarkeit und
			// Status der Berechnung des Mondaufgangs ...
			// . . . in the array LCTR[1] = sidereal time conversion (GST2UT) + LCTR[2] = visibility and
			// status of the calculation of the moonrise . . .
			if ( (statGSTandUT_LCTR == "ok") &&  (statGSTandUT_LCTS == "ok")||
					  ((statGSTandUT_LCTR == "warnung")||  (statGSTandUT_LCTS == "warnung")  )){
				if ( statRise_LCTR == "ok")
					if (what == "manual")
						objStateMoonRise.value =  LCTR[1] + " : " + LCTR[2];
					else
						// Index 1 =Status des Mondaufgangs
						// Index 1 = State of moonrise
						moonArray.push(LCTR[1] + " : " + LCTR[2]);
				// Mond am Südpol
				// Moon at the South Pole
				else if  ( statRise_LCTR == "nie sichtbar")
					if (what == "manual")
						objStateMoonRise.value = "Nie Sichtbar";
					else
						// Index 1 =Status des Mondaufgangs
						// Index 1 = State of moonrise
						moonArray.push("Nie Sichtbar");
				// Mond am Nordpol
				// Moon at the Morth Pole
				else if (statRise_LCTR == "immer sichtbar")
					if (what == "manual")
						objStateMoonRise.value = "Immer Sichtbar";
					else
						// Index 1 = Status des Mondaufgangs
						// Index 1 = State of moonrise
						moonArray.push("Immer Sichtbar");
			}
			
	//} // End of if ( jdDay != LCTR[3] )
		
	// Berechnung des Azimuts in dezimalen Grad für den Aufgang ...
	// Calculation of the azimuth in decimal degrees for the rise . . .
	// Berechne aus Stundenwinkel, Deklination und Breitengrad die Höhe eines
	// Index [0] = Der Azimuth in dezimalen Grad
	// 
	// Objekts (Mond ... Sterne ....) über dem Horizont ...
	// Index [1] = Die Höhe über dem Horizont in °, ', ''
	// 
	// Index [2] = Die Höhe (Deklination)über dem Horizont in dezimalen Grad ...
	// 
	moonRiseAzDec = moonRiseAz(jdDay, jdMonth, jdYear, 
														dst, tz, longitude, latitude);
	if ( (statGSTandUT_LCTR == "ok") &&  (statGSTandUT_LCTS == "ok")  ||
	  ((statGSTandUT_LCTR == "warnung")||  (statGSTandUT_LCTS == "warnung")  )){
		if ( statRise_LCTR == "ok"){
			if (what == "manual"){
				objMoonRiseAz.value = moonRiseAzDec[0];
				objMoonRiseAzH.value = moonRiseAzDec[1];
			// Index 0 =	Azimuth des Mondaufgangs
			// Index 0 =	Azimuth of moonrise
			// Index 2 =	Höhe des Mondes beim Aufgang
			// Index 2 =	Altitude of the moon at moonrise
			}else{
				moonArray.push(moonRiseAzDec[0]);
				moonArray.push(moonRiseAzDec[2]);
			}
		// Mond am Südpol
		// Moon at the South Pole
		}else if  ( statRise_LCTR == "nie sichtbar"){
			if (what == "manual"){
				objMoonRiseAzH.value  = "Nie Sichtbar";
				objMoonRiseAz.value = "Nie Sichtbar";
			// Index 2  = Status Azimuth des Mondaufgangs
			// Index 2  = State azimuth of moonrise
			// Index 3  = Status Höhe des Mondaufgangs
			// Index 3  = State altitude of moonrise
			}else{
				moonArray.push("Nie Sichtbar");
				moonArray.push("Nie Sichtbar");
			}
		// Mond am Nordpol
		// Moon at the Morth Pole	
		}else if (statRise_LCTR == "immer sichtbar"){
			if (what == "manual"){
				objMoonRiseAzH.value  = "Immer Sichtbar";
				objMoonRiseAz.value = "Immer Sichtbar";
			// Index 2  = Status Azimuth des Mondaufgangs
			// Index 2  = State azimuth of moonrise
			// Index 3  = Status Höhe des Mondaufgangs
			// Index 3  = State altitude of moonrise
			}else{
				moonArray.push("Immer Sichtbar");
				moonArray.push("Immer Sichtbar");
			}
		}
	}
	//
	// **********************************  Monduntergang / Moon set  ********************************************
	//
	// Berechnung des Azimuts in dezimalen Grad für den Untergang ...
	// Calculation of the azimuth in decimal degrees for the set . . .
	// Berechne aus Stundenwinkel, Deklination und Breitengrad die Höhe eines
	// Der Azimuth in dezimalen Grad
	// Index [0];
	// Objekts (Mond ... Sterne ....) über dem Horizont ...
	// Die Höhe über dem Horizont in °, ', ''
	// Index [1];
	// Die Höhe (Deklination)über dem Horizont in dezimalen Grad ...
	// Index [2];
	//
	// Calculation of the azimuth in decimal degrees for the sinking ...
	// Calculation of the azimuth in decimal degrees for the set . . .
	// Calculate from hour angle, declination and latitude the height of a
	// The azimuth in decimal degrees
	// Index [0];
	// Object (Moon ... Stars ....) above the horizon ...
	// The height above the horizon in °, ', “ 
	// Index [1];
	// The height (declination) above the horizon in decimal degrees ...
	// Index [2];
	moonSetAzDec = moonSetAz(jdDay, jdMonth, jdYear, 
													dst, tz, longitude, latitude);
	if ( (statGSTandUT_LCTR == "ok") &&  (statGSTandUT_LCTS == "ok")||
	  ((statGSTandUT_LCTR == "warnung")||  (statGSTandUT_LCTS == "warnung")  )){
		if ( statSet_LCTS == "ok"){
			if (what == "manual"){
				objMoonSetAz.value = moonSetAzDec[0];
				objMoonSetAzH.value =  moonSetAzDec[1];
			// Index 4  = Azimuth des Monduntergangs
			// Index 4  = State azimuth of moonset
			// Index 5  = Höhe des Monduntergangs
			// Index 5  = Altitude of moonset
			}else{
				moonArray.push(moonSetAzDec[0]);
				moonArray.push(moonSetAzDec[2]);
			}
		// Mond am Südpol
		// Moon at the South Pole
		}else if  ( statSet_LCTS == "nie sichtbar"){
			if (what == "manual"){
				objMoonSetAz.value  = "Nie Sichtbar";
				objMoonSetAzH.value = "Nie Sichtbar";
			// Index 4  = Am Südpol Azimuth nie sichtbar
			// Index 4  = Azimuth never visible at the South Pole
			// Index 5  = Am Südpol Höhe nie sichtbar
			// Index 5  = Altitude never visible at the South Pole
			}else{
				moonArray.push("Nie Sichtbar");
				moonArray.push("Nie Sichtbar");
			}
		// Mond am Nordpol
		// Moon at the Morth Pole
		}else if (statSet_LCTS == "immer sichtbar"){
			if (what == "manual"){
				objMoonSetAz.value  = "Immer Sichtbar";
				objMoonSetAzH.value = "Immer Sichtbar";
			// Index 4  = Am Südpol Azimuth nie sichtbar
			// Index 4  = Azimuth never visible at the South Pole
			// Index 5  = Am Südpol Höhe nie sichtbar
			// Index 5  = Altitude never visible at the South Pole
			}else{
				moonArray.push("Immer Sichtbar");
				moonArray.push("Immer Sichtbar");
			}
		}
	}
	// ... im Array LCTS[0] steht der Zeitpunkt des Monduntergangs als String Dezimalwert, diesen
	// in einen String mit dem Format hh:mm:ss.ms konvertieren und Ausgeben, wenn die Konvertierung
	// von GST nach UT OK ist ...
	// ... im Array LCTS[ 3 - 5] steht Tag, Monat und Jahr des Monduntergangs ...
	//
	// . . . in the array LCTS[0] the time of the moonset is set as a string decimal value,
	// convert to a string with the format hh:mm:ss. ms and output . . .
	// . . . in the array LCTS[ 3 – 5] there is day, month and year of the moonset . . .
	if ( (statGSTandUT_LCTR == "ok") &&  (statGSTandUT_LCTS == "ok")||
	  ((statGSTandUT_LCTR == "warnung")||  (statGSTandUT_LCTS == "warnung")  )){
		// Index 6  = Zeit des Monduntergangs
		// Index 6  = Time of the moonset
		if ( statSet_LCTS == "ok"){
			if (what == "manual")
				objMoonSetTime.value = LCTS[3] + "." + LCTS[4] + "." + LCTS[5] + "  "  +  dectime2Time(Number(LCTS[0]), "string");
			else
				moonArray.push(LCTS[3] + "." + LCTS[4] + "." + LCTS[5] + "  "  +  dectime2Time(Number(LCTS[0]), "string"));
	// Mond am Südpol
	// Moon at the South Pole
	}else if  ( statSet_LCTS == "nie sichtbar"){
		if (what == "manual")
			objMoonSetTime.value = "Nie Sichtbar";
		else{
			moonArray.push("Nie Sichtbar");
		}
	// Mond am Nordpol
	// Moon at the Morth Pole
	}else if (statSet_LCTS == "immer sichtbar"){
		if (what == "manual")
			objMoonSetTime.value = "Immer Sichtbar";
		else{
			moonArray.push("Immer Sichtbar");
		}
	}
}
		// ... im Array LCTS[1] = Sternzeitkonvertierung (GST2UT) + LCTS[2] = Sichtbarkeit und
		// Status der Berechnung des Monduntergangs ...
		// . . . in the array LCTS[1] = sidereal time conversion GST2UT + LCTS[2] = visibility and
		// status of the calculation of the moonset . . .
	if ( (statGSTandUT_LCTR == "ok") &&  (statGSTandUT_LCTS == "ok")||
	  ((statGSTandUT_LCTR == "warnung")||  (statGSTandUT_LCTS == "warnung")  )){
		// Index 7  = Status des Monduntergangs
		// Index 7  = State of the moonset
		if ( statSet_LCTS == "ok"){
			if (what == "manual")
				objStateMoonSet.value =  LCTS[1] + " : " + LCTS[2];
			else
				moonArray.push(LCTS[1] + " : " + LCTS[2]);
		// Mond am Südpol
		// Moon at the South Pole	
		}else if  ( statSet_LCTS == "nie sichtbar" ){
			if (what == "manual")
				objStateMoonSet.value = "Nie Sichtbar";
			else
				moonArray.push("Nie Sichtbar");
		// Mond am Nordpol
		// Moon at the Morth Pole
		}else if (statSet_LCTS == "immer sichtbar" ){
			if (what == "manual")
				objStateMoonSet.value = "Immer Sichtbar";
			else
				moonArray.push("Immer Sichtbar");
		}
	}
	//
	// **********************************  Mondhöchststand / Moon highest point  ********************************************
	//
	var jdMoonRiseSetDiff = 0.0;
	var highAz = 0.0;
	// ... Wenn der Monduntergang vor dem Mondaufgang liegt und beises am selben Tag ...
	// ... If the moonset is before the moonrise and both on the same day ... .
	if ( (jdMoonSet < jdMoonRise) && (jdMoonSetDate == jdMoonRiseDate) ){
			// Differenz zwischen Mondaufgang und Monduntergang als Julianisches Datum
			// Difference between moonrise and moonset as Julian date
			jdMoonRiseSetDiff = jdMoonRise - jdMoonSet;
			// ... die Differnez / 2 ergibt das JD des Mondstandes am höchsten Punkt, genau
			// in der Mitte der Sichtbarkeit ...
			// . . . the Differnez / 2 gives the JD of the moon's position at the highest point, exactly 
			// in the middle of the visibility . . .
			var jdMoonRiseSetHalf = jdMoonRiseSetDiff / 2 ;
			// ... und das JD des Mondaufgangs + die Hälfte ergibt das JD der Mitte der Sichtbarkeit
			// am höchsten Punkt des Mondes am Himmel ...
			// . . . and the JD of moonrise + half gives the JD of the center of visibility 
			// at the highest point of the moon in the sky . . .
			var jdMoonRiseSetHalfDate = jdMoonSet + jdMoonRiseSetHalf ;
			// Wert des Azimuth des Mondhöchst/Tiefststandes bei einmaliger Berechnung
			// Value of the azimuth of the moon’s highest/lowest with a single calculation
			if (what == "manual")
				highAz = (Number(objMoonRiseAz.value ) + ((Number(objMoonSetAz.value) -  Number(objMoonRiseAz.value)) / 2 ));
		// Mondaufgang liegt vor dem Monduntergang am selben Tag ...
		// Moonrise is before moonset on the same day ...
		}else if ( (jdMoonRise < jdMoonSet) && (jdMoonSetDate == jdMoonRiseDate) ){
			// ... und die Zeit zwischen Mondaufgang und Monduntergang berechnen ...
			// ... and calculate the time between moonrise and moonset ...
			jdMoonRiseSetDiff = jdMoonSet - jdMoonRise;
			// ... die Differnez / 2 ergibt das JD des Mondstandes am höchsten Punkt, genau
			// in der Mitte der Sichtbarkeit ...
			// . . . the Differnez / 2 gives the JD of the moon's position at the highest point, exactly 
			// in the middle of the visibility . . .
			var jdMoonRiseSetHalf = jdMoonRiseSetDiff / 2 ;
			// ... und das JD des Mondaufgangs + die Hälfte ergibt das JD der Mitte der Sichtbarkeit
			// am höchsten Punkt des Mondes am Himmel ...
			// . . . and the JD of moonrise + half gives the JD of the center of visibility 
			// at the highest point of the moon in the sky . . .
			var jdMoonRiseSetHalfDate = jdMoonRise + jdMoonRiseSetHalf ;
			// Wert des Azimuth des Mondhöchst/Tiefststandes bei einmaliger Berechnung
			// Value of the azimuth of the moon’s highest/lowest with a single calculation
			if (what == "manual")
				highAz = (Number(objMoonRiseAz.value ) + ((Number(objMoonSetAz.value) -  Number(objMoonRiseAz.value)) / 2 ));
		// Mondaufgang liegt vor dem Monduntergang und Monduntergangstag ist am nächsten Tag ...
		// Moonrise is before moonset and moonset day is the next day ...
		}else if ( (jdMoonRise < jdMoonSet) && (jdMoonSetDate > jdMoonRiseDate) ){
			// ... und die Zeit zwischen Mondaufgang und Monduntergang berechnen ...
			// ... and calculate the time between moonrise and moonset ...
			jdMoonRiseSetDiff = jdMoonSet - jdMoonRise;
			// ... die Differnez / 2 ergibt das JD des Mondstandes am höchsten Punkt, genau
			// in der Mitte der Sichtbarkeit ...
			// . . . the Differnez / 2 gives the JD of the moon's position at the highest point, exactly 
			// in the middle of the visibility . . .
			var jdMoonRiseSetHalf = jdMoonRiseSetDiff / 2 ;
			// ... und das JD des Mondaufgangs + die Hälfte ergibt das JD der Mitte der Sichtbarkeit
			// am höchsten Punkt des Mondes am Himmel ...
			// . . . and the JD of moonrise + half gives the JD of the center of visibility 
			// at the highest point of the moon in the sky . . .
			var jdMoonRiseSetHalfDate = jdMoonRise + jdMoonRiseSetHalf ;
			// Wert des Azimuth des Mondhöchst/Tiefststandes bei einmaliger Berechnung
			// Value of the azimuth of the moon’s highest/lowest with a single calculation
			if (what == "manual")
				highAz = (Number(objMoonRiseAz.value ) + ((Number(objMoonSetAz.value) -  Number(objMoonRiseAz.value)) / 2 ));
		// Monduntergang liegt vor dem Mondaufgang und Monduntergangstag liegt am Tag vor vot dem Mondaufgang ...
		// Moonset is before moonrise and moonset day is the day before moonrise ...
		}else if((jdMoonSet < jdMoonRise) && (jdMoonSetDate < jdMoonRiseDate)){
			// ... und die Zeit zwischen Mondaufgang und Monduntergang berechnen ...
			// ... and calculate the time between moonrise and moonset ...
			jdMoonRiseSetDiff = jdMoonRise - jdMoonSet;
			// ... die Differnez / 2 ergibt das JD des Mondstandes am höchsten Punkt, genau
			// in der Mitte der Sichtbarkeit ...
			// . . . the Differnez / 2 gives the JD of the moon's position at the highest point, exactly 
			// in the middle of the visibility . . .
			var jdMoonRiseSetHalf = jdMoonRiseSetDiff / 2 ;
			// ... und das JD des Mondaufgangs + die Hälfte ergibt das JD der Mitte der Sichtbarkeit
			// am höchsten Punkt des Mondes am Himmel ...
			// . . . and the JD of moonrise + half gives the JD of the center of visibility 
			// at the highest point of the moon in the sky . . .
			var jdMoonRiseSetHalfDate = jdMoonSet + jdMoonRiseSetHalf ;
			// Wert des Azimuth des Mondhöchst/Tiefststandes bei einmaliger Berechnung
			// Value of the azimuth of the moon’s highest/lowest with a single calculation
			if (what == "manual")
				highAz = unwindDeg(Number(objMoonSetAz.value ) + Number(objMoonRiseAz.value) );
		}// End of if ( (jdMoonSet < jdMoonRise) && (jdM....)
		// ... dann aus dem JD des höchsten Punkts am Himmel wieder ein Datum berechnen ...
		// . . . then calculate a date again from the JD of the highest point in the sky . . .
		var arrjdMoonRiseSetHalfDate = julianDate2Date(jdMoonRiseSetHalfDate);
		// Ausgabe des Datums und Uhrzeit im Zenith, wenn der Status der Konvertierung von
		// GST zu UT beim Auf- und Untergang OK ist ... 
		if ( (statGSTandUT_LCTR == "ok") &&  (statGSTandUT_LCTS == "ok")||
					  ((statGSTandUT_LCTR == "warnung")||  (statGSTandUT_LCTS == "warnung")  )){
			// Index 8  = Datum und Uhrzeit des Mondhöchststands
			// Index 8  = Date and time of the moon’s maximum
			if (what == "manual"){
				objMoonHighDate.value = Math.floor(arrjdMoonRiseSetHalfDate[0]) + "." + arrjdMoonRiseSetHalfDate[1] + "." + arrjdMoonRiseSetHalfDate[2] +
															" " +  percentageOfDecimal2Time((arrjdMoonRiseSetHalfDate[0] - Math.floor(arrjdMoonRiseSetHalfDate[0])), "string");
			}else{
				moonArray.push(Math.floor(arrjdMoonRiseSetHalfDate[0]) + "." + arrjdMoonRiseSetHalfDate[1] + "." + arrjdMoonRiseSetHalfDate[2] +
															" " +  percentageOfDecimal2Time((arrjdMoonRiseSetHalfDate[0] - Math.floor(arrjdMoonRiseSetHalfDate[0])), "string"));
			}

		}
		// Berechnung des Azimuths beim Höchststand (Apogee) in der Mitte des sichtbaren Bogens.
		// Calculation of the azimuth at the peak (apogee) in the middle of the visible arc.
		if ( (statGSTandUT_LCTR == "ok") &&  (statGSTandUT_LCTS == "ok")||
		  ((statGSTandUT_LCTR == "warnung")||  (statGSTandUT_LCTS == "warnung")  )){
			// Index 9  = Der Azimuth beim Mondhöchststand
			// Index 9  = The azimuth at the moon’s highest point
			if (what == "manual")
				objMoonHighAz.value = highAz;
			else
				moonArray.push(highAz);

	}
	// Das Datum des Mondhöchststandes als Array, um die neue äquatoriale Mondposition berechnen zu können ...
	// The date of the moon,s highest position as an array to calculate the new equatorial position of the moon . . .
	var arrMoonHighAzDate = percentageOfDecimal2Time((arrjdMoonRiseSetHalfDate[0] - Math.floor(arrjdMoonRiseSetHalfDate[0])), "array");
	// ... und aus den einzelnen Mond Höchstzeiten die UT berechnen ...
	// ... and calculate the UT from the individual moon maximum times ...
	var utHigh = Number(arrMoonHighAzDate[0]) + Number(arrMoonHighAzDate[1] /60) + Number(arrMoonHighAzDate[2] / 3600)
						+ Number(arrMoonHighAzDate[3] / 3600000) - (dst+tz);
	// Berechne die äquatoriale Position des Mondhöchststandes
	// calculate the equatorial position of the moons highest position
	var newPos = precMoonPos(arrMoonHighAzDate[0], arrMoonHighAzDate[1], arrMoonHighAzDate[2],	arrMoonHighAzDate[3],
												arrjdMoonRiseSetHalfDate[0], arrjdMoonRiseSetHalfDate[1], arrjdMoonRiseSetHalfDate[2], 
												dst, tz);
	// ... und dann das Julianische Datum 	zum Mondhöchststand berechnen ...
	// ... and then calculate the Julian date to the moon’s highest position ...
	var highjdlt = calcJD((arrjdMoonRiseSetHalfDate[0] - decPart(arrjdMoonRiseSetHalfDate[0])), arrjdMoonRiseSetHalfDate[1], arrjdMoonRiseSetHalfDate[2],
									arrMoonHighAzDate[0], arrMoonHighAzDate[1], arrMoonHighAzDate[2], arrMoonHighAzDate[3],0, 0);
	// Grösste Höhe des Mondes über dem Horizont ausgeben ...
	// Output of the highest altitude of the Moon above the horizon . . .
	var horAZAlt = equ2Hor(newPos[0] * 15.0 , newPos[1], latitude, longitude, highjdlt, jdYear, utHigh);
	// Index 10  = Die geozentrische Höhe des Mondes über dem Horizont
	// Index 10  = The geocentric height of the Moon above the horizon
	if (what == "manual")
		objMoonHighDeg.value = horAZAlt[1];
	else
		moonArray.push( horAZAlt[1]);
	// Berechne die 2 Universalzeit (UT) anhand des aktuellen Berechnungsdatums mit Julianischem Datum
	// Das Ergebnis ist ein Array mit den Werten und Format:
	// jdDateUT2[0] = Tag des Datums und der Uhrzeit als Nachkommastellen
	// jdDateUT2[1] = Monat
	// jdDateUT2[2] = Jahr
	// Calculate the Universal Time (UT) using the current calculation date with Julian date
	// The result is an array with the values and format:
	// jdDateUT2[0] = day of date and time as decimal places
	// jdDateUT2[1] = month
	// jdDateUT2[2] = year
	var jdDateUT2 = calcJD2Date(Number(jdDateUT));
	// Die Nachkommastellen des Julianischen Datums ermitteln ...
	// Identify the decimals of the Julian date. . .
	var decUT = jdDateUT2[0] - Math.floor(jdDateUT2[0]);
	// ... und daraus die UT berechnen ...
	// ... and calculate the UT from this ...
	var UT = decUT * 24.0;
	// Berechne die Tage seit dem Berechnungsjahr vom 0.1.2010 00:00:00 Uhr Greenwich an.
	// Calculate the days since the calculation year of 0.1.2010 00:00:00 Greenwich.
	var daysSinceEpoche = 	calcDaysSinceEpoch(2010, jdDay, jdMonth, jdYear);
	// ... und den Anzeil der Uhrzeit UT an diesem Tage hinzuaddieren
	// ... and add the time display UT on this day
	daysSinceEpoche = daysSinceEpoche + UT/24.0;
	
	// ************* Mondpositionen berechnen - Calculate moon positions *****************
		
	// Berechnen der durchschnittlichen Länge l des Mondes  ...
	// Calculate the average length l of the Moon ...
	var averageLMoon = moonAverageLengthL(daysSinceEpoche, l0_moon);
	// ... und die durchschnittliche Anomalie des Mondes Mm...
	// ... and the average anomaly of the Moon Mm...
	var averageAnomalyMoon = moonAverageAnomaly(averageLMoon, daysSinceEpoche);
	// Berechne die Hilfsgroesse N anhand der vergangenen Tage seit
	// Epochenbeginn
	// Calculate the auxiliary size N from the last days since
	// Beginning of the epoch
	var N = calculateN(daysSinceEpoche);
	// Berechnung der 2-ten mittleren Sonne anhand der Hilfsgroesse N.
	// Calculation of the 2nd mean Sun based on the auxiliary magnitude N.
	var Msun2 = mediumSun2(N, epsilong, omegag );
	// Berechnung von Ec als Hilfsgrösse
	// Calculation of Ec as auxiliary variable
	var Ec = calculateEc(e, Msun2);
	// Berechnet den ekliptischen Längengrad der Sonne
	// Calculates the ecliptic longitude of the Sun
	var LDSun = lambdaSun(N, Ec, epsilong);
	// ... und die Jahresgleichung der mittleren Sonne ...
	// ... and the equation of the mean sun ...
	var Ye = yearEquation(Msun2);
	// ... und die dritte Korrektur der mittleren Sonne ...
	// ... and the third correction of the middle sun ...
	var A3 = a3(Msun2);
	// ... und die Korrektur der Evektion des Mondes Ev ...
	// ... and the correction of the evection of the moon Ev ...
	var evectionMoon = correctionsForEvection(Number(averageAnomalyMoon), Number(averageLMoon),  Number(LDSun));
	// ... Ausgabe der korregierten durchschnittlichen Anomalie des Mondes m'M
	// ... Output of the corrected average anomaly of the Moon m’M
	mStrichM = moonAverageAnomalyCorrected(averageAnomalyMoon, evectionMoon, Ye, A3);
	// Berechnen der durchschnittlichen Länge N des Mondes N  ...
	// Calculate the average length N of the Moon N ...
	var averageNMoon = moonAverageLengthN(daysSinceEpoche);
	//console.log("averageNMoon=" + averageNMoon);
	// ... Ausgabe des korregierten Längengrades des Knoten des Mondes N'
	NStrich = correctedLongitudeOfTheMoon(averageNMoon, Msun2);
	// ... Ausgabe der Korrektur der Gleichung der Mitte
	// ... Output of the correction of the equation of the center
	var ECM = equationOfMiddle(mStrichM);
	// ... Ausgabe der 4-ten Korrektur der Länge des Mondes
	// ... Output of the 4th correction of the length of the Moon
	var A4 = a4(mStrichM);
	// ... Ausgabe der korregierten Länge des Mondes l'
	// ... Output of the corrected length of the Moon l'
	LStrich = correctedLengthOfTheMoon(averageLMoon, evectionMoon, ECM, Ye,  A4);
	// ... Ausgabe der Korrektur V für Variation der wahren  Länge des Mondes
	// ... Output of correction V for variation of the true length of the Moon
	var V = variationV(LStrich, LDSun);
	// ... Ausgabe der wahren Längengrades l" des Mondes
	// ... Output of the true longitude l'' of the Moon
	var LStrichStrich = trueLongitudeOfTheMoon(LStrich, V);
	// Berechnung des X/Y-Wertes für den Längengrad des Mondes aus der Ekliptik
	// xy = Array mit 2 Werten
	// xy[1] = X xy[0] = Y
	// Calculation of the X/Y value for the longitude of the moon from the ecliptic
	// xy = Array with 2 values
	// xy[1] = X xy[0] = Y
	var xy = valueXYforEclipticLongitudeOfTheMoon(LStrichStrich, NStrich);
	// Berechne den arctan von X/Y (ecliptic Längengrad)und korregiere ihn mit 180/360 Grad um Ihn in den bewünschten
	// Bereich zu bekommen
	// Calculate the arctan of X/Y (ecliptic longitude)and correct it with 180/360 degrees around it in the desired
	// To get area
	LDM = eclipticLongitudeOfTheMoon(xy[1], xy[0], NStrich);
	// Berechne den ecliptic Breitengrad des Mondes
	// Calculate the ecliptic latitude of the moon
	BM = eclipticLatitudeOfTheMoon(LStrichStrich, NStrich, i_moon);
	// Berechnung der aktuellen Position des Mondes am Himmel
	// Calculation of the current position of the Moon in the sky
	moonArray = calcAzimuthAndAltitude(jdlt, jdMoonRise, jdMoonSet, LCTR[3], LCTS[3], jdDay, jdMonth, jdYear, 
											jdHour, jdMinute, jdSecond, jdMsecond, dst, tz, longitude, latitude,
											LDM, BM, averageLMoon, UT, daysSinceEpoche, moonArray, what);

	// Berechnung ds Mondabstandes
	// Calculation of the Moon’s Distance
	var moonDist = moonDistance( jdHour, jdMinute, jdSecond, dst, tz, jdDay, jdMonth, jdYear);
	// Index 13  = Die Entfernung Erde-Mond
	// Index 13  = The distance Earth-Moon
	if (what == "manual")
		objDistMoon.value = moonDist;
	else
		moonArray.push(moonDist);
	// Berechnung der größe des Mondes am Himmel in Grad ...
	// Calculation of the size of the moon in the sky in degrees ...
	var moonDia = moonDiameter(  jdHour, jdMinute, jdSecond, dst, tz, jdDay, jdMonth, jdYear);
	// Index 14  = Durchmesser des Mondes am Himmel in Grad
	// Index 14  = Diameter of the Moon in the Sky in degrees
	if (what == "manual")
		objDiaMoon.value = moonDia;
	else
		moonArray.push(moonDia);
	// Zu sendender String an das Hauptausgabefenster an den Aufrufer zurück
	// String to be sent to the main output window back to the caller
	return(moonArray);
	
	// Funktion in der Funktion am Ende 
	// Berechnung der aktuellen Position des Mondes am Himmel innerhalb einer internen Funktion in
	// moonParameters()
	// Calculation of the current position of the Moon in the sky within an internal function in
	// moonParameters () 
	function calcAzimuthAndAltitude(jdlt, jdMoonRise, jdMoonSet, dayRise, daySet, jdDay, jdMonth, jdYear, 
														jdHour, jdMinute, jdSecond, jdMsecond, dst, tz, longitude, glatDeg, 
														LDM, BM, averageLMoon, UT, daysSinceEpoche, moonArray, what){
		// Berechnung der äquatorial Koordinaten RA und Dec  aus dem ekliptischen Längengrad Lambda und
		// der ekliptischen Breite Beta zu dem Berechnungszeitpunkt ...
		// Calculation of the equatorial coordinates RA and Dec from the ecliptic longitude lambda and
		// the ecliptic latitude beta at the time of calculation ...
		//var equRA = eclipticCoords2EquatorialRA(LDM, 0, 0, BM, 0, 0, jdDay, jdMonth, jdYear);
		//var equDec = eclipticCoords2EquatorialDec(LDM, 0, 0, BM, 0, 0, jdDay, jdMonth, jdYear);
		// Als nächstes berechnen wir die rechteckigen Ekliptikkoordinaten des Mondes und rotieren sie, um rechtwinckelige
		// Äquatorialkoordinaten ...
		// Next we calculate the rectangular ecliptic coordinates of the Moon and rotate them to right-angled
		// Equatorial coordinates ...
		var xm2eclip = (1 * Math.cos(LDM / RAD) * Math. cos(BM / RAD)).toFixed(6);
		var ym2eclip = (1 * Math.sin(LDM / RAD) * Math.cos(BM / RAD)).toFixed(6);
		var zm2eclip = (1 * Math.sin(BM / RAD)).toFixed(6);
		// Berechnung der ekliptischen Schiefe ...
		// Calculation of the ecliptic slope ...
		var oblecl = eclipticObliquity(jdDay, jdMonth, jdYear);
		// Rotieren in rechtwinkelige ekliptischen Koordinaten in Äquatoriale Koordinaten
		var xm2equat = xm2eclip;
		var ym2equat = (ym2eclip * Math.cos(oblecl / RAD) - zm2eclip * Math.sin(oblecl / RAD)).toFixed(6);
		var zm2equat = (ym2eclip * Math.sin(oblecl / RAD) + zm2eclip * Math.cos(oblecl / RAD)).toFixed(6);
		// Und dann geozentrische RA und Dec berechnen ...
		// And then calculate geocentric RA and Dec ...
		var geoRA   = Math.atan2( ym2equat, xm2equat );
		geoRA = unwindDeg(geoRA * RAD).toFixed(4);
		// Berechnung der geozentrischen Deklination aus den Äquatorial-Koordinaten ...
		// Calculation of the geocentric declination from the equatorial coordinates ...
		var geoDecl = ((Math.atan2( zm2equat, Math.sqrt( xm2equat*xm2equat + ym2equat*ym2equat ) )) * RAD).toFixed(4);
		// Berechnung des Teils des vergangenen Jahrhunderts als Dezimalzahl von 0.0 - 1.0 ...
		// Calculate the part of the last century as a decimal from 0.0 – 1.0 ...
		var T = partOfTheCentury(jdYear, jdlt);
		// Berechnung der Sternzeit in Greenwich um 0h ...
		// Calculation of the stardate in Greenwich at 0h ...
		var GMST0 =  100.46061837 + (36000.770053608 * Number(T[1])) + (0.000387933 * Math.pow(Number(T[1]), 2)) - (Math.pow(Number(T[1]), 3) / 38710000);
		GMST0 = unwindDeg(GMST0 + (15 * (1.00273790935 * UT)));
		// Berechnung der lokalen Sternzeit am Ort der Beobachtung ...
		// Calculation of the local stardate at the place of observation ...
		var LMSTG = unwindDeg(Number(GMST0) + Number(longitude));
		// Berechnung der Höhe des Objekts in Grad ...
		// Calculate the height of the object in degrees ...
		var Alt = Math.asin( ( Math.sin(glatDeg / RAD) * Math.sin(geoDecl / RAD) ) + ( Math.cos(glatDeg / RAD) * Math.cos(geoDecl / RAD) *  Math.cos( (LMSTG - geoRA) / RAD) ) ) * RAD;
		// ... und dazu noch die Refraktion der Atmosphäre in Grad einrechnen ...
		// ...  and also calculate the refraction of the atmosphere in degrees ...
		var R = 1.02 / Math.tan(Alt + (10.3/ (Alt + 5.11)) /  RAD );
		Alt = Alt + R / 60.0;
		// Index 11  = Der aktuelle Höhe des Mondes über dem Horizont in Grad
		// Index 11  = The actual altitude of thh moon above horizon in degrees
		if (what == "manual")
			objHMoon.value = Alt;
		else
			moonArray.push(Alt)
		// Berechnung der X/Y-Werte für die tan()-Funktion des Azimuths ...
		// Calculation of the X/Y values for the tan () function of the azimuth ...
		var dy = ( Math.sin( (LMSTG - geoRA) / RAD) );
		var dx = ( Math.sin(glatDeg / RAD) * Math.cos( (LMSTG - geoRA) / RAD )) - (Math.cos(glatDeg / RAD) * Math.tan(geoDecl / RAD) );
		// Korrektur des Ergebnisses, da bein Tangens die Quadranten I. + III. sowie II. + IV. dieselben Werte ergeben.
		// Es muss nach Quadrant selektiert werden und dazu werden der Y-Wert und der X-Wert verwendet ...
		// Correction of the result, since tangent the quadrants I. + III. and II. + IV. give the same values.
		// It must be selected by quadrant using the Y-value and the X-value ...
		var AZ = 0.0;
		// I. Quadrant
		if ( dx > 0.0 && dy > 0.0){ 
			AZ = (Math.atan( dy / dx) + Math.PI) * RAD;
		// II. Quadrant
		}else if ( dx < 0.0 && dy > 0.0){
			AZ = (Math.atan( dy / dx) + (2 * Math.PI)) * RAD;
		// III. Quadrant
		}else if ( dx < 0.0 && dy < 0.0){
			AZ = Math.atan( dy / dx)  * RAD;
		// IV. Quadrant
		}else if ( dx > 0.0 && dy < 0.0){
			AZ = (Math.atan( dy / dx) + Math.PI) * RAD;
		}
		// ... dann noch die Sonderfälle der Null-Werte bei X und Y, da die Tangenswerte unendlich werden ...
		// ... then the special cases of the zero values at X and Y, since the tangent values become infinite ...
		if (dx == 0.&& dy > 0.0)
			AZ = 90.0;
		else if (dx == 0.0 && dy < 0.0)
			AZ = 180.0;
		else if (dx < 0.0 && dy == 0.0)
			AZ =  270.0;
		else if ( dx > 0.0 && dy == 0.0)
			AZ =  360.0;
		// Das Ergebnis im Textfeld "Azimuth" ausgeben ...
		// Display the result in the text field “Azimuth” ...
		// Index 12  = Der aktuelle Azimuth des Mondes in Grad
		// Index 12  = The actual azimuth of teh moon in degrees
		if (what == "manual")
			objAzMoon.value = AZ;
		else
			moonArray.push(AZ);
		// Mond unter dem Horizont und Text in Rot sowie Hilfetext erweitern ...
		// Moon under the horizon and text in red and help text expand ...
		if (Alt < 0.0){
			if (what == "manual"){
				objAzMoon.style.color = "red";
				objHMoon.style.color = "red";
				objAzMoon.title = "Der geozentrische Azimuth des Mondes von N->W im horizontalen Koordinatensystem" + " - Mond ist unter dem Horizont!";
				objHMoon.title = "Die geozentrische Höhe des Mondes über dem Horizont im horizontalen Koordinatensystem" + " - Mond ist unter dem Horizont!";
			}
		// Mond über dem Horizont und Text in Rot sowie Hilfetext erweitern ...
		// Moon over the horizon and text in red and help text expand ...
		}else{
			if (what == "manual"){
				objAzMoon.style.color = "green";
				objHMoon.style.color = "green";
				objAzMoon.title = "Der geozentrische Azimuth des Mondes von N->W im horizontalen Koordinatensystem" + " - Mond ist ueber dem Horizont!";
				objHMoon.title = "Die geozentrische Höhe des Mondes über dem Horizont im horizontalen Koordinatensystem" + " - Mond ist ueber dem Horizont!";
			}
		}

		/* ********************** Alternative Funktionen **********************************************
		var equRADec = eclip2EquRaDec(LDM, BM, jdDay, jdMonth, jdYear);
		console.log("equRADec=" + equRADec);
		
		// Fehlerhafte Funktion
		var equEclip = equ2Eclip(equRADec[0] , equRADec[1], jdDay, jdMonth, jdYear);
		console.log("Lambda=" + LDM + " Beta=" + BM + " equEclip=" + equEclip);
		
		var horAlt = equ2HorAlt(equRADec[0] , equRADec[1], glatDeg, longitude, jdlt, jdYear, UT);
		console.log("horAlt=" +  horAlt);
		
		var horAZ = equ2HorAZ(equRADec[0] , equRADec[1], glatDeg, longitude, jdlt, jdYear, UT);
		console.log("horAZ=" +  horAZ);
		
		var horAZAlt1 = convertEquatorial2Horizontal(equRADec[0] , equRADec[1], glatDeg);
		console.log("horAZAlt1 RA=" + equRADec[0] + " Dec=" + equRADec[1] + " Latitude=" + glatDeg);
		console.log("horAZAlt1=" + horAZAlt1);
		
		var horAZAlt = equ2Hor(equRADec[0] , equRADec[1], glatDeg, longitude, jdlt, jdYear, UT);
		console.log("horAZAlt=" + horAZAlt);
		
		 **************************************************************************************************** */
		// Zurück zum Aufrufer moonParameters().
		// Return to the caller moonParameters ().
		return(moonArray);
		
	}// End of calcAzimuthAndAltutude()
	
	
	
	
	/*	*********************************************************************************************
	Die Funktion berechnet den ekliptischen Längengrad (Lamda)der Sonne. der
	ekliptische Breitengrad der Sonne ist ja 0.0, da sie in der Ekliptik liegt.
	
	Quelle:
	https://de.wikipedia.org/wiki/Astronomische_Koordinatensysteme
	
	Übergabewert:
	N														= 	Aktuell berechnete Position in Grad 0° - 360°
																als Number
	ec														= 	Korrekturwert
	epsilong											=	Die mittlere eklipt. Längengrad der Sonne

	
	Rückgabewert:
	Ekliptischer Längengrad Sonne		= 	Als aktuelle Position in Grad bei kreisförmigem Orbit
																0° - 360°
	----------------------------------------------------------------------------------------------------------
	The function calculates the ecliptic longitude (Lamda) of the sun. the ecliptic 
	latitude of the sun is 0. 0, since it lies in the ecliptic. 
	
	Source: https://de. wikipedia. org/wiki/Astronomische_Koordinatensysteme 
	
	Transfer value: 
	N 														= Current calculated position in degrees 0° - 360° as Number 
	ec 													= Correction value 
	epsilong 											= The mean eklipt. Longitude of the sun 
	
	Return value: 
	Ecliptic longitude of the sun 			= As current position in degrees for circular orbit 0° - 360
	******************************************************************************************* */
	function lambdaSun(n, ec, epsilong){
		var N = Number(n);								// Unkorregierte mittlere Anomalie der Sonne in Grad
		var EC = Number(ec);							// Korrekturwert
																	// Uncorrected mean anomaly of the Sun in degrees
																	// Correction value
		var EPSILONG = Number(epsilong);	// Die mittlere eklipt. Länge der Sonne
																	// The middle eclipses. Length of the Sun
		var ldsun = 0.0;									// Ekliptischer Längengrad der Sonne als Ergebnis
																	// Ecliptic longitude of the Sun as a result
		// Übergabewerte aufaddieren ...
		// Add up transfer values ...
		ldsun = N + EC + EPSILONG;
		// Das Ergebnis in den Bereich 0° - 360° bringen ...
		// Bring the result to the range 0° – 360° ...
		ldsun = unwindDeg(ldsun );
		// ... und zurück an den Caller.
		// ... and back to the caller.
		return(ldsun);
		
	}// End of lambdaSun()
	
}// End of moonParameters()