// *EASY READERS* - for use on showing hi/los - also on Special_Education.htm page
//
// figure out the current day number, then use that for determining which
// easyread#_#.js to load
//
// easy_todaydnum(): return today's Date_DayOfYear()
// easyJS(): return the script that should be loaded
// einfo(): returns the entire string to display

function einfo(MX) {
  // return all the dailies for the next MX days; maximum of up to 10
  var N,x,y,S,S2,A;
  N=easy_todaydnum();
  S="";
  S2="";
  for (x=N;x<=N+MX;x++) {
    S=S+easyreadinfo(x,1);
  }
  if (S.length>0) {
    A=S.split("<BR>");
    if (A.length>10) {
       A.length=10;
    }
    for (y=0;y<A.length;y++) {
       if (y>9) {
          return S2;
       }
       // alert("At y="+y+" for length of "+A.length+" = "+A[y]);
       S2=S2+A[y]+"<BR>";
    }
  }
  return S2;
}

function easyJS() {
  var N,N1,N2,N3,N4,R;
  N=easy_todaydnum();
  if (N>=325) {
     N3=325;
     N4=375;
  } else {
     // alert("Math.floor="+Math.floor(N/25)+" OR "+(N/25)+" N="+N);
     N3=Math.floor(N/25)*25;
     N4=N3+50;
  }
  R="easyread"+N3+"_"+N4+".js";
  // alert("R="+R);
  return R;
}

function easy_todaydnum() {
   // return today's Date_DayOfYear()
   var now,m,d,yr,n;
   now=new Date();
   m=now.getMonth()+1;
   d=now.getDate();
   y=now.getYear();
   if (y<2000) y+=1900;
   n=easy_datenum(m,d,y);
   // alert(m+"/"+d+"/"+y+"; day number="+n);
   return n;
}

function easy_datenum(m,d,y) {
   var days,ly;
   // return the day number
   // this was originally [sub Date_DayOfYear in .pl]
   days=new Array( 0, 31, 59, 90,120,151,181,212,243,273,304,334,365);
   ly=0;
   if ((m>2)&&(easy_dateisleapyear(y))) {
      ly=1;
   }
   return (days[m-1]+d+ly);
}

function easy_dateisleapyear(yr) {
   if (y % 4!=0) {
     return 0;
   }
   if (y % 100!=0) {
     return 1;
   }
   if (y % 400!=0) {
     return 0;
   }
   return 1;
}



