// Holiday Routines
// ##############################################################

var Holi_Date	= new Date();
var Holi_Year	= Holi_Date.getYear();
var Holi_Day	= Holi_Date.getDate();
if ( Holi_Year < 1000 )	{ Holi_Year += 1900; }
var Holi_Month  = Holi_Date.getMonth(); Holi_Month = Holi_Month + 1;
var Holi_Dow	= Holi_Date.getDay();
var akey	= 0;
var xkey	= 0;
var nkey	= 0;
var adash	= "-";
var empty	= "";
var holimsg	= empty;
var holnext	= empty;
var holims2	= empty;
var holix	= empty;
var holix2	= empty;
var holi2	= empty;
var seasm1	= empty;
var seasm2	= empty;
var seasm3	= empty;
var seasmsg	= empty;
var xx		= empty;
var yy		= empty;
var br		= "<BR>";
var h		= "Happy ";
var hb		= h + "Birthday ";

var aholi	= 0;
var bholi	= adash;
var bholidys	= 0;
var cholidys	= 0;
var nholi	= adash;
var xholix	= 0;
var yrs		= 0;
var Holi_Nday	= new Array(35);
var Holi_Days	= new Array(35);
var Holi_Msgs	= new Array(35);
var Holi_mo	= new Array(35);
var Holi_dy	= new Array(35);
var Holi_AAs	= new Array(35);
// ##############################################################
var ix		= 0;
for ( ix = 0; ix < 35; ix++ )	{ Holi_AAs[ ix ] = 0; }

ix		= 0;
      Holi_Days[ix] = "0101"; Holi_mo[ix] = 01; Holi_dy[ix] = 01; Holi_Msgs[ix] = h + "New Years";
ix++; Holi_Days[ix] = "0104"; Holi_mo[ix] = 01; Holi_dy[ix] = 04; Holi_Msgs[ix] = h + "Steve's AA"; Holi_AAs[ ix ] = 1986;
ix++; Holi_Days[ix] = "0202"; Holi_mo[ix] = 02; Holi_dy[ix] = 02; Holi_Msgs[ix] = hb + "Mary";
ix++; Holi_Days[ix] = "0211"; Holi_mo[ix] = 02; Holi_dy[ix] = 11; Holi_Msgs[ix] = hb + "Becky";
ix++; Holi_Days[ix] = "0216"; Holi_mo[ix] = 02; Holi_dy[ix] = 16; Holi_Msgs[ix] = h + "Anniversary Steve & Brigid"; Holi_AAs[ ix ] = 1991;

ix++; Holi_Days[ix] = "0221"; Holi_mo[ix] = 02; Holi_dy[ix] = 21; Holi_Msgs[ix] = hb + "Dad Prendergast";
ix++; Holi_Days[ix] = "0225"; Holi_mo[ix] = 02; Holi_dy[ix] = 25; Holi_Msgs[ix] = hb + "Steve Zeck";
ix++; Holi_Days[ix] = "0302"; Holi_mo[ix] = 03; Holi_dy[ix] = 02; Holi_Msgs[ix] = hb + "Steve";
ix++; Holi_Days[ix] = "0303"; Holi_mo[ix] = 03; Holi_dy[ix] = 03; Holi_Msgs[ix] = hb + "Mom Prendergast";
ix++; Holi_Days[ix] = "0305"; Holi_mo[ix] = 03; Holi_dy[ix] = 05; Holi_Msgs[ix] = hb + "Donna Zeck";

ix++; Holi_Days[ix] = "0320"; Holi_mo[ix] = 03; Holi_dy[ix] = 20; Holi_Msgs[ix] = h + "Ruth's AA"; Holi_AAs[ ix ] = 1984;
ix++; Holi_Days[ix] = "0324"; Holi_mo[ix] = 03; Holi_dy[ix] = 24; Holi_Msgs[ix] = hb + "Allie Rock";
ix++; Holi_Days[ix] = "0328"; Holi_mo[ix] = 03; Holi_dy[ix] = 28; Holi_Msgs[ix] = h + "Anniversary David & Marki"; Holi_AAs[ ix ] = 1959;
ix++; Holi_Days[ix] = "0401"; Holi_mo[ix] = 04; Holi_dy[ix] = 01; Holi_Msgs[ix] = h + "Allie Rock's AA"; Holi_AAs[ ix ] = 1981;
ix++; Holi_Days[ix] = "0420"; Holi_mo[ix] = 04; Holi_dy[ix] = 20; Holi_Msgs[ix] = h + "Brigid's AA"; Holi_AAs[ ix ] = 1979;

