<!--Hide from JS-Impaired Browsers
// Some code from http://www.infohiway.com/javascript/ecal2.htm
// Cut-N-Paste JavaScript from ISN Toolbox 
// Copyright 1999, Infohiway, Inc. -->

var default_bg = "linen";

function numDaysIn(mth,yr) {
 if (mth==3 || mth==5 || mth==8 || mth==10) return 30;
 else if ((mth==1) && leapYear(yr)) return 29;
 else if (mth==1) return 28;
 else return 31;
}
function leapYear(yr) {
 if (((yr % 4 == 0) && yr % 100 != 0) || yr % 400 == 0)
  return true;
 else
  return false;
}
// fixes a Netscape 2 and 3 bug
function getFullYear(d) { // d is a date object
 yr = d.getYear();
// if (yr < 1000)
//  yr+=2000;
	if (yr < 90)
		{yr+=2000};
	if (yr < 100)
		{yr+=1900};
	if (yr < 200)
		{yr+=1900};

 return yr;
}
function arr() {
 for (n=0;n<arr.arguments.length;n++) {
  this[n] = arr.arguments[n];
 }
}

//weekdays = new arr("Sun.","Mon.","Tues.","Wed.",
// "Thurs.","Fri.","Sat.");
// *** comment out the one you don't want to use ***
weekdays = new arr("Sunday","Monday","Tuesday","Wednesday",
 "Thursday","Friday","Saturday");
 
//months = new arr("Jan.","Feb.","Mar.","Apr.","May",
// "June","July","Aug.","Sep.","Oct.","Nov.","Dec.");
// *** comment out the one you don't want to use ***
months = new arr("January","February","March","April","May",
 "June","July","August","September","October","November",
 "December");

// Change filename to be the name of this file
var filename="calendar.shtml";
var flg=0;
var today = new Date();

/* You control the size of this calendar
   by specifying the font size (from 1
   through 7) in the var fs below. */
var fs=4;

/* The events array - E - below uses an
     array element for each month from
     Jan thru Dec. The string for each
     month is indexed with a tilde (~), the
     date and a space, followed by the
     event description.  Substitute the
     events you wish here. Use two lines
     (with <BR>) for each. */
/* 
* Note:
* This has now been expanded to a two dimensional array.
* The first index is the year and the second is the month.
*/
/* Note: do *NOT* fill date with 0. For example, 1/9 should be entered as ~9 not ~09 
* NOTE: Month 0 = January, 1 = February, ... , 11 = Dec
*/
E=new arr( 2007, 2008, 2009, 2010 );
E[2007]=new arr("","","","","","","","","","","","");
E[2008]=new arr("","","","","","","","","","","","");
E[2009]=new arr("","","","","","","","","","","","");
E[2010]=new arr("","","","","","","","","","","","");


