<!--  
//  multi-week Calendar JavaScript by TJ Olney &copy; 2003 2004 2005
// look and feel calendar settings

// You will have to experiment with colors to decide what you like.
// It's a lot easier to make hideous combinations than pleasant ones!
// There are several stylesheets bundled that allow changing amongst a limited 
// set of possible color schemes.  You can use them as models for your own.
// There are many "color picker" sites around.
//  eg http://www.spacetoday.org/BoilerRoom/Colors.html
// The cell background colors alternate month to month 
// The today colors take precedence over holiday (noclass) colors
// 
// The calendar scales reasonably well, but when made very small, 
// something must be done about the long day and month names. Hence, the
// various chop variables that allow you to decide how much of the name 
// is really necessary.  


// To make more generic, need to create 3 dimensional array of event lists
// and then an associative array of those

// Also year could become another dimension for events so that each event
// would be singular and not try to reappear next year if the event list
// hasn't been updated  This would make it a 4 dimensional array of events
// list, year, month, date
// year, month, and date would be automatic
// list would be set by the server user 
// fixed events could still be 2 dimensional
// holidates 3D and calculated for different years
//
// something like this.
//
// for (list=0;list<numlists;list++)
// for (year=startyear;year<=endyear;year++)
// for (month=startmonth;month<=endmonth;month++)
// for (date = startdate;date<=31;date++)
//  printevent += event[list,year,month,date]

//
var narrow_weekends = false  // flag for making weekends less important...
//var framerule = "void"              // can be all left right etc.
//var borderrule = "all"		//
if (weekcolumn){var colWidth = "12%";} else{var colWidth="14%" ;}   

function chopvars(){
  monthchop1 = 9   // could be based on width of document.window how many letters of the month name to keep in 1st of month cell
  monthchop2 = 9   // how many letters of the month name to keep in 1st column
  daychop = 9  // how many letters of the weekday name to keep in column heads 9 max for Wednesday
  calnotes += '<br>  '     // any additional notes at the bottom of the page... 
  if (tiny||tiny=="true"||tiny==1) 
    {
     monthchop1 = 1   // how many letters of the month name to keep in 1st of month cell
     monthchop2 = 1   // how many letters of the month name to keep in 1st column
     daychop = 1  // how many letters of the weekday name to keep in column heads 9 max for Wednesday
    }
    }
//  multi-week Calendar JavaScript by TJ Olney &copy; 2003 

//   For the multi-week format, the first day of the calendar is adjusted to
//   the 1st sunday of the week containing the initdate.
//   The last row of the calendar will contain the final date plus any
//   remaining days in the week.  

//   Multi-week continuous calendars are bit like Dvorak keyboards, 
//   they just make sense!
//   But, people are creatures of habit.  Break the habit.  Once you get
//   used to using multi-week calendars you'll start to wonder why the 
//   month by month calendars continue to be popular.   TJ Olney January 2003
//
//  Notes:
//    As the primary purpose of developing this has been to use for my 
//   classes at Western Washington University, a quarter school, The calendar
//   is setup to generate a heading for the quarter it starts.
//   if the calendar requested is longer than 91days, but less than 120 days
//   Semesters are assumed.  For any calendar longer than 120 days the heading
//   is generic. In semesters and quarters, weeks are numbered from the first
//   week of the quarter.  In longer calendars, weeks just tell the year & month.
//
//   Based on several other limited scripts around, I've incorporated the
//   ability to adjust the look of the calendar fairly easily, but not trivially.
//   The calendar composing code flunks the elegance test, but it seems to work.

//        Change the following to generate calendar for different time periods

//          WARNING
//   It is possible to crash people's old slow computers with too
//   large a calendar!  1 year is quick, 20, interminable...
//   
//
// initdate 1st date wanted in desired multi-week calendar
// fin  last date wanted on the calendar
//  *** Note: Months start at Jan=0 .... Dec =11 
// Change these to reflect the day you want the calendar to start and end.

//Class variables added to TD elements so css can be used to define colors and formatting.
var diag = 0; //set to 0 noramally to 1 for diagnostic messages
var inityear = ""; var initmonth = ""; var initdate= "";
var finyear = "";  var finmonth = ""; var findate = "";
var extrahead = ""
var enddate ="";
var totdays = "";
var milliseconds = "";
var weeksincal = "";
var year = "";
var now = new Date();
var nowyear = now.getYear()
if (nowyear < 1000) {nowyear+=1900}
year=parseInt(nowyear);
var nowmonth = now.getMonth()
var month=initmonth
var i;     // miscellaneous looping variable
var j;     // miscellaneous looping variable
var parmList;
var parmList = new Array();
var callingURL = new String(document.location);
var urlAndParms = new Array();
urlAndParms[0]="";
urlAndParms[1]="";
var tempVars = new Array();
var tiny=null    // no quotes makes boolean flag to set parameters if it is to be a tiny calendar
var weekcolumn=null;