ix++; Holi_Days[ix] = "0422"; Holi_mo[ix] = 04; Holi_dy[ix] = 22; Holi_Msgs[ix] = hb + "John";
ix++; Holi_Days[ix] = "0505"; Holi_mo[ix] = 05; Holi_dy[ix] = 05; Holi_Msgs[ix] = hb + "Amy";
ix++; Holi_Days[ix] = "0512"; Holi_mo[ix] = 05; Holi_dy[ix] = 12; Holi_Msgs[ix] = hb + "Tommy";
ix++; Holi_Days[ix] = "0704"; Holi_mo[ix] = 07; Holi_dy[ix] = 04; Holi_Msgs[ix] = h + "Fourth of July";
ix++; Holi_Days[ix] = "0715"; Holi_mo[ix] = 07; Holi_dy[ix] = 15; Holi_Msgs[ix] = hb + "Brigid";

ix++; Holi_Days[ix] = "0719"; Holi_mo[ix] = 07; Holi_dy[ix] = 19; Holi_Msgs[ix] = hb + "Marki";
ix++; Holi_Days[ix] = "0805"; Holi_mo[ix] = 08; Holi_dy[ix] = 05; Holi_Msgs[ix] = h + "Becky's AA"; Holi_AAs[ ix ] = 1984;
ix++; Holi_Days[ix] = "0819"; Holi_mo[ix] = 08; Holi_dy[ix] = 19; Holi_Msgs[ix] = hb + "Cody Kerns";
ix++; Holi_Days[ix] = "0826"; Holi_mo[ix] = 08; Holi_dy[ix] = 26; Holi_Msgs[ix] = hb + "David K. and William N.";
ix++; Holi_Days[ix] = "0913"; Holi_mo[ix] = 09; Holi_dy[ix] = 13; Holi_Msgs[ix] = hb + "David";

ix++; Holi_Days[ix] = "0914"; Holi_mo[ix] = 09; Holi_dy[ix] = 14; Holi_Msgs[ix] = hb + "Kelli";
ix++; Holi_Days[ix] = "1005"; Holi_mo[ix] = 10; Holi_dy[ix] = 05; Holi_Msgs[ix] = hb + "Ruth";
ix++; Holi_Days[ix] = "1013"; Holi_mo[ix] = 10; Holi_dy[ix] = 13; Holi_Msgs[ix] = hb + "Dawson Kerns";
ix++; Holi_Days[ix] = "1031"; Holi_mo[ix] = 10; Holi_dy[ix] = 31; Holi_Msgs[ix] = hb + "";

ix++; Holi_Days[ix] = "1201"; Holi_mo[ix] = 12; Holi_dy[ix] = 01; Holi_Msgs[ix] = h + "John's AA"; Holi_AAs[ ix ] = "1976";
ix++; Holi_Days[ix] = "1225"; Holi_mo[ix] = 12; Holi_dy[ix] = 25; Holi_Msgs[ix] = "Merry Christmas";
ix++; Holi_Days[ix] = "1231"; Holi_mo[ix] = 12; Holi_dy[ix] = 31; Holi_Msgs[ix] = h + "New Years Eve";
var MaxHolis	= ix;
var max_ix	= MaxHolis + "";
for ( ix = 0; ix <= MaxHolis; ix++ )
{
	Holi_mo  [ ix ] = 0 + Holi_mo [ ix ];
	Holi_dy  [ ix ] = 0 + Holi_dy [ ix ];
	Holi_Nday[ ix ] = 0 + Holi_Days[ ix ];
}
// ##############################################################
function WriteSeasonB() {
	GetHoliDate();
	show_seas	= Find_Season( Holi_Month, Holi_Day, Holi_Year );
	x	= show_seas.replace( " ", br );
	show_seas	= x.replace( " ", br );
	document.write( show_seas );
}
// ##############################################################
function WriteHoli() {
	GetHoliDate();
	holimsg	= Find_Holiday( Holi_Month, Holi_Day, Holi_Dow );
	document.write( holimsg );
}

function WriteSeason() {
	GetHoliDate();
	show_seas	= Find_Season( Holi_Month, Holi_Day, Holi_Year );
	document.write( show_seas );
}

function Write_Holiday() {
	GetHoliDate();
	holimsg	= Find_Holiday( Holi_Month, Holi_Day, Holi_Dow );
	elem	= document.getElementById( "My_Holiday" );
	if ( elem )	{ elem.innerHTML = holimsg; }
}

function Write_A_Holiday( Month, Day, Dow ) {
	holimsg	= Find_Holiday( Month, Day, Dow );
	elem	= document.getElementById( "My_Holiday" );
	if ( elem )	{ elem.innerHTML = holimsg; }
}

function Write_B_Holiday( Month, Day, Dow ) {
	x1	= Find_Holiday( Month, Day, Dow );
	holimsg = x1.replace( "=", br );
	elem	= document.getElementById( "My_Holiday" );
	if ( elem )	{ elem.innerHTML = holimsg; }
}

