// JavaScript Document
function SymError() {
  return true;
}

window.onerror = SymError;

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+=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");

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=5;

/* 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. */
	 
// positions 0 thru 5 are for the following year's events as club calendar starts in July

E=new arr("","","","","","","","","","","","","","","","","","");
FOOTNOTE=new arr("","","","","","","","","","","","","","","","","","");
//Jan 2009
E[0]="~1 <i>New Year's Day</i>~6 SIK Board Meeting~13 11:45-1:00 Business Meeting<br>Hospice of Kona~19 <i>Birthday of Martin Luther King Jr.</i>~";
FOOTNOTE[0]="<b>Program Meeting - Ho'olaulea Party at Paula's!!!</b>";
//Feb 2009
E[1]="~3 SIK Board Meeting~6 Region Board Meeting~7 Region Board Meeting~10 11:45-1:00 Business Meeting<br>Hospice of Kona~14 Dinner, Dance and Silent Auction<br>Sheraton Keauhou Beach Resort and Spa<br><i>Valentines's Day</i>~24 11:45-1:00 Program Meeting<br>Awards Program<br>Royal Kona Resort~";
//Mar 2009
E[2]="~3 SIK Board Meeting~10 11:45-1:00 Business Meeting<br>Hospice of Kona~17 <i>St. Patrick's Day</i>~24 11:45-1:00 Program Meeting<br>Alzheimers<br>Royal Kona Resort~";
//Apr 2009
E[3]="~7 SIK Board Meeting~14 11:45-1:00 Business Meeting<br>Hospice of Kona~28 11:45-1:00 Program Meeting<br>Royal Kona Resort~30 Pre-Conference Board Meeting";
//May 2009
E[4]="~1 Annual Region Conference<br>San Ramon~2 Annual Region Conference<br>San Ramon~3 Annual Region Conference<br>San Ramon~5 SIK Board Meeting~12 11:45-1:00 Business Meeting<br>Hospice of Kona~26 11:45-1:00 Program Meeting<br>Makin a Difference for Women Awards~";
// June 2009
E[5]="~2 SIK Board Meeting~9 11:45-1:00 Business Meeting<br>Hospice of Kona~14 Redwood Memorial Grove~23 Program Meeting<br>Installation  of 2009-2010 Board~17 SI Kona Chartered in 1971~";
FOOTNOTE[5]="";

// July 2008
E[6]="~4 <i>4th of July</i>~8 11:45-1:00 Business Meeting<br>Hospice of Kona~22 11:45-1:00 Program Meeting<br>Royal Kona Resort<br><i>Car Injection System</i>~";
//Aug 2008
E[7]="~5 SIK Board Meeting~9 Garage Sale Linda's House<br>Region Board Meeting~9 Region Board Meeting ~10 Region Board Meeting~12 11:45-1:00 Business Meeting<br>Hospice of Kona~26 11:45-1:00 Program Meeting<br>Rob Baird NEHLA<br>Royal Kona Resort~";
//Sep 2008
E[8]="~1 <i>Labor Day</i>~2 SIK Board Meeting~9 11:45-1:00 Business Meeting<br>Hospice of Kona~23 11:45-1:00 Program Meeting<br>Royal Kona Resort~";
//Oct 2008
E[9]="~7 Board Meeting<br><i>Founder's Day (1st Club Chartered in 1921)</i>~14 11:45-1:00 Business Meeting<br>Hospice of Kona~25 District VI Meeting on Maui~26 District VI Meeting on Maui~31 <i>Halloween</i>~";
//Nov 2008
E[10]="~4 SIK Board Meeting~7 Girls Fest Hawaii<br>5th Anniversary<br>November 7-15, 2008<br>Honolulu, HI<br>www.girlsfesthawaii.org <br>Region Board Meeting~8 Region Board Meeting~9 Region Board Meeting~11 11:45-1:00 Business Meeting<br>Hospice of Kona~15 File IRS Form 990 and State Taxes~25 Program Meeting<br>Royal Kona Resort<br><i>International Day for Elimination of Violence against Women</i>~27 <i>Thanksgiving Day</i>~";
FOOTNOTE[10]="";
//Dec 2008
E[11]="~2 SIK Board Meeting~9 11:45-1:00 Business Meeting<br>Hospice of Kona~23 NO PROGRAM MEETING~25 <i>Christmas Day</i>~";
FOOTNOTE[11]="";