E[2007][0]="~7 Tiger Den 7<br>Bear Den 4<br>Webelos 2 Den 9<br>Webelos 1 Den 3~8 Wolf Den 5<br>Wolf Den 6~19 Pinewood Derby weigh-in and movie~20 Pack Meeting<br>Pinewood Derby~21 Tiger Den 7<br>Bear Den 4<br>Webelos 2 Den 9<br>Webelos 1 Den 3~22 Wolf Den 5<br>Wolf Den 6~27 Klondike Derby (Webelos)~"
E[2007][1]="~4 Scout Sunday<br>Tiger Den 7<br>Bear Den 4<br>Webelos 2 Den 9<br>Webelos 1 Den 3~5 Wolf Den 5<br>Wolf Den 6~23 Pack Meeting<br>Blue and Gold~25 Tiger Den 7<br>Bear Den 4<br>Webelos 2 Den 9<br>Webelos 1 Den 3~26 Wolf Den 5<br>Wolf Den 6~"
E[2007][2]="~4 Community Day EB Square Mall<br>Tiger Den 7<br>Bear Den 4<br>Webelos 2 Den 9<br>Webelos 1 Den 3~5 Wolf Den 5<br>Wolf Den 6~10 <a href=\"events/OLM2007FLYER.pdf\">Cub Olympics</a>~16 Pack Meeting<br>Space Derby~18 Tiger Den 7<br>Bear Den 4<br>Webelos 2 Den 9<br>Webelos 1 Den 3~19 Wolf Den 5<br>Wolf Den 6~"
E[2007][3]="~1 Tiger Den 7<br>Bear Den 4<br>Webelos 2 Den 9~2 Wolf Den 5<br>Wolf Den 6~13 SEMEOS Camporee (Webelos)~14 SEMEOS Camporee (All)~15 SEMEOS Camporee (Webelos)<br>Tiger Den 7<br>Bear Den 4<br>Webelos 2 Den 9<br>Webelos 1 Den 3~16 Wolf Den 5<br>Wolf Den 6~20 Pack Meeting<br>Bake auction~21 SEMEOS Swim Day (Webelos)~29 Tiger Den 7<br>Bear Den 4<br>Webelos 2 Den 9<br>Webelos 1 Den 3~30 Wolf Den 5<br>Wolf Den 6~"
E[2007][4]="~6 Webelos 1 Den 3~11 Night Flight at Phila Zoo~12 Night Flight~13 Tiger Den 7<br>Bear Den 4<br>Webelos 2 Den 9~14 Wolf Den 5<br>Wolf Den 6~18 Pack Meeting~19 <a href=\"events/2007cubregattaflyer.pdf\">District Raingutter Regatta / Fishing Derby</a>~20 Webelos 1 Den 3~"
E[2007][5]="~1 Tiger Day~3 Tiger Den 7<br>Bear Den 4<br>Webelos 2 Den 9~4 Wolf Den 5<br>Wolf Den 6~9 Program Launch~10 Webelos 1 Den 3~16 Pack Picnic~"
E[2007][6]="~4 Milltown Parade~22 Boy Scout Camp~23 Boy Scout Camp~24 Boy Scout Camp~25 Boy Scout Camp~26 Boy Scout Camp~27 Boy Scout Camp~28Cub Parent Weekend<br>Boy Scout Camp~29 Cub Parent Weekend~30 <a href=\"events/2007SomersetPatriots.pdf\">Somerset Patriots Due</a>~"
E[2007][7]="~1 National Night Out~12 Webelos Resident Camp~13 Webelos Resident Camp~14 Webelos Resident Camp~15 Webelos Resident Camp<br>Mini Resident Camp~16 Webelos Resident Camp<br>Mini Resident Camp~17 Webelos Resident Camp<br>Mini Resident Camp~18 Webelos Resident Camp<br>Mini Resident Camp~25 <a href=\"events/2007SomersetPatriots.pdf\">Somerset Patriots Game</a>~"
E[2007][8]="~~"
E[2007][9]="~~"
E[2007][10]="~~"
E[2007][11]="~21 Pack Meeting~"