//initialize these arrays of constants as global arrays to use later
var dayname=new Array("Sunday","Monday ","Tuesday ","Wednesday","Thursday","Friday ","Saturday")
var qndx = null;
var firstof = new Array(12);	     
var daysinmonth = new Array(12);
var calnotes ="";
// month names long version used in header use substr() to get short versions.

monthname = new Array ("January ","February ","March ","April ","May ","June ","July","August ","September ","October ", "November ", "December ")
var period = new Array();
period[0]= "Winter  "
period[1]= "Spring  "
period[2]= "Summer  "
period[3]= "Fall  "
period[4]= "Calendar "
period[5]= "Fall "
period[6]= "Spring "
period[7]= "Summer "
//function setqndx() picks which to use in your heading


// CREATE AND INITIALIZE ALL EVENT LISTS AS 2 DIMENSIONAL ARRAYS  
var type1events
var fixedevents
var type2events
var myevents
var event
var type3events  

var event = new Array(12);
var type1events  = new Array(12);
var myevents  = new Array(12);
var fixedevents  = new Array(12);
var type2events  = new Array(12);
var type3events  = new Array(12);

// now make each of the first  have 32 elements;
for(i=0;i<12;i++){

   event[i] = new Array(32); 
   fixedevents[i] = new Array(32);
   type2events[i] = new Array(32);
   myevents[i] = new Array(32);
   type1events[i] = new Array(32);
   type3events[i] = new Array(32);
                 }

//to have a third dimension  of years 2 before and 8 after
// for (i=inityear-2;i<inityear+8;i++){
//       for(j=0;j<32;J++){
//	   for(k=0;k<12;k++){ event[i][j] = new Array(10);
//                          } }}

// then initialize them all to null;
for (i=0; i<12; i++){
    for(j=0; j<32; j++){ 
    event[i][j] = "" 
    type2events[i][j]= "";
    type1events[i][j]= "";
    myevents[i][j]+= "";
    type3events[i][j]= "";
    fixedevents[i][j]= "";
       
    }
}





// in the various event files, year is handled by switch (String(year)) 

/////////////////////////////set to null then set the various event lists 
//          fixed events need not be dealt with again
//          all other events must be reset when a year boundry is crossed
function resetevents(year){
for (i=0; i<12; i++){
    for(j=0; j<32; j++){ 
    event[i][j] = "" 
    type2events[i][j]= "";
    type1events[i][j]= "";
    myevents[i][j]= "";
    type3events[i][j]= "";
   
    }
}
//   document.write("<br>running resetevents for the year ", year,'<br>')

set_type2events(year); 
set_type3events(year);
set_type1events(year); 
  //set_myevents(year); 
  //  any additional event arrays should be set here 
  // set_type3events();
  // event array files should clean up and set the events for each event list 
  // their new events will be set when a function defined in them is
  // executed here  as set_*([year]);   Year boundaries can be tricky and
  // event lists should deal with them before merging events for inclusion
  // into the calendar string.  setcal.html works with a form and cgi-bin
  // script to allow web addition of new events to an event list
}
///////////////////////////end of reset events


// constant holidays 



function merge_events(){

if ((!tiny) ||(tiny==false)||(tiny==0)||(tiny=="no")){
for (i=0; i<12; i++){
    for(j=0; j<32; j++){
    	     if(myevents[i][j]) {event[i][j] += myevents[i][j]}
	     if(type1events[i][j]) {event[i][j] += type1events[i][j]}
	     if(fixedevents[i][j]) {event[i][j] += fixedevents[i][j] }
	     if(type2events[i][j]) {event[i][j] += type2events[i][j] }
	     if(type3events[i][j]) {event[i][j] += type3events[i][j] }
                       }
	            }
	}	
// no events on tiny calendars..
//document.write('merge_events has been run and year is ',year)
}
   


// calparams.js 

// You can set these manually but if called with a query string that will override these
// If not set default is a 3 month interval including current week
// inityear= 2005;
// initmonth=0;
// initdate=7 ;
// finyear = 2007;
// finmonth=11;
// findate=29;
// if neither is set, then the default is to start this week and go for 10 weeks