function Write_Season() {
	GetHoliDate();
	show_seas	= Find_Season( Holi_Month, Holi_Day, Holi_Year );
	elem	= document.getElementById( "My_Season" );
	if ( elem )	{ elem.innerHTML = show_seas; }
}

function Write_A_Season( Month, Day, Year ) {
	show_seas	= Find_Season( Month, Day, Year );
	elem	= document.getElementById( "My_Season" );
	if ( elem )	{ elem.innerHTML = show_seas; }
}
//
// ##############################################################
function no2( a_num ) {
	var xx1	= a_num + "";
	if ( xx1.length < 2 )	{ xx1	= "0" + xx1; }
	return( xx1 );
}
// ##############################################################
function GetHoliDate() {
	Holi_Date  = new Date();
	Holi_Year  = Holi_Date.getYear();
	Holi_Day   = Holi_Date.getDate();
	if ( Holi_Year < 1000 )	{ Holi_Year += 1900; }
	Holi_Month = Holi_Date.getMonth(); Holi_Month = Holi_Month + 1;
}
// ##############################################################
function Get_Holiday2_days() {
	return( bholidys );
}
function Find_Holiday( Month, Day, Dow ) {
	aholi	= 0;
	bholi	= adash;
	bholidys= 0;
	Month	= no2( Month );
	Day	= no2( Day );
	holix	= Get_Holiday( Month, Day );
	if ( Holi_AAs[ xholix ] > 0 )
	{
		yrs	= Holi_Year - Holi_AAs[ xholix ];
		holix	= holix + " " + yrs + ' Years !';
	}

	holix2	= Get_Holi2( Month, Day, Dow );
	if ( aholi == 0 && holix2 != adash && holix2.length > 4 )
	{
		if ( bholi != adash )			{ holix	= " !-! " + holix2 + "-!"; holix2 = adash; }
		else
		{
			x	= "/" + holix2 + "/i";
			if ( holix.search( x ) != -1 )	{ holix	+= " !=! " + holix2 + "=!"; holix2 = adash; }
		}
	}

	if ( holix == adash )
	{
		holix = holix2;
		holix2	= adash;
		if ( holix == adash )	{ holix	= holnext; }
	}
	if ( holix2 != adash )	{ holix	+= " " + holix2; }
	return( holix );
}
// ##############################################################
function Get_Holiday( Month, Day ) {
	akey	= Month + Day;
	Month	= no2( Month );
	Day	= no2( Day );
	ymo	= Month + "";
	ydy	= Day + "";
	xholi	= adash;
	bholi	= adash;
	bholidys= 0;
	holnext = adash;
	aholi	= 0;
	nmo	= Month + 1;
	yy	= " - " + ymo + adash + ydy + " ++";

	for (var ix = 0; ix <= MaxHolis; ix++)
	{
		xkey	= Holi_Days[ ix ];
		nkey	= Holi_Nday[ ix ];
		bholi	= Holi_Msgs[ ix ];
		xholix	= ix;
		if ( akey == xkey )
		{
			aholi	= ix + 1;
			xholi	= bholi;
			return( xholi );
		}
		if ( ( akey == nkey ) || ( 0 + akey == nkey ) )
		{
			aholi	= ix + 1;
			xholi	= bholi;
			return( xholi );
		}

		xmo	= Holi_mo[ ix ];
		xdy	= Holi_dy[ ix ];
		xx	= " " + xmo + "-" + xdy + " = ";
		if ( ymo == xmo )
		{
			if ( ydy < xdy )
			{
				xtill	= xdy - ydy;
				bholidys= xtill;
				if ( xtill == 1 )	{ holnext	= "1 Day until" + xx; }
				else			{ holnext	= xtill + " Days until" + xx; }
				holnext += bholi;
				xholi	= holnext;
				return( xholi );
			}
			else
			{
				xtill	= ydy - xdy;
				bholidys= -xtill;
				holnext = "Last Holiday was " + xtill + " Days ago.";
				xholi	= holnext;
			}
		}
		if ( ymo < xmo )
		{
			if ( ymo == ( xmo - 1 ) )	{ holnext = " Next Holiday is next Month " + nmo; }
			else				{ holnext = " Next Holiday is"; }
			holnext += " " + xx + br + bholi;
			xholi	= holnext;
			return( xholi );
		}
	}
	return( xholi );
}
// ##############################################################
function get_suff( innum )
{
	var remainder = innum % 10;
	if ( remainder == 1 )		{ return( "st" ); }
	if ( remainder == 2 )		{ return( "nd" ); }
	if ( remainder == 3 )		{ return( "rd" ); }
	return( "th" );
}
// ##############################################################
function Get_Holi2_Msg() {
	return( holi2 );
}
// ##############################################################
function Get_Holi2( Month, Day, Dow ) {
	var nx	= Day;
	Month	= no2( Month );
	Day	= no2( Day );
	holi2	= adash;
	cholidys= 0;
	var nn	= 0;
	// May
	if ( Month == 05 )
	{
		if ( Day < 24 )
		{
			nn	= 25 - Day;
			x	= 7 - Dow;
			nn	+= x;
			nx	= nx - 1 + 1;
			nx	+= nn + 1;
			cholidys= nx;
			x	= get_suff( nx );

			holi2	= "Have a Happy Memorial Day in " + nn + " Days on the " + nx + x;
			nholi	= 3;
		}
		if ( Day > 24 )
		{
			holi2	= "!>24! " + Month + " - " + Day + " - " + Dow + " :";
			if ( Dow == 1 )
			{
				holi2	= "Happy Memorial Day";
				nholi	= 1;
			}
			else
			{
				x	= Day - 24;
				if ( x < Dow )
				{
					x	= 7 - Dow;
					cholidys= x;
					holi2	= "Have a Happy Memorial Day in " + x + " Days";
					nholi	= 2;
				}
			}
		}
		cholidys= 0;
		return( holi2 );
	}
	// June
	if ( Month == 06 )
	{
		if ( Day >= 15 && Day <= 21 )
		{
			if ( Dow == 0 )
			{
				holi2	= "Happy Father's Day";
				nholi	= 1;
			}
			else
			{
				x	= Day - 15;
				if ( x < Dow )
				{
					cholidys= 7 - Dow;
					holi2	= "Have a Happy Father's Day in " + cholidys + " Days";
					nholi	= 2;
				}
			}
		}
		else
		if ( Day < 15 )
		{
			xd	= Dow;
			xy	= Day;
			for ( x = Day + 1; x < 22; x++ )
			{
				xd++;
				if ( xd > 6 )	{ xd = 0; }
				if ( x >= 15 )
				{
					if ( xd == 0 )
					{
						cholidys= Day - xd;
						holi2	= "Have a Happy Father's Day in " + cholidys + " Days";
						x	= 23;
					}
				}
			}
		}
		return( holi2 );
	}
	// September
	if ( Month == 09 )
	{
		if ( Day < 8 )
		{
			if ( Dow == 1 )
			{
				holi2	= "Happy Memorial Day";
				nholi	= 3;
			}
			else
			{
				y	= Dow;
				z	= Day;
				for ( x = 0; z < 8 && y != 1; x++ )
				{
					y++;
					z++;
					if ( y > 6 )	{ y = 0; }
				}
				if ( z < 8 && y != Dow )
				{
					cholidys= x;
					holi2	= "Have a Happy Memorial Day in " + cholidys + " Days";
					nholi	= 4;
				}
			}
		}
		return( holi2 );
	}
	// October
	if ( Month == 10 )
	{
		if ( Day > 16 )
		{
			cholidys= 31 - Day;
			holi2	= "Happy Halloween";
			nholi	= 5;
		}
		return( holi2 );
	}
	// November
	if ( Month == 11 )
	{
		if ( Day <= 7 )
		{
			if ( Dow == 3 )
			{
				holi2	= "GO-GO Vote !!!";
				nholi	= 6;
			}
			else
			{
				cholidys= 0;
				for ( x = Dow; x != 3; x++ )	{ if ( x > 7 )	{ x = 1; } cholidys++; }
				holi2	= "GO-GO Vote on Tuesday !!!";
				nholi	= 7;
			}
		}
		else
		if ( Day > 21 && Day <= 28 )
		{
			if ( Dow == 5 )
			{
				holi2	= "Happy Turkey Day";
				nholi	= 8;
			}
			else
			{
				cholidys= 0;
				for ( x = Dow; x != 5; x++ )	{ if ( x > 7 )	{ x = 1; } cholidys++; }
				holi2	= "Have a Happy Turkey on Thursday";
				nholi	= 9;
			}
		}
		return( holi2 );
	}
	return( holi2 );
}
// ##############################################################
function Find_Season( Month, Day, Year ) {
	Month	= no2( Month );
	Day	= no2( Day );
	xkey	= Month + "" + Day;
	if ( xkey < "0321" )		{ seasm1 = "Wonderful";	seasm2 = "Winter";	}
	else if ( xkey < "0621" )	{ seasm1 = "Springy";	seasm2 = "Spring";	}
	else if ( xkey < "0921" )	{ seasm1 = "Sunny";	seasm2 = "Summer";	}
	else if ( xkey < "1221" )	{ seasm1 = "Awesome";	seasm2 = "Autumn";	}
	else				{ seasm1 = "Wonderful";	seasm2 = "Winter";	}
	seasm3	= "! " + Year + " / " + xkey + " !";
	seasmsg	= seasm1 + " " + seasm2 + " " + seasm3;
	return( seasmsg );
}
// ##############################################################

