//
// Little Flock Events Calendar.
// Designed by Brian Heitner.

var SpecialDay=1;	// 1=Sunday, 2=Monday, . . . 7=Saturday
var FontSize=5;
var ColorBackground="2949A6";
var ColorSpecialDay = "red";
var ColorToday = "green";
var ColorEvent = "blue";
var weekdays;
var bdr = 0;


// Initialize the range of the calendar to Jan - Dec of the current year.  Calls to DefineEvent( ) will change this
// as needed; it is also possible to explicitly override the range before calling Calendar( ) from the HTML page.

var today = new Date();
var FirstMonth=GetFullYear(today) * 100 + 1;
var LastMonth=FirstMonth + 11;
var numfont;
var weekdaycolor = "7ABEFF";
var weekendcolor = "51B1FF";
var highlightcolor = "AFEFFF";
var nodaycolor = "3F6FCF";
var dayheadercolor = "5A9ADD";
var monthtitle = "99DFFF";
var monthheader = "71A1E7";
var numberfont = 5;
var todaybackground = "BCFCFF";
var monthbottom = "";

// Events[] is a SPARSE array; Call DefineEvent( ) to populate it
var Events = new Array;
var EventDetails = new Array;
var DayBackgrounds = new Array;
var DetailBackgrounds = new Array;
var DayBackgroundv = new Array;
var DayBackgroundt = new Array;
var DetailBackgroundv = new Array;
var DetailBackgroundt = new Array;
var DetailHeaderFont = new Array;
var DayBackgroundtype = new Array;
var MonthBackground = new Array;
var MonthHeaderBackground = new Array;
var MonthBottomBackground = new Array;
var MonthTitleBackground = new Array;
var MonthWeek1Background = new Array;
var MonthWeek2Background = new Array;
var MonthWeek3Background = new Array;
var MonthWeek4Background = new Array;
var MonthWeek5Background = new Array;
var MonthSundayBackground = new Array;
var MonthMondayBackground = new Array;
var MonthTuesdayBackground = new Array;
var MonthWednesdayBackground = new Array;
var MonthThursdayBackground = new Array;
var MonthFridayBackground = new Array;
var MonthSaturdayBackground = new Array;
var NumberFont = new Array;


// Each event is defined by calling the DefineEvent( ) routine with the following parameters:
//
//   DefineEvent(EventDate, EventDescription, EventLink, Image, Width, Height)
//        EventDate is a numeric value in the format YYYYMMDD
//        EvenDescription is a string that can include embedded HTML tags (e.g., <BR>, <strong>, etc.)
//        EventLink is the URL of the target page if a hyperlink is desired from this event entry
//        Image is the URL of the image if you want to display an image with this event
//        Width is the width of the image in pixels
//        Height is the height of the image in pixels

function version () {
var look='width=180,height=120';
var popwin=window.open('','',look);
popwin.moveTo(200,50);
popwin.document.open();
popwin.document.write('<title>Version</title><body bgcolor="7abeff"><CENTER><H3>Version: 1.7.7</H3><h5>Date Modified:  03/13/04</h5><CENTER><FORM><input type="BUTTON" value="CLOSE" onclick="window.close()"></FORM></CENTER></body>');
popwin.document.close();
}


function openday(ind, yr, mo, dy, day, month, dayofweek, bk) {
var bkg = bk;
var look='width=500,height=400';
var fnt;
var popwin=window.open('','',look);
popwin.moveTo(200,50);
popwin.document.open();

if (DetailBackgrounds[ind]) {
    bkg = DetailBackgrounds[ind];};
   fnt = "<font color=000000>";
if (DetailHeaderFont[ind]) {
    fnt = DetailHeaderFont[ind];};

popwin.document.write('<title>'+mo+'/'+dy+'/'+yr+'</title><body '+bkg+'><CENTER><H2>'+fnt+day+' - '+month+' '+dy+', '+yr+'</FONT></H2></CENTER> <BR><BR><B> '+EventDetails[ind]+'</B><BR><BR><CENTER><FORM><input type="BUTTON" value="CLOSE" onclick="window.close()"></FORM></CENTER></body>');
popwin.document.close();

}