if (callingURL.indexOf("?") != -1)
{ 
   
   var urlAndParms = callingURL.split("?");
     {
	
      parmList = urlAndParms[1].split("&");
     }
   
      //document.write('parmList.length = ',parmList.length,'<br>');
      
      // and loop through the array, splitting out the x=y pairs
   for (i = 0; i < parmList.length; i++)
      {
   if(diag==1){document.write('parmList[',i,'] = ',parmList[i],'  Query Parameter pairs <br>')};
      // now separate each pair into their constituents.
      tempVars  = parmList[i].split("=");
      if(tempVars[0]=="inityear" && tempVars[1]!=""){inityear = tempVars[1]}
      if(tempVars[0]=="initmonth" && tempVars[1]!=""){initmonth = tempVars[1]}
      if(tempVars[0]=="initdate" && tempVars[1]!=""){initdate = tempVars[1]}
      if(tempVars[0]=="finyear" && tempVars[1]!=""){finyear = tempVars[1]}
      if(tempVars[0]=="finmonth" && tempVars[1]!=""){finmonth = tempVars[1]}
      if(tempVars[0]=="findate" && tempVars[1]!=""){findate = tempVars[1]}
      if(tempVars[0]=="tiny" && tempVars[1]!=""){tiny =  tempVars[1]}
      if((tempVars[0]=="tiny") && ((tempVars[1]=="")||(tempVars[1]=="null"))){tiny =  null; }
      if(tempVars[0]=="weekcolumn" && tempVars[1] != ""){weekcolumn =tempVars[1]}
      if(tempVars[0]=="weekcolumn" && ((tempVars[1] == "")||(tempVars[1]=="0")||(tempVars[1]=="false")||(tempVars[1]=="null"))){weekcolumn = null}
//      document.write('tempVars[0] = ',tempVars[0],' tempVars[1] = ',tempVars[1],' value passed is weekcolumn is now ',weekcolumn,'  still testing <br>');
//if (weekcolumn){document.write('at read weekcolumn evaluates to true<br>')};
//if (!weekcolumn){document.write('at read weekcolumn evaluates to false <br>')}
      
      }
}
chopvars();

   if(diag==1){document.write('At this point inityear = ',inityear,'initmonth = ',initmonth,'initdate = ', initdate,'<br>')};

// if no values set by query string or hard coded, then set to defaults of now plus about 11 weeks
if(tiny){document.write('<style>td {height:1em;}</style>')}

if (inityear==""){
   current();
      if (!tiny){document.write('<a href=#today> Today is &nbsp;&nbsp;<b>',dayname[now.getDay()],' ',monthname[nowmonth],' ', now.getDate(),', ',nowyear,'</b><br></a>')}; // top of page!
   var inityear =nowyear; var initmonth=nowmonth; var initdate=nowdate ;
   var finyear = nowyear; var finmonth=nowmonth+2; var findate=nowdate+7;
                 }
else {
      current();
      if (!tiny){document.write('<a href=#today> Today is &nbsp;&nbsp;<b>',dayname[now.getDay()],' ',monthname[nowmonth],' ', now.getDate(),', ',nowyear,'</b><br></a>')}; // top of page!
      //==false)||(tiny==0)||(tiny=="no"))      
      var year = inityear ;}

   if(diag==1){document.write('If no Query string, these are the defaults set otherwise they should be the same as above<br>  inityear = ',inityear,'initmonth = ',initmonth,'initdate = ', initdate,'<br> finyear = ',finyear,'finmonth = ',finmonth,'findate = ', findate,'<br>')};

// text in calnotes will be printed at the bottom of the calendar
//if ((tiny==true)||(tiny==1)||(tiny=="yes"))
if (tiny){calnotes = '<font size=-2 color="indigo">Multi-Week Calendar<br> created by TJ Olney<br> &copy; 2002 - &copy; ' + nowyear +'<br></font> ' ;}
else {
calnotes += 'Multi-Week Calendar created by TJ Olney &copy; 2002 - &copy; ' + nowyear +'<br>' ;
calnotes += ' '}


// in order to highlight today, we need its parameters -- does not change with year
function current(){
       now = new Date();
       nowday = now.getDay();
       nowdate = now.getDate();
       nowmonth = now.getMonth()
       nowyear = now.getYear()
       if (nowyear < 1000) {nowyear+=1900}
                  }
///////////////////////////////////////////////////////

