function jupiterEphemeris(year, month, day, latitude, longitude) {

// This function will calculate orbital data for Jupiter base of the
// date and location passed in.
// Latitude and longitude should be passed in radians.
	
	var dataArray = new Array();
	var h  = -0.833;
	
// Calculate the day number

	var d = calcDayNumber(year, month, day);
	
// Get the Sun's position.  It will be needed for Jupiter's ephemeris.

	var sunData = new Array();
	sunData = sunEphemeris(year, month, day, latitude, longitude);
		
// Calculate the orbital parameters for the given day.

	var o = obliquity(d);
	var N = NJupiter(d);
	var i = iJupiter(d);
	var w = wJupiter(d);
	var a = aJupiter(d);
	var e = eJupiter(d);
	var M = MJupiter(d);
		
// Calculate the eclipse values.

	var L = w + M;
	L = normalize(L, 2 * Math.PI);
	var E = Ecc(e, M);
	
	var x = a * (Math.cos(E) - e);
	var y = a * (Math.sin(E) * Math.sqrt(1.0 - Math.pow(e, 2)));
	var r = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
	var v = Math.atan2(y, x);
	v = normalize(v, 2 * Math.PI);
		
// Calculate the heliocentric ecliptical coordinates.

	var xHeEcl = r * (Math.cos(N) * Math.cos(v + w) - Math.sin(N) * Math.sin(v + w) * Math.cos(i));
	var yHeEcl = r * (Math.sin(N) * Math.cos(v + w) + Math.cos(N) * Math.sin(v + w) * Math.cos(i));
	var zHeEcl = r * Math.sin(v + w) * Math.sin(i);
	
// Calculate the heliocentric spherical coordinates.

	var lonHeEcl = Math.atan2(yHeEcl, xHeEcl);
	lonHeEcl = lonHeEcl + lonPerturJupiter(d);
	lonHeEcl = normalize(lonHeEcl, 2 * Math.PI);
	var latHeEcl = Math.atan2(zHeEcl, Math.sqrt( Math.pow(yHeEcl, 2) + Math.pow(xHeEcl, 2) ));
	latHeEcl = normalize(latHeEcl, 2 * Math.PI);
	var RHeEcl = Math.sqrt( Math.pow(xHeEcl, 2) + Math.pow(yHeEcl, 2) + Math.pow(zHeEcl, 2) );
	
// Re-calculate the heliocentric ecliptical coordinates.

	var xHeEcl = RHeEcl * Math.cos(lonHeEcl) * Math.cos(latHeEcl);
	var yHeEcl = RHeEcl * Math.sin(lonHeEcl) * Math.cos(latHeEcl);
	var zHeEcl = RHeEcl * Math.sin(latHeEcl);

// Calculate the geocentric ecliptical coordinates.

	var xGeoEcl = xHeEcl + sunData[0];
	var yGeoEcl = yHeEcl + sunData[1];
	var zGeoEcl = zHeEcl + sunData[2];

// Calculate the geocentric equitorial coordinates.

	var xGeoEqu = xGeoEcl;
	var yGeoEqu = yGeoEcl * Math.cos(o) - zGeoEcl * Math.sin(o);
	var zGeoEqu = yGeoEcl * Math.sin(o) + zGeoEcl * Math.cos(o);
	
// Calculate the right accension, declination and distance.

	var R   = Math.sqrt(Math.pow(xGeoEqu, 2) + Math.pow(yGeoEqu, 2) + Math.pow(zGeoEqu, 2));
	var RA  = Math.atan2(yGeoEqu, xGeoEqu);
	RA = normalize(RA, 2 * Math.PI);
	var Dec = Math.asin(zGeoEqu / R);
	Dec = normalize(Dec, 2 * Math.PI);
	
// Calculate the elongation, percent illumination, apparent diameter and magnitude.

	var elongation = Math.acos((Math.pow(sunData[5], 2) + Math.pow(R, 2) - Math.pow(RHeEcl, 2)) 
		/ (2 * sunData[5] * R));
	
	var FV = Math.pow(RHeEcl, 2) + Math.pow(R, 2) - Math.pow(sunData[5], 2);
	FV = FV / (2 * RHeEcl * R);
	FV = Math.acos(FV);
	
	var pctIllumination = (1 + Math.cos(FV)) / 2 * 100;
	
	var aprntDiameter = 196.94 / 60 / 60 / R;
	
	FV = radToDeg(FV);
	var magnitude = 5 * Math.log(RHeEcl * R) / Math.log(10);
	magnitude = -9.25 + magnitude + 0.014 * FV;

// Calculate the rise, south and set time.

	var L = LSun(d);
	var UTSouth = RA - L + Math.PI - longitude;
	UTSouth = UTSouth / degToRad(15.04107);
	UTSouth = normalize(UTSouth, 24);
	
	var LHA = (Math.sin(degToRad(h)) - Math.sin(latitude) * Math.sin(Dec)) /
		(Math.cos(latitude) * Math.cos(Dec));
	if (LHA <= -1) {
		UTRise = "Always Up"
		UTSet  = "Always Up"
		}
	else if (LHA >= 1) {
		UTRise = "Always Set"
		UTSet  = "Always Set"
		}
	else {
		LHA = Math.acos(LHA);
		LHA = LHA / degToRad(15.04107);
	
		var UTRise = UTSouth - LHA;
		UTRise = normalize(UTRise, 24);
		var UTSet  = UTSouth + LHA;
		UTSet = normalize(UTSet, 24);
		}
	
	dataArray[0]  = xGeoEcl;
	dataArray[1]  = yGeoEcl;
	dataArray[2]  = zGeoEcl;
	dataArray[3]  = RA;
	dataArray[4]  = Dec;
	dataArray[5]  = R;
	dataArray[6]  = elongation;
	dataArray[7]  = aprntDiameter;
	dataArray[8]  = magnitude;
	dataArray[9]  = pctIllumination;
	dataArray[10] = UTRise;
	dataArray[11] = UTSouth;
	dataArray[12] = UTSet;
	
	return dataArray;
			
	}
	