function decval (value) {
 var decval, pos1, pos2;
 pos1 = value.substring(0, 1);
 pos2 = value.substring(1, 2);

 if ((pos1 > 'F') || (pos2 > 'F')) alert ('ERROR:'+value+' is not a hexidecimal color value.');

 if (pos1 == 'A') pos1 = 10;
 if (pos1 == 'B') pos1 = 11;
 if (pos1 == 'C') pos1 = 12;
 if (pos1 == 'D') pos1 = 13;
 if (pos1 == 'E') pos1 = 14;
 if (pos1 == 'F') pos1 = 15;
  
 if (pos2 == 'A') pos2 = 10;
 if (pos2 == 'B') pos2 = 11;
 if (pos2 == 'C') pos2 = 12;
 if (pos2 == 'D') pos2 = 13;
 if (pos2 == 'E') pos2 = 14;
 if (pos2 == 'F') pos2 = 15;
 
 decval = (pos1*16) + pos2;
 
 return(decval);

}

function coloradjust (color, type, percent) {
 var newcolor, r, g, b, nr, ng, nb, hr, hg, hb, adj;
 var hexval = new arr ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");

 if (percent.indexOf('%') != (percent.length -1)) {
    alert ('!!ERROR: Percentage sign missing at the end of '+color+'.');}

 percent = percent.replace('%', '');
 
 r = color.substring(0, 2);
 g = color.substring(2, 4);
 b = color.substring(4, 6);

 nr = decval(r);
 ng = decval(g);
 nb = decval(b);

 if (type == "lighter") {
    adj = 1+(percent/100); 
    }
 if (type == "darker") {
     adj = 1-(percent/100); 
    }

 nr = Math.round(nr*adj);
 ng = Math.round(ng*adj);
 nb = Math.round(nb*adj);

 if (nr > 255) nr = 255;
 if (ng > 255) ng = 255;
 if (nb > 255) nb = 255;

 hr = hexval[Math.round((((nr))/16))] + hexval[((((nr))%16)+1)]; 
 hg = hexval[Math.round((((ng))/16))] + hexval[((((ng))%16)+1)]; 
 hb = hexval[Math.round((((nb))/16))] + hexval[((((nb))%16)+1)]; 

 newcolor = hr+hg+hb;

 return (newcolor);


} 

function defaultval (id, value, type) {
   if (id == "weekdaycolor") {
      if (GetType(value) == "PERCENT") {
          value = coloradjust (weekendcolor, type, value);};
        weekdaycolor = value;};

   if (id == "weekendcolor") {
       if (GetType(value) == "PERCENT") {
          value = coloradjust (weekdaycolor, type, value);};
       weekendcolor = value;};

   if (id == "highlightcolor") {
      if (GetType(value) == "PERCENT") {
          value = coloradjust (weekdaycolor, type, value);};
       highlightcolor = value;};

   if (id == "nodaycolor") {
      if (GetType(value) == "PERCENT") {
          value = coloradjust (weekdaycolor, type, value);};
        nodaycolor = value;};

   if (id == "dayheadercolor") {
       dayheadercolor = value;};

   if (id == "month") {
       ColorBackground = value;};

   if (id == "todaycolor") {
      if (GetType(value) == "PERCENT") {
          value = coloradjust (weekdaycolor, type, value);};
       ColorToday = value;};

   if (id == "monthtitle") {
      if (GetType(value) == "PERCENT") {
          value = coloradjust (monthheader, type, value);};
        monthtitle = value;};

   if (id == "monthheader") {
      if (GetType(value) == "PERCENT") {
          value = coloradjust (ColorBackground , type, value);};
       monthheader = value;};

   if (id == "monthbottom") {
      if (GetType(value) == "PERCENT") {
          value = coloradjust (monthbottom , type, value);};
       monthbottom = value;};



   if (id == "eventdaycolor") {
       ColorEvent = value;};

   if (id == "specialdaycolor") {
       ColorSpecialDay = value;};


   if (id == "border") {
       if (value == "NONE") {
           bdr = "0";}
       else {
	      if (GetType(value) == "PERCENT") {
        	  value = coloradjust (ColorBackground , type, value);};

		bdr = value;};
       };
   if (id == "numberfont") {

       numberfont = value;};

   if (id == "todaybackground") {
      if (GetType(value) == "PERCENT") {
          value = coloradjust (weekdaycolor, type, value);};
      if (value == "NONE") {
          value = "";}
      todaybackground = value;};     
  

}