//  Holidays included in this calendar
//   Work schedules may or may not be affected by these holidays.
//* New Year's Day, January 1st.
//* Birthday of Martin Luther King, third Monday in January.
//* Presidents day, third Monday in February 
//* Memorial Day, last Monday in May 
//* United States of America's Independence Day, July 4.
//* Labor Day, first Monday in September.
//* Veterans Day, November 11th 
//* Thanksgiving Day, fourth Thursday in November.
//* National Mall of Worship Day ... Day after Thanksgiving
//* Christmas Day, December 25th. 
//* Columbus Day, second Monday in October (federal holiday since 1971).
// from http://www.smart.net/~mmontes/ushols.html 
// shows how to calculate easter if you want...
// initialize daysinmonth array
  daysinmonth[0] = 31;   daysinmonth[2] = 31 ;  daysinmonth[3] = 30 ;  daysinmonth[4] = 31 ;  daysinmonth[5] = 30 ;  daysinmonth[6] = 31 ;  daysinmonth[7] = 31 ;  daysinmonth[8] = 30 ;  daysinmonth[9] = 31 ;  daysinmonth[10] = 30;  daysinmonth[11] = 31 // December
 
//////////////////////////////////////
function setfebdays(yr) {
  if (yr % 4 == 0) {daysinmonth[1]=29}
    else
    {daysinmonth[1]=28}
  }
//////////////////////////////////////

				      
//////////////////////////////////////

  
function setcalparams(inityear,initmonth,initdate,finyear,finmonth,findate){
if(diag==1){document.write('These values have been passed to setcalparams: inityear = ',inityear,'initmonth = ',initmonth,'initdate = ', initdate,'<br>')};
      
     startdate = new Date(inityear,initmonth,initdate);

// If the start date given is not a sunday, revise startdate to previous Sunday
// lookups
     startwday= startdate.getDay();
   //document.write('Inside function setcalparams given startdate ',startdate,'given start week day ',startwday,'<br>')
//     var backup = parseInt(initdate)-parseInt(startwday)
     if (parseInt(startwday) !=0) {startdate= new Date(inityear,initmonth,(initdate-startwday))}
  if(diag==1){document.write(' figured out  startdate ',startdate,'given start week day ',startwday,'<br>')}
     startcal = startdate.getDate();
     startmonth = startdate.getMonth()
     startyear = startdate.getYear(); // was getYear
     if (startyear <1000) {startyear+=1900};
     if (year <1000) {year+=1900};

     enddate = new Date(finyear,finmonth,findate);
//     document.write('<br>Inside function set calparams enddate gets set fisrt to : '+enddate)

     endwday = enddate.getDay()
     if (endwday !=6) {newend=parseInt(findate)+(6-parseInt(endwday));
                       enddate = new Date(finyear,finmonth,newend)}
//     document.write('<br>Still Inside function set calparams enddate gets adjusted  to : '+enddate,finyear,finmonth,newend)
     
     endmonth = enddate.getMonth()
     endyear = enddate.getYear()
     if (endyear <1000) {endyear+=1900};

     milliseconds=enddate.getTime()-startdate.getTime();
     totdays=Math.floor(milliseconds/(3600000*24));
     weeksincal=Math.round((totdays+1)/7)

     //firstofyear = new Date(inityear,0,1)
     //dayinyear = Math.floor((startdate.getTime-firstofyear.getTime)/86400000)

     month = startmonth;
// set number of days in february into daysinmonth[1]
     setfebdays(year); 
   if(diag==1){document.write('<br><table border=1><tr><td>finyear </td><td>finmonth </td><td>findate </td><td> enddate</td></tr><tr><td> '+finyear+'</td><td> '+finmonth+'</td><td> '+findate+' </td><td>  '+enddate+'</td></tr></table>')}
   if(diag==1){document.write('At the end but still Inside the function setcalparams has run and  the starting date, variables<br>  startcal= '+ startcal+'&nbsp; milliseconds='+milliseconds+'&nbsp; totdays='+totdays+'&nbsp; weeksincal='+weeksincal+'&nbsp; enddate='+enddate+'  <br>')}


}
/// end of setcalparams()
/////////////////////////////////////////////////////////////////////////







// simple day of week function -- remember that months are 0-11 
function DayofWeek(year,month,day){
             var lookupdate = new Date(year,month,day);
	     var lookupday = lookupdate.getDay();
             return lookupday ;
	     }

////////////  function to get the first of each month in a given year 	     
function firstdays(yr){
         for (var i=0;i<12;i++){
         firstof[i]= DayofWeek(yr,i,1)}
         return firstof;
         }
