function neptuneEphemeris(year, month, day, latitude, longitude) {

// This function will calculate orbital data for Neptune 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 Neptune'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 = NNeptune(d);
	var i = iNeptune(d);
	var w = wNeptune(d);
	var a = aNeptune(d);
	var e = eNeptune(d);
	var M = MNeptune(d);
		
// Calculate the eclipse values.

	var L = LNeptune(d);
	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 = 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) );
	
// 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 = 62.2 / 60 / 60 / R;
	
	FV = radToDeg(FV);
	var magnitude = 5 * Math.log(RHeEcl * R) / Math.log(10);
	magnitude = -6.90 + magnitude + 0.001 * 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 aNeptune(d) {

// Calculate the Mean Distance, a, for Neptune.  Input is the day number, d. 

	var a1 = 30.05826;
	var a2 = 0.00000003313;
	var a  = 0;
	
	a = a1 + a2 * d;
	
	return a;
	}

function eNeptune(d) {

// Calculate the Longitude of Perihelion, w, for Neptune.  Input is the day number, d.

	var e1 = 0.008606;
	var e2 = 0.00000000215;
	var e  = 0;
	
	e = e1 + e2 * d;
	
	return e;
	}

function NNeptune(d) {

// Calculate the Logitude of Accending Node, N, for Neptune.  Input is the day number, d. 

	var N1 = 131.7806;
	var N2 = 0.000030173;
	var N  = 0;
	
	N1 = degToRad(N1);
	N2 = degToRad(N2);	
	N  = N1 + N2 * d;
	N  = normalize(N, 2 * Math.PI);
	
	return N;
	}
	
function iNeptune(d) {

// Calculate the Inclination, i, for Neptune.  Input is the day number, d. 

	var i1 = 1.7700;
	var i2 = -0.000000255;
	var i  = 0;
	
	i1 = degToRad(i1);
	i2 = degToRad(i2);	
	i  = i1 + i2 * d;
	i  = normalize(i, 2 * Math.PI);
	
	return i;
	}
	
function wNeptune(d) {

// Calculate the Longitude of Perihelion, w, for Neptune.  Input is the day number, d.

	var w1 = 272.8461;
	var w2 = -0.000006027;
	var w  = 0;
	
	w1 = degToRad(w1);
	w2 = degToRad(w2);	
	w  = w1 + w2 * d;
	w  = normalize(w, 2 * Math.PI);
	
	return w;
	}

function LNeptune(d) {

// Calculate the Mean Logitude, L, for Neptune.  Input is the day number, d. 

	var M = MNeptune(d);	
	var w = wNeptune(d);
	
	var L = M + w;
	L = normalize(L, 2 * Math.PI);
	
	return L;
	}
	
function MNeptune(d) {

// Calculate the Mean Logitude, L, for Neptune.  Input is the day number, d. 

	var M1 = 260.2471;
	var M2 = 0.005995147;
	var M  = 0;
	
	M1 = degToRad(M1);
	M2 = degToRad(M2);	
	M  = M1 + M2 * d;
	M  = normalize(M, 2 * Math.PI);
	
	return M;
	}