function daybackground(DDate, Value) {
	var tmp, Month, Day, Year;
 	Month = DDate.substring(0, 2);
        Day = DDate.substring(3, 5);
        Year = DDate.substring(6, 10);
        var EventDate = Year+Month+Day;
        DayBackgroundv[EventDate] = Value;

        if (GetType(Value) == "IMAGE") {
            DayBackgrounds[EventDate] = " background = '"+Value+"' ";
            DayBackgroundt[EventDate] = " background = ";}
        if (GetType(Value) == "COLOR") {
           DayBackgrounds[EventDate] = " bgcolor = '"+Value+"' ";
           DayBackgroundt[EventDate] = " bgcolor = ";}
}

function detbackground (DDate, Value) {
	var tmp, Month, Day, Year;
 	Month = DDate.substring(0, 2);
        Day = DDate.substring(3, 5);
        Year = DDate.substring(6, 10);
        var EventDate = Year+Month+Day;
        DetailBackgroundv[EventDate] = Value;
        if (GetType(Value) == "IMAGE") {
            DetailBackgrounds[EventDate] = " background = '"+Value+"' ";
            DetailBackgroundt[EventDate] = " background = ";}
        if (GetType(Value) == "COLOR") {
           DetailBackgrounds[EventDate] = " bgcolor = '"+Value+"' ";
           DetailBackgroundt[EventDate] = " bgcolor = ";}
}

function monthval (Month, id, Value) {
        if (id == "numberfont") {
           NumberFont [Month] = Value;}
}
          
function monthbackground (Month, id, Value) {
      var tmp;

        if (GetType(Value) == "IMAGE") {
            tmp = " background = ";}

        if (GetType(Value) == "COLOR") {
            tmp = " bgcolor = ";}

        if (id == "month") {
           MonthBackground [Month] = tmp + "'"+Value+"' ";}
        if (id == "monthheader") { 
           MonthHeaderBackground [Month] = tmp + "'" +Value+"' ";}
        if (id == "monthtitle") { 
           MonthTitleBackground [Month] = tmp + "'"+Value+"' ";}
        if (id == "monthbottom") { 
           MonthBottomBackground [Month] = tmp + "'" +Value+"' ";}
        if (id == "week1") { 
           MonthWeek1Background [Month] = tmp + "'"+Value+"' ";}		
        if (id == "week2") { 
           MonthWeek2Background [Month] = tmp + "'"+Value+"' ";}
        if (id == "week3") { 
           MonthWeek3Background [Month] = tmp + "'"+Value+"' ";}
        if (id == "week4") { 
           MonthWeek4Background [Month] = tmp + "'"+Value+"' ";}
        if (id == "week5") { 
           MonthWeek5Background [Month] = tmp + "'"+Value+"' ";}

        if (id == "Sunday") { 
           MonthSundayBackground [Month] = tmp + "'"+Value+"' ";}
        if (id == "Monday") { 
           MonthMondayBackground [Month] = tmp + "'"+Value+"' ";}
        if (id == "Tuesday") { 
           MonthTuesdayBackground [Month] = tmp + "'"+Value+"' ";}
        if (id == "Wednesday") { 
           MonthWednesdayBackground [Month] = tmp + "'"+Value+"' ";}
        if (id == "Thursday") { 
           MonthThursdayBackground [Month] = tmp + "'"+Value+"' ";}
        if (id == "Friday") { 
           MonthFridayBackground [Month] = tmp + "'"+Value+"' ";}
        if (id == "Saturday") { 
           MonthSaturdayBackground [Month] = tmp + "'"+Value+"' ";}
            
}