////////////////// The function that calculates holidays that fall on
//variable dates, like the 2nd Monday or the 4th thursday.
//
function setholidates(thisyear){
   year=thisyear;
   firstdays(thisyear);
          setfebdays(thisyear);
          resetevents(thisyear);
//document.write("<br>middle of setholidates its parameter",thisyear, 'type2= ',type2events[0][2],' year = ',year,'year should precede this<br>'  )
// general  holidaydate =  first_possible_date + ((7+num_day_of_week_of_holiday)  -  (day_of_week_month_starts))%7
//  so  4th thursday is possible on the 22 if the first day of the month is a thursday.
//  thursday is day number 4 
// so thanksgiving date is 22 + ((7+4)-dayofweekoffirstofmonth)
//  an event occuring on the second thursday would be 8 +((7+4)-DayofWeek(thisyear,thismonth,1))
         mlkdate = 15 + (8 - DayofWeek(thisyear,0,1))  //3nd monday jan 0
          presdate =15 + (8 - DayofWeek(thisyear,1,1))  //3nd monday feb
          momdate = 8 +  (7-DayofWeek(thisyear,4,1)) ;    //2nd sunday  may
          labdate = 1 +  (8 - DayofWeek(thisyear,8,1)) ;  //1st monday sept
          columbdate = 8 + (8 - DayofWeek(thisyear,9,1)) ; //2nd monday october
          //So.... Thanksgiving is the 4rd Thursday of November 
//          tgdate = 22 + ((11) - DayofWeek(thisyear,10,22))%7 ;  //4th thursday
          tgdate = 22 + ((11) - DayofWeek(thisyear,10,1))%7 ;  //4th thursday
	  //stdtimdate = 31 - (DayofWeek(thisyear,9,31));  //last sunday oct 25-31
          daylitedate = 8 + (7 - DayofWeek(thisyear,2,1)) ;  //now second sunday march 1st sunday 
          stdtimdate = 1 + (7 - DayofWeek(thisyear,10,1)) ;  //1st sunday

          var mayends = DayofWeek(thisyear,4,31); //Memorial Day last monday
                                                  //of May
	   if (mayends==0) {memdate = 25}
           else {memdate = 31-(mayends-1)};  
	   
if((!tiny)||(tiny==false)||(tiny==0)||(tiny=="no")){

event[0][mlkdate] += "Martin Luther King Day"
event[1][presdate] += "President's Day"
event[4][momdate]  += "Mother's Day"
event[4][memdate] += "Memorial Day"
event[10][tgdate] += "Thanksgiving"
event[8][labdate] += "Labor Day"
event[9][columbdate] += "Columbus Day"
event[2][daylitedate] += "<img src=./images/springforward.gif >Forward to <br><a href=http://webexhibits.org/daylightsaving/b.html>Daylight Saving</A> "
event[10][stdtimdate] += '<img src=./images/fallback.gif alt="Set Clocks"> Back to <br><a href=http://webexhibits.org/daylightsaving/b.html>Standard Time</A> '


merge_events();
}
}
///////////////////end  setholidates /////////////////////////////

   

/////////////////////////////////////////////////////
//        End of new stuff for holidays etc.
///////////////////////////////

// set headers based on how long calendar is and when it starts.
function setqndx(totdays,initmonth){
  qndx=null;
  if (totdays>120) {qndx=4;return;}   // generic calendar
  if (((initmonth <= 1) || (initmonth==11)) && (totdays<92) ){qndx = 0;return;} //winter quarter
  if ((initmonth <= 1) && (totdays>91) ) {qndx = 6;return;}                     //spring semester
  if ((initmonth >= 2) && (initmonth < 4) && (totdays<92)) {qndx = 1;return;}  // spring quarter
  if ((initmonth >=5) && (initmonth < 7) && (totdays<92)) {qndx =2;return;}  // summer quarter
  if ((initmonth >= 4) && (initmonth < 7)  && (totdays >91)) {qndx =7 ;return;}  //summer semester
  if ((initmonth >= 7) && (initmonth < 8)  && (totdays >91)) {qndx =5;return;}  //fall semester
  if ((initmonth >=7) && (initmonth < 11)  && (totdays <92)) {qndx =3;return;}  //fall quarter
  if (!(qndx)) { qndx = 4};
   return qndx ;
}   
////////////////////////////end setqndx() ////////////////////     

//////////////////////////////////////////////////////////////////////////
////// function that builds the calendar 