E[2008][0]="~18 Pinewood Derby Car weigh-in and movie~19 Pack Meeting (Pinewood Derby)~26 <a href=\"events/BlueAndGold2008.pdf\">Blue and Gold</a> reservations due<br><a href=\"http://www.cnjcscouting.org/SemeosDistrict.shtml\">Klondike Derby</a> (Webelos)~"
E[2008][1]="~3 Scout Sunday~7 Committee Meeting~10 Semeos Leader Training<br><a href=\"events/Feb08SEMLeaderTraining.pdf\">Info</a><br><a href=\"events/Feb08SEMLeaderTrainingRegistration.pdf\">Registration</a>~15 <a href=\"events/RutgersSwim2008.pdf\">Rutgers Swim</a>~29 Pack Meeting<br>Blue and Gold~"
E[2008][2]="~2 Community Day EB Square Mall~6 Committee Meeting 7:30~8 <a href=\"events/CubOlympics2008.pdf\">Cub Olympics</a>~28 Pack Meeting~"
E[2008][3]="~5 Battleship New Jersey<br><a href=\"events/BattleshipNJ2008.pdf\">Preboarding info</a>~11 <a href=\"events/SpringCamporeeBrochure2008.pdf\">SEMEOS Camporee</a> (Webelos)~12 <a href=\"events/SpringCamporeeBrochure2008.pdf\">SEMEOS Camporee</a> (Webelos)~13 <a href=\"events/SpringCamporeeBrochure2008.pdf\">SEMEOS Camporee</a> (Webelos)~18 Pack Meeting<br><a href=\"events/2008CubCamping.pdf\">Summer camp registration</a> due~19 Pack Cleanup 9-11:30~25 Arbor Day Planting~"
E[2008][4]="~1 Committe Meeting 7:30~16 Pack Meeting~"
E[2008][5]="~6 Tiger Day~21 <a href=\"events/Picnic2008.pdf\">Pack/Troop Picnic</a> Class B~"
E[2008][6]="~4 Milltown Parade~19 Pack Planning Meeting 12:00~21 Cub Scout Day Camp~22 Cub Scout Day Camp~23 Cub Scout Day Camp~24 Cub Scout Day Camp~25 Cub Scout Day Camp~26 Cub/Parent Weekend~27 Cub/Parent Weekend~"
E[2008][7]="~1 National Night Out~2 <a href=\"events/SomersetPatriotsGame2008.pdf\">Somerset Patriots</a>~9 <a href=\"events/MemorialCarWash2008.pdf\">Car Wash to benefit Memorial School</a> 9-2~10 Webelos Resident Camp~11 Webelos Resident Camp~12 Webelos Resident Camp~13 Webelos Resident Camp<br>Mini Resident Camp~14 Webelos Resident Camp<br>Mini Resident Camp~15 Webelos Resident Camp<br>Mini Resident Camp~16 Webelos Resident Camp<br>Mini Resident Camp~23 <a href=\"events/ProgramLaunch2008memo.pdf\">Program Launch</a>~"
E[2008][8]="~19 Pack Meeting<br>Invite a friend<br>Membership Drive~"
E[2008][9]="~4 Popcorn show and sell begins~9 Committee Meeting~11 Apple Picking/Pumpkin Picking~17 Pack Meeting~18 Semeos Training~31 Popcorn orders due~"
E[2008][10]="~1 <a href=\"events/ScoutsToTheRescue2008.pdf\">Scouts to the Rescue</a> - Mercer Area District~13 7:30 Committee Mtg~15 Lakota Wolf Preserve~21 Pack Meeting<br>Toy collection<br>Scouting for food<br>Amaryllis Planting~28 Ten Commandments Hike (Webelos)~"
E[2008][11]="~19 Pack meeting~29 <a href=\"events/2008IceSkating.pdf\">Ice Skating</a>~"

E[2009][0]="~8 Committee Mtg 7:30~16 Pack Meeting~24 Klondike Derby (Webelos)~"
E[2009][1]="~6 Pinewood Derby car weigh-in 6-8 and movie 7:30~7 Pinewood Derby 9:00~8 Scout Sunday~12 Commmittee Mtg 7:30~13 <a href=\"events/2009Swim.pdf\">Rutgers Swim Night</a>~28 Blue and Gold~"
E[2009][2]="~1 Community Day EB Square Mall 11-4<br>SEMEOS Recognition dinner~7 <a href=\"events/2009PowWow.pdf\">Pow Wow</a>~12 Commmittee Mtg 7:30~14 Cub Scout Olympics <a href=\"events/2009 Cub Olympics Flyer Registration.pdf\">Information</a> (don't register here)~20 Pack Meeting~29 <a href=\"events/2009Lakota.pdf\">Lakota</a>~"
E[2009][3]="~8 Committee Meeting<br>(Yes, Wed.) 7:30~17 Pack Meeting~"
E[2009][4]="~2 Family Camping~3 Family Camping~7 Committee Mtg~9 Cleanup 9:00 Keystone Park *~15 Pack Meeting~"
E[2009][5]="~11 Committee Mtg 7:30~20 Pack picnic~"
E[2009][6]="~4 Milltown Parade~"
E[2009][7]="~1 Patriots Game~4 National Night Out~8 Cub/Parent~9 Cub/Parent<br>Mini-Res<br>Webelos Camp~10 Mini-Res<br>Webelos Camp~11 Mini-Res<br>Webelos Camp~12 Mini-Res<br>Webelos Camp~13 Webelos Camp~14 Webelos Camp~15 Webelos Camp~"
E[2009][8]="~~"
E[2009][9]="~~"
E[2009][10]="~~"
E[2009][11]="~~"