function event(EDate, EventDescription, EventDetail) {
	var tmp, tmp2, Month, Day, Year;
          
 	Month = EDate.substring(0, 2);
        Day = EDate.substring(3, 5);
        Year = EDate.substring(6, 10);
        
        var EventDate = Year+Month+Day;

	// Build the HTML string for this event: image (optional), link (optional), and description
	tmp = "";
	tmp = tmp + EventDescription;      

        if (EventDetail && EventDetail != "") {
            tmp2 = "";
            tmp2 = "<h3>&middot;&nbsp;&nbsp"+tmp + "</h3>" +"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+tmp2 + EventDetail+"<br>";      
            }
        else {
            tmp2 = "<h3>&middot;&nbsp;&nbsp "+tmp + "</h3>";}

	if (EventDetails[EventDate])
		 EventDetails[EventDate] += "<BR>" + tmp2;
	else
		 EventDetails[EventDate] = tmp2;


	// If an event already exists for this date, append the new event to it.
	if (Events[EventDate])
		Events[EventDate] += "<BR>" + tmp;
	else
		Events[EventDate] = tmp;

	// Adjust the minimum and maximum month & year to include this date
	tmp = Math.floor(EventDate / 100);
	if (tmp < FirstMonth) FirstMonth = tmp;
	if (tmp > LastMonth) LastMonth = tmp;
}


function dayimage(IDate, Image, Width, Height) {
	var tmp, Month, Day, Year;
 	Month = IDate.substring(0, 2);
        Day = IDate.substring(3, 5);
        Year = iDate.substring(6, 10);
        var EventDate = Year+Month+Day;

	// Build the HTML string for this event: image (optional), link (optional), and description
	tmp = "";
	tmp = tmp + '<img src="' + Image + '"';
        if (Width != "") {
            tmp = tmp + ' width="' + Width + '"';}
        if (Height  != "") {
            tmp = tmp +' height="' + Height + '">';}


	// If an event already exists for this date, append the new event to it.
	if (Events[EventDate])
		Events[EventDate] += "<BR>" + tmp;
	else
		Events[EventDate] = tmp;

	// Adjust the minimum and maximum month & year to include this date
	tmp = Math.floor(EventDate / 100);
	if (tmp < FirstMonth) FirstMonth = tmp;
	if (tmp > LastMonth) LastMonth = tmp;
}


function detailheaderfont(FDate, Font, Size, Color) {
	var tmp, Month, Day, Year;
 	Month = FDate.substring(0, 2);
        Day = FDate.substring(3, 5);
        Year = FDate.substring(6, 10);
        var EventDate = Year+Month+Day;


	// Build the HTML string for this event: image (optional), link (optional), and description
	tmp = "";
	tmp = tmp + '<font face="' + Font + '"';
        if (Size != "") {
            tmp = tmp + ' size="' + Size + '"';}
        if (Color  != "") {
            tmp = tmp +' color="' + Color + '">';}

	DetailHeaderFont[EventDate] = tmp;

        


	// Adjust the minimum and maximum month & year to include this date
	tmp = Math.floor(EventDate / 100);
	if (tmp < FirstMonth) FirstMonth = tmp;
	if (tmp > LastMonth) LastMonth = tmp;
}