//function output_cal(firstday, nowdate, startmonth, monthname, startyear, weekcolumn) {
function output_cal() {
year =startyear;
var calstring = '<'+'!-- multi-week Calendar JavaScript by TJ Olney @2003-2005  --'+'>' // 
if(tiny){calstring += '<style>td {height:1em;padding:0;margin:0; }</style>'}
     calstring += ' '
     calstring += '<TABLE class="caltable" border=1 ' 
     if(!tiny){calstring += 'WIDTH="100%" >'}else {calstring += '>'}
     // table settings
     calstring += '<thead><tr><TH class="calheader" COLSPAN=8 >' 
     // set font for table header;
     if ((!tiny) ||(tiny==false)||(tiny==0)||(tiny==null)||(tiny=="no")) {calstring += extrahead + ' '}
     calstring +=  period[qndx]+ '<br> ' + monthname[initmonth].substring(0,monthchop2) +' '+ inityear +' -  '+ monthname[endmonth].substring(0,monthchop2) +' '+ endyear +' &nbsp; '
     calstring += '</th></tr></thead>' // close header cell
   
// variables to hold constant settings
if(tiny){var headrowtd='<TD>'}else{ var headrowtd = '<TD class="celldayname" >'}
var headrowtdend = '</TD>'

//////////////
//create first row of table to set column width and specify week day
         calstring += '<tbody><TR ALIGN="center" VALIGN="center">'
         if ((weekcolumn) &&(!tiny)){calstring += '<TD class="cellweeknum"> Week' + headrowtdend}
	 else if((weekcolumn) && (tiny)) {calstring +=  '<td class="cellweeknum" ><font size=-2>Wk</font></td>'}
           for (var dayNum = 0; dayNum < 7; ++dayNum) {
                calstring += headrowtd +dayname[dayNum].substring(0,daychop) + headrowtdend
                }
         calstring += '</TR>'  // end of row of column headings
//////
////////////////////////////////////////////////////////////////////////////////////
// declaration and initialization of two variables to help with tables
//  since this is inside the function this declaration stays here
var dayofmonth = startcal 
var curcell = startcal

for (var row = 1; row <= weeksincal; ++row)   /// main loop for each row
       {
        calstring += '<TR ALIGN="right" VALIGN="top">'
        //nospaces --  make it skinny
        for (var col = 0; col <= 7; col++)   //// loop for cells in row
	      {  if ((col == 0) && (!weekcolumn)) 
						 {
						    col++
				
			       
			     }
		 
		 if ((col ==0) && (dayofmonth>daysinmonth[month]) ) {month++;dayofmonth=1; if(month>11){month=0;year++;setholidates(year)} }

//less than a quarter
if ((col == 0)&&(totdays<=90) ) 
		  {calstring += '<TD  class="weeknumcell' +(month%2)+ '">'
if(!tiny){calstring += 'Week '+row+'<br>'}else {calstring += '<sub>' +row+' </sub>'}
calstring += monthname[month].substring(0,monthchop2)
                  calstring += '</TD>'
		      col++
		 }
		 else
		 {
 		 if ((col == 0)&&(totdays>90)) {calstring += '<TD class="datecell' + ((month%2)+2) +'">'+year+' '+monthname[month].substring(0,monthchop2)+'</td>'
		      col++
                      } 
		    if (dayofmonth == nowdate && month == nowmonth && year==nowyear)
		     {  
			// current cell represent today's date
			//
			calstring += '<TD class="celltoday">'
			calstring += dayofmonth 
			if (!tiny){calstring += '<A NAME="today"></A><br>Today<br>'}
			if (event[month][dayofmonth]){calstring += '<br>' +event[month][dayofmonth]+' '}
                        calstring += '</TD>'
                        dayofmonth++
                        col ++
			  if (col >7) {break}
		     }
		   }
		 if (dayofmonth > daysinmonth[month])
		   {
		      dayofmonth=1 ;
		      month++ ; 
		      if ((month > 11) && (year==startyear)) {month =0; year++;  setholidates(year) }
		      else if ((month >11)&&(year>inityear)) {month=0;year++;setholidates(year)}
		   }
		   
 if (month > 11) {month =0; year++;  setholidates(year);}
       // weekends and holiday formatting first, ordinary formatting next
		 if (
		 (col==1 || col==7) ||
		 (dayofmonth == 1 && month == 0)|| 
		 (dayofmonth == mlkdate && month == 0) || 
		 (dayofmonth == presdate && month == 1) || 
		 (dayofmonth == memdate && month ==4) || 
		 (dayofmonth == 4 && month ==6) || 
		 (dayofmonth == labdate && month == 8) || 
		 (dayofmonth == 11 && month ==10) || 
		 (((dayofmonth==tgdate) ||(dayofmonth==(tgdate+1)))  && month==10)  || 
		 (dayofmonth==25 && month==11))
		   {
		      calstring += '<TD class="cellholiday'+(month%2)+'" >'
                    }
		  else 
		   { 
		      calstring += '<TD class="datecell'+(month)%2 +'">'
		  //if (event[month][dayofmonth]){calstring += '<br>'+event[month][dayofmonth]+' '}
		  }
	     if (dayofmonth==1)
		   {calstring +=  '<i><b>'+monthname[month].substring(0,monthchop1)+'</b></i> '  + dayofmonth 
		    if (event[month][dayofmonth]){calstring += '<br>'+event[month][dayofmonth]+' '}
		   calstring += '</TD>'}
             else 
		   {calstring += dayofmonth  
		  if (event[month][dayofmonth]){calstring += '<br>'+event[month][dayofmonth]+' '}
                   calstring += '</TD>'}
             dayofmonth++
	      }
       }
   
   
calstring += '</TR> </tbody>'






// close all basic table tags
calstring += '</TABLE>'
calstring += calnotes
//  leave choice for centering up to calling page calstring += ' '//</CENTER>'


// print the whole calendar to screen as a string
document.write(calstring) 

}