/* You can hard code the year by setting
   hard_code_year to true and then setting the
   hard_yr variable to the year you want */
hard_code_year = false; // change to true if desired
hard_yr = 1998; // specify your hard coded year if desired

/* You can hard code the month by setting
   hard_code_date to true and then setting the
   hard_mo variable to the month you want */
hard_code_date = false; // change to true if desired
hard_mo = 3; // 0=Jan, 1=Feb, etc.

function Calendar(){
 mo=today.getMonth();
 rd=today.getDate();
 yr=getFullYear(today);
 if (location.search.length > 1) {
  mon = parseInt(location.search.substring(1,location.search.length));
  if (((""+mon).length<=2) && (mon >= 0) && (mon <= 11)) {
   if (mo > 5 && mon < 6 )  
   		yr = yr + 1; 
   else 
   		{ if (mo < 6 && mon > 5 ) yr = yr -1; };
   mo = mon ;
   rd = -99; // so current day doen't get highlighted
  }
 }

 if (hard_code_year) {
  yr = hard_yr;
  rd = -99; // so current day doen't get highlighted
 }
 if (hard_code_date) {
  mo = hard_mo;
  rd = -99; // so current day doen't get highlighted
 }

 bgn=new Date(months[mo]+" 1,"+yr);
 dy=bgn.getDay();
 
 ld=numDaysIn(mo,yr);
 
// first display navigation to previous and next month 

document.write("<TABLE align=right><TR>");

 jump = "&nbsp;";

 if (mo != 6) {
  mp = mo -1;
  if (mp < 0) mp = mp + 12;
  jump = '<a href="club-calendar.html?'+(mp)+'">&lt;-- View '+months[mp]+'</a>';
  if (mo !=5)
  jump += " &nbsp; | &nbsp; "; 
 };

 if (mo != 5) {
  mn = mo +1;
  if (mn > 11) mn = mn - 12; 
  jump += '<a href="club-calendar.html?'+(mn)+'">View '+months[mn]+' --&gt;</a>';
 };

 if (hard_code_date)
  jump = "";
  
 document.write("<Td>"+jump+"</Td></TR></TABLE><br clear=all>");
 
// start displaying calendar
document.write("<TABLE class='caltbl'>");
document.write("<TR><Th ALIGN=CENTER COLSPAN=7><B>"+months[mo]+" "+yr+"</B></Th>"+"</TR><TR>");
 for (var i=0;i<7;i++){
  document.write("<TD ALIGN=CENTER WIDTH=14%>"+"<FONT SIZE=1>"+weekdays[i]+"</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>"+"&nbsp;"+"</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>");
 }

// last row was navigation, but I moved it to the top of the table, so finish last row and close table  

 if (FOOTNOTE[mo] > "") {
  document.write( "<TD class=caltbl2 colspan=7>"+FOOTNOTE[mo]+"</TD></TR></TABLE>"); 
 }
  else{ document.write("<Td class=caltbl2 colspan=7>&nbsp;</Td></TR></TABLE>"); }

}

function dupWrt() {
 document.write("<TD>"+"<FONT ");
 blue=0;
 

 if (ctr==rd){

  /* Change color to whatever color you wish
     for the current date to be differentiated on
     screen.  */

  document.write(" COLOR='#cc6600'");
  blue=1;

 }

  tmp="&nbsp;";

 /* Then check for event in this month's events
    array for this date. If present, rewrite the
    tmp variable to contain the event. */

 pos=E[mo].indexOf("~"+ctr+" ");

 if (pos>-1){
  tmp=E[mo].substring(pos+3,E[mo].length);
  pos=tmp.indexOf("~");
  tmp=tmp.substring(0,pos);
  if (blue!=1){

   /* Change color to whatever color you wish
      for the events to be differentiated on
      screen. */

   document.write(" COLOR='#000000'");
   }
  }

 document.write("><B>"+ctr+"</B><BR><span class=xsm>"+tmp+"</span></TD>");
 }