function dayfont(FDate, Font, Size, Color) {
	var tmp, Month, Day, Year;
 	Month = FDate.substring(0, 2);
        Day = FDate.substring(3, 5);
        Year = FDate.substring(6, 10);
        var EventDate = Year+Month+Day;

	// Build the HTML string for this event: image (optional), link (optional), and description
	tmp = "";
	tmp = tmp + '<font face="' + Font + '"';
        if (Size != "") {
            tmp = tmp + ' size="' + Size + '"';}
        if (Color  != "") {
            tmp = tmp +' color="' + Color + '">';}

	if (Events[EventDate])
		Events[EventDate] += tmp;
	else
		Events[EventDate] = tmp;


	// Adjust the minimum and maximum month & year to include this date
	tmp = Math.floor(EventDate / 100);
	if (tmp < FirstMonth) FirstMonth = tmp;
	if (tmp > LastMonth) LastMonth = tmp;
}


function detailfont(FDate, Font, Size, Color) {
	var tmp, Month, Day, Year;
 	Month = FDate.substring(0, 2);
        Day = FDate.substring(3, 5);
        Year = FDate.substring(6, 10);
        var EventDate = Year+Month+Day;

	// Build the HTML string for this event: image (optional), link (optional), and description
	tmp = "";
	tmp = tmp + '<font face="' + Font + '"';
        if (Size != "") {
            tmp = tmp + ' size="' + Size + '"';}
        if (Color  != "") {
            tmp = tmp +' color="' + Color + '">';}

	if (EventDetails[EventDate])
		EventDetails[EventDate] += tmp;
	else
		EventDetails[EventDate] = tmp;


	// Adjust the minimum and maximum month & year to include this date
	tmp = Math.floor(EventDate / 100);
	if (tmp < FirstMonth) FirstMonth = tmp;
	if (tmp > LastMonth) LastMonth = tmp;
}



// Utility function to populate an array with values
function arr() {
	for (var n=0;n<arr.arguments.length;n++) {
		this[n+1] = arr.arguments[n];
	}
}

// Create the array of month names (used in various places)
var months = new arr("January","February","March","April","May","June","July","August","September","October","November","December");

// Calendar( ) is the only routine that needs to be called to display the calendar