// if not all parameters are set, then the defaults get used, so have care
// to set those you want set  need to account for month & week crossings after multiple reloads...
// also make it go a quarter at a time  or directly to quarters
// initmonth=0; initdate=1; inityear=2003; finyear=2003; finmonth=2; findate=30;


// function has generic parameters, but non generic assignments.
var iniyearhold=parseInt(inityear); var inimonthhold=parseInt(initmonth);var initdatehold=parseInt(initdate);
var finyearhold=parseInt(finyear); var finmonthhold=parseInt(finmonth); var findatehold=parseInt(findate);



function resetinit(){
inityear=iniyearhold; initmonth=inimonthhold; initdate=initdatehold;finyear=finyearhold; finmonth=finmonthhold; findate=findatehold;
}


function newparms(inity,initm,initd,finy,finm,find)
{
   var newstartdate = new Date(inity, initm, initd)
   var new_s_day = newstartdate.getDay();
   initdate  = newstartdate.getDate();
   initmonth = newstartdate.getMonth()
   inityear  = newstartdate.getYear()
              if (inityear < 1000) 
	 {
	    inityear+=1900
	 }
   var newfindate = new Date(finy,finm,find)
   var new_f_day = newfindate.getDay();
   findate  = newfindate.getDate();
   finmonth = newfindate.getMonth()
   finyear  = newfindate.getYear()
              if (finyear < 1000) 
	 {
	    finyear+=1900
	 }
 setcalparams(inityear,initmonth,initdate,finyear,finmonth,findate);
}

  
function nextweek()
{  
initdate = parseInt(initdate) + 7
findate = parseInt(findate) + 7
newparms(inityear,initmonth,initdate,finyear,finmonth,findate)
}

  
function lastweek()
{
initdate = parseInt(initdate) - 7
findate = parseInt(findate) - 7
     newparms(inityear,initmonth,initdate,finyear,finmonth,findate)
      
}

function nextmonth()
{
initmonth = parseInt(initmonth) + 1
finmonth = parseInt(finmonth) + 1
     newparms(inityear,initmonth,initdate,finyear,finmonth,findate)
}

function lastmonth()
{
initmonth = parseInt(initmonth) - 1
finmonth = parseInt(finmonth) - 1
newparms(inityear,initmonth,initdate,finyear,finmonth,findate)
  }