E[2010][0]="~~"
E[2010][1]="~18 Committee Mtg~27 Pack Mtg<br>Blue and Gold~"
E[2010][2]="~7 Community Day @ Mall~11 Committee Mtg<br>7:30 Nancy's~13 Cub Olympics~19 Pack Mtg<br>Space Derby~"
E[2010][3]="~16 Pack Mtg<br>Cake Auction~"
E[2010][4]="~8 Pack Cleanup 9:00~21 Pack Mtg~22 Irwin Cleanup 10-12~"
E[2010][5]="~5 <a href=\"events/100anniversaryjune5event.pdf\">100 Anniversary</a> includes <a href=\"events/Council_Wide_Pinewood_Derby_Flyer_20101.pdf\">Pinewood Derby</a>~12 Pack Picnic~"
E[2010][6]="~4 Milltown Parade~"
E[2010][7]="~3 National Night Out~"
E[2010][8]="~~"
E[2010][9]="~~"
E[2010][10]="~~"
E[2010][11]="~~"


/*
* Determine the month that is required.
*/
function getMonth()
{
   month=today.getMonth();
   endIndex=location.search.length;

   if( location.search.length > 1 )
   {
      index = location.search.indexOf(",");
      if( index != -1 )
      {
         endIndex=index;
      }

      mon = parseInt(location.search.substring(1,endIndex) );
      if ( ((""+mon).length<=2) && (mon >= 0) && (mon <= 11)) {
         month=mon;
      }
   }
   return( month );
}

/*
* Determine the year that is required.
*/
function getYear() 
{
   year=getFullYear(today);


   if( location.search.length > 1 )
   {
      index = location.search.indexOf(",");
      if( index != -1 )
      {
         yr = parseInt(location.search.substring(index+1) );
      }
      if ( ((""+yr).length<=4) && (yr >= 1900) && (yr <= 2010)) {
         year=yr;
      }
   }
   return( year );
}

/*
* Output HTML to provide a month selection choice.
*/
function addMonthSelect()
{
   document.write( "<SELECT NAME='monthSelect' SIZE=1>" );
   for( i=0; i<mo; i++ )
   {
      document.write( "<OPTION>"+months[i] );
   }
   document.write( "<OPTION SELECTED>"+months[mo] );
   for( i=mo+1; i<12; i++ )
   {
      document.write( "<OPTION>"+months[i] );
   }
   document.write( "</SELECT>" );
}

/*
* Output HTML to provide a year selection choice.
*/
function addYearSelect()
{
   document.write( "<SELECT NAME='yearSelect' SIZE=1>" );
   for( i=2; i>0; i-- )
   {
      document.write( "<OPTION>"+(yr-i) );
   }
   document.write( "<OPTION SELECTED>"+yr );
   for( i=1; i<3; i++ )
   {
      document.write( "<OPTION>"+(yr+i) );
   }
   document.write( "</SELECT>" );
}

/*
* Handle changing the date from month and year selects.
*/
function changeDate(monthObj, yearObj)
{
   newMonth=monthObj.selectedIndex;
   newYear=yearObj.options[yearObj.selectedIndex].text;
   location.href=filename+"?"+newMonth+","+newYear;
}

