I am trying to figure out how to calculate the location to put a sun image on a page (theme really)


stats:

sunset location: 378px
sun peak: 18px

sun travel up 360 then down 360px

i already have code that will grab sunrise/sunset times - but i just filled in some times for now....

all in minutes....
i figure i need to calc total sunshine time, time since sunrise, peak time, pixel per min...

but i cant seem to figure out how to figure the current location?
I know i need to test to see if the time since sunrise is past the peak time..

help!

heres what i have so far (just starting)

Code:
var SnRs = new Date (new Date().toDateString() + ' ' + '6:30 am');
		var SnSt = new Date (new Date().toDateString() + ' ' + '9:15 pm');
		var cTime = new Date ( );
		

		var totalsuntime = Math.floor((Math.abs(SnSt - SnRs)/1000)/60);
		var minssincesunrise = Math.floor((Math.abs(cTime - SnRs)/1000)/60);
		alert("Total Mins: " + totalsuntime + "    Mins Since SR: " + minssincesunrise);
		var peaksun = Math.round(totalsuntime/2);
		var pxlpermin = Math.abs(peaksun/360).toFixed(2);
		
		var sLoc = Math.round(378 - (minssincesunrise * pxlpermin));
		
		alert(sLoc);
sLoc is too large... if i am thinking right, there should be a way to calc so that the value is always between 18 and 378 ? right?

THANKS!