// this jumps to a next likely starting quarter date.  Your mileage may vary if your school calendar differs too much
function nextquarter()
{ 
if((initmonth==0)||(initmonth==1)||(initmonth==2)){initmonth=3;finmonth=5;initdate=1;findate=15;finyear=inityear;newparms(inityear,initmonth,initdate,finyear,finmonth,findate);return;}
if ((initmonth==3)||(initmonth==4)||((initmonth==5)&&(initdate<15))) {initmonth=5;finmonth=7;initdate=20;findate=30;finyear=inityear;newparms(inityear,initmonth,initdate,finyear,finmonth,findate);return;}
if (((initmonth==5)&&(initdate>14))||(initmonth==6)||(initmonth==7)) {initmonth=8;finmonth=11;initdate=21;findate=15;finyear=inityear;newparms(inityear,initmonth,initdate,finyear,finmonth,findate);return;}
if((initmonth==8)||(initmonth==9)||(initmonth==10)||(initmonth==11)) {initmonth=0;finmonth=2;initdate=4;findate=25;inityear=parseInt(inityear)+1;finyear=inityear;newparms(inityear,initmonth,initdate,finyear,finmonth,findate);return;}
document.write("next quarterfunction broken")
//newparms(inityear,initmonth,initdate,finyear,finmonth,findate)
}

  
function lastquarter()
{
if((initmonth==8)||(initmonth==9)||(initmonth==10)||(initmonth==11)){initmonth=5;finmonth=7;initdate=20;findate=30;finyear=parseInt(inityear);newparms(inityear,initmonth,initdate,finyear,finmonth,findate);return;}
if (((initmonth==5)&&(initdate>14))||(initmonth==6)||(initmonth==7)){initmonth=3;finmonth=5;initdate=1;findate=15;finyear=inityear;newparms(inityear,initmonth,initdate,finyear,finmonth,findate);return;}
if ((initmonth==3)||(initmonth==4)||((initmonth==5)&&(initdate<15))) {initmonth=0;finmonth=2;initdate=4;findate=24;finyear=inityear;newparms(inityear,initmonth,initdate,finyear,finmonth,findate);return;}
if ((initmonth==0)||(initmonth==1)||(initmonth==2)) {initmonth=8;finmonth=11;initdate=21;findate=11;inityear=parseInt(inityear)-1;finyear=inityear; newparms(inityear,initmonth,initdate,finyear,finmonth,findate);return;}
document.write("last quarterfunction broken")
//newparms(inityear,initmonth,initdate,finyear,finmonth,findate)
}

   
   function nextyear()
{  
inityear=parseInt(inityear)+1
finyear=parseInt(finyear)+1
   newparms(inityear,initmonth,initdate,finyear,finmonth,findate)
}

  
function lastyear()
{
inityear=parseInt(inityear)-1
finyear=parseInt(finyear)-1
   newparms(inityear,initmonth,initdate,finyear,finmonth,findate)
}
/////////////////////////////////draw the nav bar///
// Use '+document.location.pathname+' so the script can be included in any file.
// draw the nav bar.
function drawnavbar(){
lastyear()  //set year back
document.write('<b><A HREF='+document.location.pathname+'?inityear='+inityear+'&finyear='+finyear+'&initmonth='+initmonth+'&finmonth='+finmonth+'&initdate='+initdate+'&findate='+findate+'&tiny='+tiny+'&weekcolumn='+weekcolumn+'><font size=""> &larr; prev yr |</A> ')
resetinit();

lastquarter()  // set back 3 months
document.write('<b><A HREF= '+document.location.pathname+'?inityear='+inityear+'&finyear='+finyear+'&initmonth='+initmonth+'&finmonth='+finmonth+'&initdate='+initdate+'&findate='+findate+'&tiny='+tiny+'&weekcolumn='+weekcolumn+'> prev quarter| </A> ')
resetinit();
if(tiny)document.write('<br>')

lastmonth()  //set it back a month
document.write('<b><A HREF= '+document.location.pathname+'?inityear='+inityear+'&finyear='+finyear+'&initmonth='+initmonth+'&finmonth='+finmonth+'&initdate='+initdate+'&findate='+findate+'&tiny='+tiny+'&weekcolumn='+weekcolumn+'>  prev month| </A> ') 
resetinit();

lastweek()
document.write('<b><A HREF= '+document.location.pathname+'?inityear='+inityear+'&finyear='+finyear+'&initmonth='+initmonth+'&finmonth='+finmonth+'&initdate='+initdate+'&findate='+findate+'&tiny='+tiny+'&weekcolumn='+weekcolumn+'> prev week </A>|')
resetinit();
if(tiny)document.write('<br>')

//document.write(' <a href=custom.html>Custom Calendar</a> ')
//if(tiny)document.write('<br>')

nextweek()
document.write('|<b><A HREF= '+document.location.pathname+'?inityear='+inityear+'&finyear='+finyear+'&initmonth='+initmonth+'&finmonth='+finmonth+'&initdate='+initdate+'&findate='+findate+'&tiny='+tiny+'&weekcolumn='+weekcolumn+'> next week |</A> ')
resetinit();

nextmonth()
document.write('<b><A HREF= '+document.location.pathname+'?inityear='+inityear+'&finyear='+finyear+'&initmonth='+initmonth+'&finmonth='+finmonth+'&initdate='+initdate+'&findate='+findate+'&tiny='+tiny+'&weekcolumn='+weekcolumn+'>  next month |</A> ')
resetinit();
if(tiny)document.write('<br>')

nextquarter()
document.write('<b><A HREF='+document.location.pathname+'?inityear='+inityear+'&finyear='+finyear+'&initmonth='+initmonth+'&finmonth='+finmonth+'&initdate='+initdate+'&findate='+findate+'&tiny='+tiny+'&weekcolumn='+weekcolumn+'> next quarter |</A> ')
resetinit();

nextyear()
document.write('<b><A HREF='+document.location.pathname+'?inityear='+inityear+'&finyear='+finyear+'&initmonth='+initmonth+'&finmonth='+finmonth+'&initdate='+initdate+'&findate='+findate+'&tiny='+tiny+'&weekcolumn='+weekcolumn+'> next yr &rarr; </A></b></font>')
resetinit();

newparms(inityear,initmonth,initdate,finyear,finmonth,findate);

}



//// end hiding -->