/*
* Main calendar generator.
*/
function Calendar()
{
 todayYr=getFullYear(today);
 mo=getMonth();
 yr=getYear();

 bgn=new Date(months[mo]+" 1,"+yr);
 dy=bgn.getDay();
 ld=numDaysIn(mo,yr);

// Start table

 document.write("<TABLE BORDER=0 BGCOLOR="+default_bg+" width=85%>");

// janet added links here

document.write("<tr>");
 // Create prev/next jump links
   document.write("<TD align=left>");

   // Prev link
   prevMonth=(mo - 1);
   prevYr=yr;
   if( mo == 0 )
   {
      prevMonth=11;
      prevYr=yr - 1;
   }
   document.write('<a href="'+filename+'?'+prevMonth+','+prevYr+'">&lt;- '+months[prevMonth]+'</a></td><td align=center>');

   // Middle
 document.write("&#09;&#09;<FONT SIZE="+(fs+2)+"><B>"+months[mo]+" "+yr+"</B></FONT>&#09;&#09;");

   // Next link
   nextMonth=(mo + 1);
   nextYr=yr;
   if( mo == 11 )
   {
      nextMonth=0;
      nextYr=yr + 1;
   }
   document.write('</td><td align=right><a href="'+filename+'?'+nextMonth+','+nextYr+'">'+months[nextMonth]+' -&gt;</a>');

   document.write("</TD>");

	if( ( mo == 8) && ( year == 2005 ) )
	{
		document.write('</tr><tr><td colspan=3 align="center">Theme: <a href="http://usscouts.org/bbugle/bb0508/index.html">Cub Scout Round Up</a>');
	}

document.write("</tr></table><TABLE BORDER=2 BGCOLOR="+default_bg+" width=85%>");

// janet added open tr and bold/unbold
	document.write("<tr>");
 for (var i=0;i<7;i++){
  document.write("<TD ALIGN=CENTER WIDTH=14%>"
  +"<FONT SIZE=1><b>"+weekdays[i]+"</b></FONT></TD>");
 }
 document.write("</TR><TR>");
 ctr=0;
 for (var i=0;i<7;i++) {
  /* If the ctr is less than the day of the
     week determined to be the first day
     of the month, print a space in
     this cell of the table. */
  if (i<dy){
   document.write("<TD ALIGN=CENTER>"
   +"<FONT SIZE="+fs+">&nbsp;</FONT>"
   +"</TD>");
  }
  /* Otherwise, write date and the event,
     if any, in this cell of the table. */
  else {
   ctr++;
   di=i; // carry var i outside this routine
   dupWrt();
  }
 }

 document.write("</TR><TR>");
 while (ctr<ld){
  for (var i=0;i<7;i++){
   ctr++;
   /* If the ctr is greater than the last
      day of the month, print a space in
      this cell of the table. */
   if (ctr>ld){
    document.write("<TD ALIGN=CENTER>"
    +"&nbsp;</TD>");
   }
   /* Otherwise, write date and the event,
      if any, in this cell of the table. */
   else{
    di=i; // carry var i outside this routine
    dupWrt();
   }
  }
  document.write("</TR><TR>");
 }

 // Create prev/next jump links
 jump = "";
   document.write("<TD colspan=2 align=center>");

   // Prev link
   prevMonth=(mo - 1);
   prevYr=yr;
   if( mo == 0 )
   {
      prevMonth=11;
      prevYr=yr - 1;
   }
   document.write('<a href="'+filename+'?'+prevMonth+','+prevYr+'">&lt;- '+months[prevMonth]+'</a>');

   // Middle
   // document.write(" &nbsp; | &nbsp; ");
   document.write("</td>");

   // Create quick jump
   document.write( "<TD ALIGN=CENTER COLSPAN=3>" );
   document.write( "<FORM Name='selectForm'>" );
   addMonthSelect();
   addYearSelect();
   document.write( "<INPUT TYPE=BUTTON VALUE='Go' onClick='changeDate"
      +"(document.selectForm.monthSelect,document.selectForm.yearSelect)'>" );
   document.write( "</FORM>" );
   document.write("</TD>");

   // Next link
   nextMonth=(mo + 1);
   nextYr=yr;
   if( mo == 11 )
   {
      nextMonth=0;
      nextYr=yr + 1;
   }
   document.write('<TD ALIGN=CENTER COLSPAN=2><a href="'+filename+'?'+nextMonth+','+nextYr+'">'+months[nextMonth]+' -&gt;</a>');

   document.write("</TD>");

   document.write("</TR>");


 document.write("</TABLE>");

}