function aJupiter(d) {

// Calculate the Mean Distance, a, for Jupiter.  Input is the day number, d. 

	var a1 = 5.20256;
	var a2 = 0;
	var a  = 0;
	
	a = a1 + a2 * d;
	
	return a;
	}

function eJupiter(d) {

// Calculate the Longitude of Perihelion, w, for Jupiter.  Input is the day number, d.

	var e1 = 0.048498;
	var e2 = 0.000000004469;
	var e  = 0;
	
	e = e1 + e2 * d;
	
	return e;
	}

function NJupiter(d) {

// Calculate the Logitude of Accending Node, N, for Jupiter.  Input is the day number, d. 

	var N1 = 100.4542;
	var N2 = 0.0000276854;
	var N  = 0;
	
	N1 = degToRad(N1);
	N2 = degToRad(N2);	
	N  = N1 + N2 * d;
	N  = normalize(N, 2 * Math.PI);
	
	return N;
	}
	
function iJupiter(d) {

// Calculate the Inclination, i, for Jupiter.  Input is the day number, d. 

	var i1 = 1.3030;
	var i2 = -0.0000001557;
	var i  = 0;
	
	i1 = degToRad(i1);
	i2 = degToRad(i2);	
	i  = i1 + i2 * d;
	i  = normalize(i, 2 * Math.PI);
	
	return i;
	}
	
function wJupiter(d) {

// Calculate the Longitude of Perihelion, w, for Jupiter.  Input is the day number, d.

	var w1 = 273.8777;
	var w2 = 0.0000164505;
	var w  = 0;
	
	w1 = degToRad(w1);
	w2 = degToRad(w2);	
	w  = w1 + w2 * d;
	w  = normalize(w, 2 * Math.PI);
	
	return w;
	}

function LJupiter(d) {

// Calculate the Mean Logitude, L, for Jupiter.  Input is the day number, d. 

	var M = MJupiter(d);	
	var w = wJupiter(d);
	
	var L = M + w;
	L = normalize(L, 2 * Math.PI);
	
	return L;
	}
	
function MJupiter(d) {

// Calculate the Mean Logitude, L, for Jupiter.  Input is the day number, d. 

	var M1 = 19.8950;
	var M2 = 0.0830853001;
	var M  = 0;
	
	M1 = degToRad(M1);
	M2 = degToRad(M2);	
	M  = M1 + M2 * d;
	M  = normalize(M, 2 * Math.PI);
	
	return M;
	}
	
function lonPerturJupiter(d) {

// Calculate the heliocentric longitudinal perturbation for Jupiter.
// Input is the day number, d.

	var Mj = MJupiter(d);
	var Ms = MSaturn(d);
	var perturbation = 0;
	
// Calculate the perturbation.
	
	perturbation = degToRad(-0.332) * Math.sin(2 * Mj - 5 * Ms + degToRad(-67.6));
	perturbation = perturbation + degToRad(-0.056) * Math.sin(2 * Mj - 2 * Ms + degToRad(21));
	perturbation = perturbation + degToRad(0.042)  * Math.sin(3 * Mj - 5 * Ms + degToRad(21));
	perturbation = perturbation + degToRad(-0.036) * Math.sin(Mj - 2 * Ms);
	perturbation = perturbation + degToRad(0.022)  * Math.cos(Mj - Ms);
	perturbation = perturbation + degToRad(0.023)  * Math.sin(2 * Mj - 3 * Ms + degToRad(52));
	perturbation = perturbation + degToRad(-0.016) * Math.sin(Mj - 5 * Ms + degToRad(-69));
	
	return perturbation;
	}
