<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="Author" content="Charles Hartley">
   <meta name="GENERATOR" content="Mozilla/4.5 [en] (Win98; I) [Netscape]">
   <title>ttest1</title>

<SCRIPT language="JavaScript">
<!--

//Puts data in Planet object
Moon= new Planet(3.66009781847778e-2,3.09396973237063e-4,32,0,0,0,0,0,-0,0);
Sun= new Planet(2.73778515163592e-3,2.45259916358821e-10,14,0,0,0,0,0,0,0);

//this function performs the sd calculation
function doit(form) {
julian(form)
sd=jd+714401708161.5+76/360;
form.sdbox.value=sd;
for (i=1;i<3;i++){
   Moon.LongPlanet(i);
   Sun.LongPlanet(i);
   sd++;
}
Moon.dlong = Moon.tlongtwo - Moon.tlongone;
if (Moon.dlong  <0 ){Moon.dlong = Moon.dlong +360;};
Sun.dlong = Sun.tlongtwo - Sun.tlongone;
if (Sun.dlong <0) {Sun.dlong=Sun.dlong+360;};
mbeh=Sun.tlongone - Moon.tlongone;
if (mbeh <0) {mbeh=mbeh+360;};
et=mbeh/(Moon.dlong - Sun.dlong);
form.mbehbox.value=inty(10*mbeh+.5)/10;
if (et<1) {
 sd=sd-2+et;
nc=0.0; Moon.LongPlanet(1);
 Sun.LongPlanet(1);
 form.tlongmoon.value=Moon.tlongone;
 eth=inty(24*et);
 etm=inty(60*(24*et-inty(24*et)));
 form.timebox.value="  " + eth + ":" + etm;
 ntl=(1.4718003426982e-4)*sd+nc;//node true longitude
 ntl=360-360*(ntl-inty(ntl));
 if (ntl<0) {ntl=ntl+360};
 dtl=Moon.tlongone-ntl;
 mlat=4.5*Math.sin(dtl*dr);
 gam=64.47*(1+Moon.cepi*Math.cos(Moon.manom*dr)/360); gam=gam*Math.tan(dr*mlat)*1.0812;
 mtdiam=0.040475*Moon.dlong;
 stdiam=0.54812*Sun.dlong;
 em=mtdiam/stdiam;
 form.gambox.value=gam;
 form.embox.value=em;
 form.nodebox.value=inty(10*(ntl-Sun.tlongone)+.5)/10;
}
else {
 form.timebox.value= "NA";
 form.gambox.value="NA";
 form.embox.value="NA";
 form.nodebox.value="NA";
 form.tlongmoon.value="NA";
 }
}

//this function creates the planet objects
function Planet(rates,arate,epic,cepi,tlongone,tlongtwo,manom,dlong,lc,ac) {
this.rates=rates;
this.arate=arate;
this.epic=epic;
this.cepi=cepi;
this.tlongone=tlongone;
this.tlongtwo=tlongtwo;
this.manom=manom;
this.dlong=dlong;
this.lc=lc;
this.ac=ac;
this.LongPlanet=LongPlanet;
}

//this function calculates the true longitude for the planet
function LongPlanet(k){
dr=Math.PI/180;
L=sd*this.rates+this.lc;
L=360*(L-inty(L));
M=sd*this.arate+this.ac;
M=360*(M-inty(M));
M=M-L;
this.cepi= this.epic - Math.abs(Math.sin(M*dr)*20/60);
bas=this.cepi*Math.sin(dr*M)/360;
L=L+Math.atan(bas/Math.sqrt(1-bas*bas))/dr;
if (L>360) {L=L-360};
if (L<0) {L=L+360};
if (k==1) {this.tlongone=L};
if (k==2) {this.tlongtwo=L};
this.manom=M;
}

//this functions takes in the year, month and day
//and calculates the Julian Day
function julian(form) {
var yr=parseFloat(form.yrbox.value);
var mo=parseFloat(form.mobox.value);
var dy=parseFloat(form.dybox.value);
var jy= yr + mo/12;
var bb=1;
if (jy < 1582) {bb=0;}
else {bb=1;}
var bg=0;
if (yr<0){bg=1}
if (mo<=2){mo=mo+12;yr=yr-1;}
var a =inty(yr/100);
var b = (2 - a + inty(a/4))*bb;
jd=inty(365.25*yr-bg*0.75)
+inty(30.601*(mo+1))+dy+1720994.5+b;
form.julbox.value=jd;
}

//this function gets the integer value of x
function inty (x){
if (x>0) {y=Math.floor(x)}
else {y=Math.ceil(x)};
return y
}

//-->
</SCRIPT>
</head>
<body>
<FORM>
This is a Javascript program to calculate the circumstances of a solar eclipse using methods described in the Surya Siddhanta (from Translation of the Surya-Siddhanta, a text-book of Hindu astronomy; with notes, and an appendix. by Ebenezer Burgess, 1850, John Wiley, New York).
<br>
<BR>
<INPUT TYPE="RESET" NAME="wipe" VALUE="Pre-set Entries" ><br><br>
<INPUT TYPE="text" NAME="yrbox" VALUE=1995 SIZE=5> Year
<INPUT TYPE="text" NAME="mobox" VALUE=10 SIZE=2> Month
<INPUT TYPE="text" NAME="dybox" VALUE =24 SIZE=2> Day
<INPUT TYPE="button" NAME="dot" VALUE="Do it!"
onClick="doit(this.form)">
<br><br>
Julian date = <INPUT TYPE="text" NAME="julbox" SIZE=9> ,
Hindu day count = <INPUT TYPE="text" NAME="sdbox" SIZE=17>
<br>
<br>
Longitude that Moon is behind the Sun on beginning of that day =
<INPUT TYPE="text" NAME="mbehbox" SIZE=4> <br>
True Longitude of Moon at conjuction = <INPUT TYPE="text" NAME="tlongmoon" SIZE=6> <br>
Time of day of Conjunction = <INPUT TYPE="text" NAME="timebox" SIZE=7>
<br>
Eclipe magnitude = <INPUT TYPE="text" NAME="embox" SIZE=5> ,
Gamma = <INPUT TYPE="text" NAME="gambox" SIZE=7>
<br>
Longitude between conjunction and ascending node of Moon =
<INPUT TYPE="text" NAME="nodebox" SIZE=7> <br>
<br>This form was last modified on.
<SCRIPT language="JavaScript">
<!--
document.write(Date(document.lastModified));
//-->
</Script>
</FORM>
</body>
</html>