function dupWrt() {
var bgcolor = default_bg;
var blank_bg = "lightskyblue";
var past_bg  = "lightgrey";
var today_bg = "lightskyblue";
var future_bg = "lightskyblue";
var event_bg = "lightgoldenrodyellow";

 if ( (mo==today.getMonth()) && (yr==todayYr) && (ctr==today.getDate()) )
 {
	bgcolor=today_bg;
 }
 else if ( (mo==today.getMonth()) && (yr==todayYr) && (ctr<today.getDate()) )
{
	bgcolor=past_bg;
}
 else if ( (mo<today.getMonth()) && (yr==todayYr) )
{
	bgcolor=past_bg;
}
 else if ( yr<todayYr )
{
	bgcolor=past_bg;
}
 else if ( (mo==today.getMonth()) && (yr==todayYr) && (ctr>today.getDate()) )
{
	bgcolor=future_bg;
}
 else if ( (mo>today.getMonth()) && (yr==todayYr) )
{
	bgcolor=future_bg;
}
 else if ( yr>todayYr )
{
	bgcolor=future_bg;
}
 

// now set bgcolor=event_bg;
 if( E[yr] )
 {
  pos=E[yr][mo].indexOf("~"+ctr+" ");
  if (pos>-1){
	bgcolor=event_bg;
   }
  }



 document.write("<TD ALIGN=CENTER bgcolor="+bgcolor+"><FONT SIZE="+fs);
 colorSet=0;
var timeValue = ""
 if ( (mo==today.getMonth()) && (yr==todayYr) && (ctr==today.getDate()) )
 {
  /* Change color to whatever color you wish
     for the current date to be differentiated on
     screen.  */
  document.write(" COLOR='green'");
  colorSet=1;
// janet - put time in today's box
         var now = new Date();
        var hours = now.getHours();
        var minutes = now.getMinutes();
        var timeValue = "<Font color='green'>" + ((hours >12) ? hours -12 :hours)
        timeValue += ((minutes < 10) ? ":0" : ":") + minutes
        timeValue += (hours >= 12) ? " P.M." : " A.M."
        timeValue += "</font><br>"
}
 else if ( (di==0) )
 {
  /* Change color to whatever color you wish
     for Sundays to be differentiated on
     screen.  */
  document.write(" COLOR='black'");
  colorSet=1;
 }
 /* For dates without an event, an HTML padder
    that will align dates properly with dates
    having an event. Here, space break space. */
 tmp="&nbsp;<BR>&nbsp;";
 /* Then check for event in this month's events
    array for this date. If present, rewrite the
    tmp variable to contain the event. */
 if( E[yr] )
 {
  pos=E[yr][mo].indexOf("~"+ctr+" ");
  if (pos>-1){
   tmp=E[yr][mo].substring(pos+3,E[yr][mo].length);
   pos=tmp.indexOf("~");
   tmp=tmp.substring(0,pos);
   if (colorSet!=1){
    /* Change color to whatever color you wish
       for the events to be differentiated on
       screen.  */
    document.write(" COLOR='red'");
   }
  }
 }
 document.write("><B>"+ctr+"</B></FONT><BR><FONT SIZE=1>"+timeValue+tmp+"</TD>");
 }
// End Hiding -->