function Calendar( ) {

	var curdy, curmo, yr, mo, dy, dayofweek, yearmonth, bgn, lastday, jump;
	var thispage = window.location.pathname;
        var nuweek = 2;
        var daybkgrnd;
        var CurBackground = " BGCOLOR="+ColorBackground+" ";
        var CurHeaderBackground = " bgcolor="+monthheader+" ";
        var CurTitleBackground = " bgcolor="+monthtitle+" ";
        var CurBottomBackground = " bgcolor="+monthbottom+" ";
        var CurWeek1Background;
        var CurWeek2Background;
        var CurWeek3Background;
        var CurWeek4Background;
        var CurWeek5Background;
        var CurDayheadBackground;
        var CurWeekBackground;
        var typ3;
        var curyearmonth;
       
	weekdays = new arr("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

	// Save current day and month for comparison
	curdy = today.getDate();
	curmo = today.getMonth()+1;

	// Default to current month and year
	mo = curmo;
	yr = GetFullYear(today);
	yearmonth = (yr * 100) + mo;
        curyearmonth = yearmonth;

   
	// If querystring parameter is present, get the month/year ("calendar.htm?YYYYMM")
	if (location.search.length > 1) {
		yearmonth = parseInt(location.search.substring(1,location.search.length));
		if ((""+yearmonth).length == 6) {
			mo = yearmonth % 100;
			yr = (yearmonth - mo) / 100;
		}
	}

	// Constrain to the range of months with events


	// Create a datae object for the first day of the desired month
	bgn = new Date(months[mo] + " 1," + yr);
	// Get the day-of-week of the first day, and the # days in the month
	dayofweek = bgn.getDay();
	lastday = NumDaysIn(mo,yr);

        CurBackground = " BGCOLOR="+ColorBackground+" ";
        CurHeaderBackground = " bgcolor="+monthheader+" ";
        CurTitleBackground = " bgcolor="+monthtitle+" ";
        CurBottomBackground =  " ";

        if (MonthBackground[mo]) {  
           CurBackground = MonthBackground[mo];}

        if (MonthHeaderBackground [mo]) {  
           CurHeaderBackground = MonthHeaderBackground[mo];}

        if (MonthTitleBackground [mo]) {  
           CurTitleBackground = MonthTitleBackground [mo];}

        if (MonthBottomBackground [mo]) {  
           CurBottomBackground= MonthBottomBackground [mo];}

  
	document.write("<TABLE border="+bdr+" width=540 "+CurBackground+"><TR><TD height=90 ALIGN=CENTER "+CurHeaderBackground+" COLSPAN=7><table "+CurTitleBackground +"><tr><td><FONT SIZE="+NumberFont+"><B>"+months[mo]+" "+yr+"</B></FONT></td></tr></table></TD></TR><TR id=dayheader bgcolor='"+dayheadercolor+"'>");
	for (var i=1;i<=7;i++){
                CurDayheadBackground = "";
                if (i==1 && MonthSundayBackground [mo]) {
                  CurDayheadBackground = MonthSundayBackground [mo];};

                if (i==2 && MonthMondayBackground [mo]) {
                  CurDayheadBackground = MonthMondayBackground [mo];};

                if (i==3 && MonthTuesdayBackground [mo]) {
                  CurDayheadBackground = MonthTuesdayBackground [mo];};

                if (i==4 && MonthWednesdayBackground [mo]) {
                  CurDayheadBackground = MonthWednesdayBackground [mo];}; 
            
                if (i==5 && MonthThursdayBackground [mo]) {
                  CurDayheadBackground = MonthThursdayBackground [mo];};

                if (i==6 && MonthFridayBackground [mo]) {
                  CurDayheadBackground = MonthFridayBackground [mo];};

                if (i==7 && MonthSaturdayBackground [mo]) {
                  CurDayheadBackground = MonthSaturdayBackground [mo];};

		document.write("<TD  id="+weekdays[i]+" "+CurDayheadBackground +" ALIGN=CENTER WIDTH=14%><FONT SIZE=2><b>"+weekdays[i]+"</b></FONT></TD>");
	}
        CurWeekBackground = "";
        CurWeekBackground  = MonthWeek1Background [mo]; 

	document.write("</TR><TR id=week1 "+CurWeekBackground+">");
	dy = 1;
        typ3 = " bgcolor = ";
        if (nodaycolor == "NONE" ||nodaycolor== "") {
           nodaycolor = "";
           typ3 = "";} 

	// Special handling for the first week of the month
	for (var i=1;i<=7;i++) {
		// If the day 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 <= dayofweek){
			document.write("<TD"+typ3+nodaycolor+" ALIGN=CENTER><FONT SIZE="+FontSize+">&nbsp;</FONT></TD>");
		}
		// Otherwise, write date and the event,
		// if any, in this cell of the table.
		else {
			ShowDate(yr,mo,dy,i,curmo,curdy);
			dy++;
		}
	}
	document.write("</TR><TR>");
	// Rest of the weeks . . .
	while (dy <= lastday) {
		for (var i=1;i<=7;i++) {
			// If the day is greater than the last
			// day of the month, print a space in
			// this cell of the table.
			if (dy > lastday) {
				document.write("<TD "+typ3+nodaycolor+" ALIGN=CENTER>&nbsp;</TD>");
			}
			// Otherwise, write date and the event,
			// if any, in this cell of the table.
			else {
				ShowDate(yr,mo,dy,i,curmo,curdy);
				dy++;
			}
		}
        CurWeekBackground == "";

        if (nuweek == 2 && MonthWeek2Background [mo]) {  
           CurWeekBackground  = MonthWeek2Background [mo];}
        if (nuweek == 3 && MonthWeek3Background [mo]) {  
           CurWeekBackground  = MonthWeek3Background [mo];}    
        if (nuweek == 4 && MonthWeek4Background [mo]) {  
           CurWeekBackground  = MonthWeek4Background [mo];}    
        if (nuweek == 5 && MonthWeek5Background [mo]) {  
           CurWeekBackground  = MonthWeek5Background [mo];}    

		document.write("</TR><TR id=week"+nuweek+" "+CurWeekBackground+">");
                nuweek++;
	}

	jump = "";
	jump += '<form name="GOFORM"><table bgcolor="AAAAAA"><tr><td>Month'+BuildMonthList(mo);
        jump +=  '</td><td>Year<INPUT name=Year type=TEXT size=4 value='+(yr)+'></td><td valign=TOP><table cellspacing=0 cellpading=0><tr><td><INPUT name=Plusyear align=right type=BUTTON value="+" onclick="javascript:document.forms[0].Year.value=(parseInt(document.forms[0].Year.value)+1)"></td><td align=left valign=TOP><td><INPUT name=Plusyear type=BUTTON value="-" onclick="javascript:document.forms[0].Year.value=(parseInt(document.forms[0].Year.value)-1)"> </td></tr></table></td><td valign=TOP><a  href="javascript:GoYearMonth()"><img src="GO.jpg"></a></td></tr></table></form><br><table width= 100%> <tr><td align=left width=33%><a  href="' + thispage + '?'+PrevYearMonth(yearmonth)+'"><img border = 0 src = "prevmonth.gif" width=100></font></a></td><td align=center width=33%><a href ="'+thispage + '?'+curyearmonth+'"><img border = 0 src = "currmonth.gif" width=100></a></td><td align=right width=33%><a href ="'+thispage + '?'+NextYearMonth(yearmonth)+'"><img border = 0 src = "nextmonth.gif" width=100></a></td></tr></table>';
	document.write("</TR><TR><TD align=center width=100% colspan=7><TABLE width=100% name=monthbottom " + CurBottomBackground + " cellspacing=0 cellpadding=0 border=0><TR><TD colspan=7 align=center>"+jump+"</TD></TR>");
	document.write("</td></tr></table></TD></TR></TABLE><br><table width=540 border=0 cellspacing=0><tr><td><CENTER><a href ='javascript:version()'><font size=-1 color='0000FF'>Version</font></a></CENTER></td></tr></table><br>");
}

