// 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 2012

E[0]="~1 ";

FOOTNOTE[0]="";

//Feb 2012

E[1]="~3 ";

//Mar 2012

E[2]="~3";

//Apr 2012

E[3]="~7";

//May 2012

E[4]="~1";

// June 2012

E[5]="~2";

FOOTNOTE[5]="";

// July 2011

E[6]="~4";

//Aug 2011

E[7]="~5";

//Sep 2011

E[8]="~1First of month~27<i>Monthly Meeting</i><br>11:45 a.m.<br>Royal Kona Resort";

//Oct 2011

E[9]="~7 ";

//Nov 2011

E[10]="~4 ";

FOOTNOTE[10]="";

//Dec 2011

E[11]="~2";

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>");

 }






