function julian(base, eyr, mth, dy ){

//
//compute jd = A -R + D
//where A = sum of all days over all months from base year to end year
//R = sum of all days of last year from $mth to 12
//D = days in last month
//ie subtract off R and add back $dy
//
//alert (base+eyr+ mth+ dy)
days=new Array(31,28,31,30,31,30,31,31,30,31,30,31);

      jd=0;
      for(y=base; y<= eyr; y++){
        for( m=1; m<=12; m++){
           if( m == 2) {
                if (( y % 4  == 0 &&  y % 100 != 0) ||  y % 400  == 0) {  days[1]=29; } else {  days[1]= 28; }
           }
            ndays= days[ m-1];
           for( d=1; d<= ndays; d++){
                 jd++;
           }
        }
      }
        if (( eyr % 4  == 0 &&  eyr % 100  != 0) ||  eyr % 400  == 0) {  days[1]= 29; } else {  days[1]= 28; }
         remainingDays=0;
        for ( i= mth; i<=12; i++) {
           k= days[ i-1];
          for( j=0; j< k; j++) {
                 remainingDays++;
          }
        }
       jd=  jd -  remainingDays+ dy;  // add back the days
       //alert("jd " + jd);
return  jd;
}

function getLesson() {
alert("hi there");
/*
Dear Steve, 

Thanks for being in touch with your question!  We're happy to help.

The sequence of the lessons never changes except on two occasions:
1. When there are 53 Sundays in a year.  Then it is left to the Board of Trustees to decide when to add the extra lesson.  Since the early days of the movement the decision has always been to add the Christ Jesus lesson the week of Christmas.

2. About once a decade, the lessons fall so that the Christian Science lesson for June actually falls on July 1.  When this happens, the Sacrament lesson comes BEFORE the God lesson because the Manual dictates that the Sacrament lesson be the second Sunday of July.  So instead of Christian Science (last Sunday of June), God (1st Sunday in July), Sacrament (2nd Sunday of July), the order is Christian Science (1st Sunday of July), Sacrament (2nd Sunday of July), God (3rd Sunday of July).  Then the lessons are back to normal.  

Other than those two times the order of the lessons are never changed.

We hope this information is helpful, Steve!  Feel free to be in touch anytime with questions, comments, or observations.  We love hearing from you.

Warm regards,

Tessa Bray
Customer Service Team
The Christian Science Publishing Society
*/


var specialCaseYear;

var lesson = new Array()
lesson[0]="God"
lesson[1]="Sacrament"
lesson[2]="Life"
lesson[3]="Truth"
lesson[4]="Love"
lesson[5]="Spirit"
lesson[6]="Soul"
lesson[7]="Mind"
lesson[8]="Christ Jesus"
lesson[9]="Man"
lesson[10]="Substance"
lesson[11]="Matter"
lesson[12]="Reality"
lesson[13]="Unreality"
lesson[14]="Are Sin, Disease, and Death Real?"
lesson[15]="Doctrine of Atonement"
lesson[16]="Probation After Death"
lesson[17]="Everlasting Punishment"
lesson[18]="Adam and Fallen Man"
lesson[19]="Mortals and Immortals"
lesson[20]="Soul and Body"
lesson[21]="Ancient and Modern Necromancy, alias Mesmerism and Hypnotism, Denounced"
lesson[22]="God the Only Cause and Creator"
lesson[23]="God the Preserver of Man"
lesson[24]="Is the Universe, Including Man, Evolved by Atomic Force?"
lesson[25]="Christian Science"
//var  a= new Date();
//a.setFullYear(2009, 11, 30);
//var weeknumber = a.getWeek();
alert("weeknumber " + weeknumber);
var today = new Date();
alert("today"+today);
dayno=today.getDay();

alert("dayno"+dayno);

var weekno = today.getWeek();

alert("weekno"+weekno);
if(weekno>26)
  weekno=weekno-26-1;
else
  weekno=weekno-1;

if ( weekno > 25 && today.getWeek() <53)
 weekno = 8; //use Christ Jesus if extra week in year (ie 27 Sundays) and is not 53 
if (weekno > 52)
 weekno = 0;
document.forms['testform'].bl.value = lesson[weekno]
}
Date.prototype.getWeek = function() {
var onejan = new Date(this.getFullYear(),0,1);
var wk=Math.ceil((((this - onejan) / 86400000) + onejan.getDay())/7);

 return wk;
}