// Display a date in the appropriate color, with events (if there are any)

function ShowDate(yr, mo, dy, dayofweek, currentmonth, currentday) {
	var ind, HighlightEvent, tmp, clr, typ, bkg, typ2, nfont;
        
        typ = " bgcolor = ";
        if (dayofweek==1 ||dayofweek==7) {
           clr = weekendcolor;}
        else {          
 	   clr = weekdaycolor;}

        typ2 = typ+clr;
 
	ind = (((yr * 100) + mo) * 100) + dy;

        bkg = clr;       
        
        if (DayBackgrounds[ind]) {
           clr = DayBackgrounds[ind];
	   if (GetType(DayBackgroundv[ind]) == 'IMAGE') {
              bkg = "url("+DayBackgroundv[ind]+")";
              typ2 = 'background='+DayBackgroundv[ind];
              }
           else {
               bkg = DayBackgroundv[ind];
               typ2 = " bgcolor = "+DayBackgroundv[ind];}
           typ = ""};

	if ((mo == currentmonth) && (dy == currentday)) {
		   if (todaybackground > "") {
   		   clr = todaybackground;
                   if (todaybackground == "INVISIBLE") {
                       clr = "";}
		   bkg = clr;
                   typ2 = "bgcolor = " + todaybackground;};
           };

         if (clr == "NONE" || clr== "") {
           clr = "";
           typ = "";
           typ2 = "";} 
    
           nfont = numberfont;
      
        if (NumberFont [mo]) {
            nfont = NumberFont [mo]; } 
        
	document.write("<TD height= 75"+typ+"'"+clr+"' VALIGN=TOP onMouseOver = 'this.style.background=&quot;#"+highlightcolor+"&quot;'  onMouseOut = 'this.style.background=&quot;"+bkg+"&quot;' onclick='javascript:openday("+ind+", "+yr+", "+mo+", "+dy+", &quot;"+weekdays[dayofweek]+"&quot;, &quot;"+months[mo]+"&quot;, "+dayofweek+", &quot;"+typ2+"&quot;)'><FONT SIZE="+nfont);
	HighlightEvent = true;
	if (dayofweek == SpecialDay) {
		document.write(" COLOR=" + ColorSpecialDay);
		HighlightEvent = false;
	}
	if ((mo == currentmonth) && (dy == currentday)) {
		document.write(" COLOR=" + ColorToday);     
		HighlightEvent = false;
	}
	if (Events[ind]) {
		tmp = Events[ind];
		if (HighlightEvent) {
			 document.write(" COLOR=" + ColorEvent);
		}
	} else tmp="&nbsp;<BR>&nbsp;";
	document.write("><B>"+dy+"</B></FONT><CENTER><FONT SIZE=1>"+tmp+"</CENTER></TD>");
}


// Remaining routines are utilities used above

function NumDaysIn(mo,yr) {
	if (mo==4 || mo==6 || mo==9 || mo==11) return 30;
	else if ((mo==2) && LeapYear(yr)) return 29;
	else if (mo==2) 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
	var yr;

	yr = d.getYear();
	if (yr < 1000)
	yr +=1900;
	return yr;
}

function PrevMonth(mth) {
	if (mth == 1) return 12;
	else return (mth-1);
}

function NextMonth(mth) {
	if (mth == 12) return 1;
	else return (mth+1);
}

function PrevYearMonth(yrmth) {
	if ((yrmth % 100) == 1) return ((yrmth-100)+11);
	else return (yrmth-1);
}

function NextYearMonth(yrmth) {
	if ((yrmth % 100) == 12) return ((yrmth-11)+100);
	else return (yrmth+1);
}


function JumpTo(calendar, thispage) {
	var sel, yrmo;

	sel = calendar.selectedIndex;
	yrmo = calendar.form.jumpmonth[sel].value;
	document.location = thispage + "?" + yrmo;
}

function GoYearMonth() {
  var month = parseInt(document.forms[0].Month.value);
  var year =  parseInt(document.forms[0].Year.value);
  var curyear = GetFullYear(today);
  if ((month < 1) || (month > 12)) {
      alert ('!ERROR: Month must be between 1 and 12');
      return;
     }
   
   if (Math.abs(curyear - year) > 10) {
      alert ('***WARNING: Year entered is '+(Math.abs(curyear - year))+' years away. Please check your year.');
    }
      
        parent.location= window.location.pathname + '?'+((document.forms[0].Year.value * 100) + (parseInt(document.forms[0].Month.value) )); 
}

function GetType (value) {
   if (value.indexOf('%') == (value.length -1)) {
      return ('PERCENT');};
   if (value.substring((value.length -4), (value.length - 3)) == '.') {
      return ('IMAGE');};
   else {return ('COLOR');};

};

function BuildMonthList(curmo) {
        var mo, yr, yearmonth, jmpmo, n, sellist;

        if (curmo == 12) {jmpmo=1;};
        else {jmpmo = curmo + 1;};

      	sellist = "<select name=Month size=1>";
        for (var n=1;n<=12;n++) {
		sellist += "<option value=";
		sellist += n;
		if (n ==  (jmpmo)) sellist += " selected";
		sellist += ">";
		sellist += months[n]+"</option>";
             }
 	sellist += "</select>";
        return (sellist);
}
