/* Tickler.js
This is the file that provides seasonal messages to several screens based on message date.
Revised 1/22/98 to allow multiple events on the same day.  Revised test for multiple 11/11/99.*/
<!--
function print() {
	 document.write("Big Date: " + this.bdate
	  + "<br>gt1a: " + this.gt1a
	  + "<br>gt1b: " + this.gt1b
	  + "<br>eve: " + this.eve
	  + "<br>eqday: " + this.eqday + "<p>");
	}

function printa() {
	var message="<P align=center><font color=brown size=5>"+else_msg
	if (daysLeft >1){ message= "<p align=center><B>"+this.gt1a+daysLeft+this.gt1b+" on " +showdate(this.bdate) +"</B>"}
	if (daysLeft==1){message = "<p align=center>"+this.eve+"</B>"}
	if (daysLeft==0){message = "<p align=center>"+this.eqday+"</B>"}
	document.write(message);
	}

function printb() {
	var message="<P align=center><font color=brown size=5>"+else_msg
	if (daysLeftNext >1){ message= "<B>"+this.gt1a+daysLeftNext+this.gt1b+" on " +showdate(this.bdate) +"</B>"}
	if (daysLeftNext==1){message = this.eve+ " on " +  showdate(this.bdate) +"</B>"}
	if (daysLeftNext==0){message = this.eqday+"</B>"}
	document.write(message);
	}

function event(bdate,gt1a,gt1b,eve,eqday) { 
	this.bdate = new Date(bdate);
 	this.gt1a = gt1a;
 	this.gt1b = gt1b;
	this.eve = eve;
	this.eqday = eqday;
 	this.print = print;
	this.printa = printa;
	this.printb = printb;
	}

function showdate(mydate) {
	thedate = mydate.getMonth()+1;
	thedate = thedate + "/" + mydate.getDate()+"/"+mydate.getFullYear();
	return thedate;
	}


//Construct a date variable for 0000 hours today
		var now= new Date();		// Current date & time
		var year = now.getYear()
		if(year < 1900)
		{
			year = year + 1900;
		}
		var month = now.getMonth()
		var day = now.getDate()
		var today= new Date(year,month,day)

// set dotest to 1 to substitute the testdate for today. set to 0 for normal operation
var testdate=new Date("9/25/2003");
var dotest= 0;
if(dotest==1){today = testdate;}

// Event data entry starts below
//Do not overwrite last event.  It is my stopper.
// If you add rather than change events, adjust the num_events value below
//Recommend that first ten event numbers be reserved for one-shot events
//Recommend that Events 10 thru -? be repeating yearly events

var num_events = 50;

// Go for it
//insert below here
var library = new Object();
library[0] = new event(
	"1/29/2003",
	"Next  ",
	" days at the Colossal Week of Rounds at St Petersburg FL. with Goss, Rumble and Worlock",
	"Tomorrow is the last day at the Colossal Week of Rounds at St Petersburg FL. with Goss, Rumble and Worlock",
	"Colossal Week of Rounds at St Petersburg FL. with Goss, Rumble and Worlock ends today. "
	);
library[1] = new event(
	"10/3/2003",
	"You have ",
	" days until the Show Me Festival - Phase IV-V-VI - Capital Ritz Ballroom - Jefferson City, Missouri",
	"Tomorrow is the Show Me Festival - Phase IV-V-VI - Capital Ritz Ballroom - Jefferson City, Missouri",
	"Today is the last day of the Show Me Festival - Phase IV-V-VI - Capital Ritz Ballroom - Jefferson City, Missouri"
	);
library[2] = new event(
	"10/10/2003",
	"You have ",
	" days until A Formal Affair - Phase IV-V-VI - Memorial Hall - Willows, California",
	"Tomorrow is the first day of A Formal Affair - Phase IV-V-VI - Memorial Hall - Willows, California",
	"Today is the first day of A Formal Affair - Phase IV-V-VI - Memorial Hall - Willows, California"
	);
library[3] = new event(
	"11/7/2003",
	"You have ",
	" days until the Georgia Round Dance Clinic - Phase III-IV - Blairsville, Georgia",
	"Tomorrow is the first day of the Georgia Round Dance Clinic - Phase III-IV - Blairsville, Georgia",
	"Today is the first day of the Georgia Round Dance Clinic - Phase III-IV - Blairsville, Georgia"
	);
library[4] = new event(
	"11/15/2003",
	"You have ",
	" days until the NEFSARDA Fall Festival - Phase II-III - Christ The King Church - Jacksonville, Florida",
	"Tomorrow is the first day of the NEFSARDA Fall Festival - Phase II-III - Christ The King Church - Jacksonville, Florida",
	"Today is the first day of NEFSARDA Fall Festival - Phase II-III - Christ The King Church - Jacksonville, Florida"
	);
library[5] = new event(
	"3/26/2004",
	"The San Diego Round Dance Festival (Mar 26-28) starts in  ",
	" days",
	"The San Diego Round Dance Festival starts tomorrow.",
	"The San Diego Round Dance Festival starts today."
	);
library[6] = new event(
	"7/9/2004",
	"Montreal C'est Magnifique (7/9-7/11)- Phase IV-V-VI starts in",
	" days @ St. Nikolas Church Hall - Montreal Canada",
	"Montreal C'est Magnifique starts tomorrow.",
	"Montreal C'est Magnifique starts today."
	);
library[7] = new event(
	"9/17/2004",
	"You have ",
	" days until the Del Val Convention (9/17-9/18) - Phase III - VI.<br>Cherry Hill Hilton - Cherry Hill, New Jersey.",
	"The Del Val Convention starts tomorrow.",
	" The Del Val Convention starts today."
	);

library[8] = new event( 
	"9/23/2004",
	"You have ",
	" days until the Myrtle Beach Ball (9/23 - 9/25) - Phase II - V<br>Convention Center - Myrtle Beach, South Carolina",
	"The Myrtle Beach Ball starts tomorrow.",
	"The Myrtle Beach Ball starts today."
	);
library[9] = new event(
	"10/08/2004",
	"You have ",
	" days until the Fall Workshop (10/8-10/9) Phase IV-VI w/ Lillefields.<br>Honeywell Center - Wabash, Indiana ",
	"The Fall Workshop  in Wabash, Indiana starts tomorrow.</A>",
	"The Fall Workshop  in Wabash, Indiana starts today."
	);
library[10] = new event(
	"10/22/2004",
	"Fiesta w/Esqueda's  (10/22 - 10/24)- Phase IV-V-VI - Valle Del Oro RV Resort - Mesa, Arizona starts in ",
	"  days ",
	"Fiesta w/Esqueda's - Phase IV-V-VI - Valle Del Oro RV Resort - Mesa, Arizona starts tomorrow.",
	"Fiesta w/Esqueda's - Phase IV-V-VI - Valle Del Oro RV Resort - Mesa, Arizona starts today."
	);
library[11] = new event(
	"11/26/2004",
	"You have ",
	" days until the Harvest Holiday Festival (11/26 - 11/28) - Phase IV-V-VI<br>Ramada Inn Market Center - Dallas, Texas.",
	"The Harvest Holiday Festival (11/26 - 11/28)  - Dallas, Texas - starts tomorrow.",
	"The Harvest Holiday Festival (11/26 - 11/28)  - Dallas, Texas - starts today "
	);
library[12] = new event(
	"3/17/2005",
	"The WASCA Festival - Phase III-VI w/Collipi & Rumble - Hyatt Regency - Reston, Virginia starts in ",
	" days ",
	"The WASCA Festival - Phase III-VI w/Collipi & Rumble - Hyatt Regency - Reston, Virginia starts tomorrow.",
	" The WWASCA Festival - Phase III-VI w/Collipi & Rumble - Hyatt Regency - Reston, Virginia starts today."
	);
library[13] = new event(
	"3/24/2005",
	"Europe Festival - Week of Rounds - Phase V-VI - Cham, Germany (March 24 - April 3) starts in  ",
	" days .",
	"The Europe Festival - Week of Rounds - Phase V-VI - Cham, Germany starts tomorrow.",
	"The Europe Festival - Week of Rounds - Phase V-VI - Cham, Germany starts tonight."
	);
library[14] = new event(
	"4/29/2005",
	"Weekend of Rounds - Phase IV-V - Boalsburg Fire Hall - Boalsburg, Pennsylvania (April 29 - May 1) starts in ",
	" days",
	"The Weekend of Rounds starts tomorrow.",
	"The Weekend of Rounds starts today."
	);
library[15] = new event(
	"8/19/2005",
	"You have ",
	" days until Colossal Week (8/19-8/24)- Phase IV-VI - w/Goss & Vogt - East LV Senior Center - Las Vegas, Nevada ",
	"Colossal Week in Las Vegas starts tomorrow.",
	"Colossal Week in Las Vegas starts today."
	);
library[16] = new event(
	"10/21/2005",
	"You have ",
	" days to Fiesta w/Esqueda's (10/21 - 10/23) - Phase IV-V-VI.<br>Valle Del Oro RV Resort - Mesa, Arizona",
	"Fiesta w/Esqueda's starts tomorrow.",
	"Fiesta w/Esqueda's starts today."
	);
library[17] = new event(
	"11/02/2006",
	"Autumn Fest - Phase IV=VI - ViewPoint RV & Golf Resort - Mesa, Az starts in  ",
	" days",
	"Autumn Fest  - Mesa, Az starts tomorrow.",
	"Autumn Fest  - Mesa, Az starts tomorrow starts tonight."
	);
library[18] = new event(
	"1/21/2006",
	"You have ",
	" days until the start of the Colossal Week (1/21 - 1/26) - Phase IV-V-VI - w/Goss & Rumble's - Coliseum - St. Petersburg, Florida",
	"Tomorrow is  the start of the Colossal Week - Phase IV-V-VI - w/Goss & Rumble's - Coliseum - St. Petersburg, Florida",
	"Today is the start of the Colossal Week - Phase IV-V-VI - w/Goss & Rumble's - Coliseum - St. Petersburg, Florida"
	);
library[19] = new event(
	"2/4/2006",
	"You have ",
     " days until Super Saturday - Phase V-VI - Stardust Dance Center - Plant City, Florida",
	"Tomorrow is Super Saturday - Phase V-VI - Stardust Dance Center - Plant City, Florida",
	"Today is Super Saturday - Phase V-VI - Stardust Dance Center - Plant City, Florida"
	);
library[20] = new event(
	"5/11/2006",
	"T & D Convention - Phase III-V - Brock University - St. Catherines, Ontario Canada (May 11-13) starts in ",
	" days",
	"T & D Convention - Phase III-V - Brock University - St. Catherines, Ontario Canada (May 11-13) starts tomorrow.",
	"T & D Convention - Phase III-V - Brock University - St. Catherines, Ontario Canada (May 11-13) starts today."
	);
library[21] = new event(
	"5/20/2006",
	"Heartland Classic - Phase IV-V-VI - Muskogee Dance Hall - Muskogee, Oklahome (May 20-21) starts in  ",
	" days",
	"Heartland Classic - Phase IV-V-VI - Muskogee Dance Hall - Muskogee, Oklahome (May 20-21) starts tomorrow.</A>",
	"Heartland Classic - Phase IV-V-VI - Muskogee Dance Hall - Muskogee, Oklahome (May 20-21) starts today."
	);
library[22] = new event(
	"8/11/2006",
	"You have ",
	" days until the R/D Clinic - Indiana Callers Association - Phase IV - V<br>Exhibitiob Center - Noblesville, Indiana",
	"Tomorrow is the R/D Clinic - Indiana Callers Association",
	"Today is the R/D Clinic - Indiana Callers Association"
	);
library[23] = new event(
	"9/8/2006",
	"You have ",
	" days until the State Round Dance Festival - Phase IV-V-VI - Dance Center - Albuquerque, New Mexico.  Official Dance starts ",
	"The State Round Dance Festival - Phase IV-V-VI - Dance Center - Albuquerque, New Mexico starts tomorrow.",
	"Today is the start of the State Round Dance Festival - Phase IV-V-VI - Dance Center - Albuquerque, New Mexico"
	);
library[24] = new event(
	"9/11/2006",
	"You have ",
	" days until Curt leaves for the 15th Anniversary Party - Round Dance Clinic W/E Phase V-VI<br>Hiroshima, Japan",
	"Tomorrow Curt leaves for the 15th Anniversary Party - Round Dance Clinic W/E Phase V-VI<br>Hiroshima, Japan ",
	"Today Curt leaves for the 15th Anniversary Party - Round Dance Clinic W/E Phase V-VI<br>Hiroshima, Japan "
	);
library[25] = new event(
	"09/20/2006",
	"You have ",
	" days until the Beach Ball - Phase II-V - Sands Hotel - Myrtle Beach, South Carolina ",
	"The Beach Ball - Phase II-V - Sands Hotel - Myrtle Beach, South Carolina starts tomorrow.",
	"The Beach Ball - Phase II-V - Sands Hotel - Myrtle Beach, South Carolina starts today."
	);
library[26] = new event(
	"10/06/2006",
	"You have ",
	" days until the Centex Festival - Phase III/IV/V - Burnet Middle School -  Burnet, Texas",
	"It's Christmas Eve",
	"Merry Christmas"
	);
library[27] = new event(
	"10/19/2006",
	"You have ",
	" days until the Red River Rounders Halloween Ball - Phase IV-V-VI - Civic Center - Shreveport/Bossier City, Louisiana",
	"Tomorrow is the first day of the Red River Rounders Halloween Ball - Phase IV-V-VI - Civic Center - Bossier City, Louisiana",
	"Today is the first day of the Red River Rounders Halloween Ball - Phase IV-V-VI - Civic Center - Bossier City, Louisiana"
	);
library[28] = new event(
	"11/18/2006",
	"You have ",
	" days until Super Saturday - Phase V-VI - Stardust Dance Center - Plant City, Florida.",
	"Tomorrow is Super Saturday in Plant City",
	"Today is Super Saturday in Plant City"
	);
library[29] = new event(
	"12/2/2006",
	"You have ",
	" days until the Dec 2nd & 3rd Florida Round Dance Council Phase IV-V Clinic Weekend - Stardust Dance Center - Plant City, Florida",
	"Tomorrow is the Dec 2nd & 3rd Florida Round Dance Council Phase IV-V Clinic Weekend - Stardust Dance Center - Plant City, Florida",
	"Today is the first day of the Dec 2nd & 3rd Florida Round Dance Council Phase IV-V Clinic Weekend - Stardust Dance Center - Plant City, Florida"
	);
library[30] = new event(
	"12/9/2006",
	"You have ",
	" days until the Christmas Party & Super Saturday - Phase IV-V-VI - Stardust Dance Center - Plant City, Florida",
	"Tomorrow is the Christmas Party & Super Saturday - Phase IV-V-VI - Stardust Dance Center - Plant City, Florida",
	"Today is the Christmas Party & Super Saturday - Phase IV-V-VI - Stardust Dance Center - Plant City, Florida"
	);
library[31] = new event(
	"12/30/2006",
	"You have ",
	" days until the New Year's W/E w/Shibata's (12/30 - 1/1) - Phase IV-VI - Stardust Dance Center - Plant City, Florida",
	"Tomorrow is the first day of the New Year's W/E w/Shibata's - Phase IV-VI - Stardust Dance Center - Plant City, Florida",
	"Today is the first day of the New Year's W/E w/Shibata's - Phase IV-VI - Stardust Dance Center - Plant City, Florida"
	);
library[32] = new event(
	"1/1/2007",
	"You have run out of events in your list.  By the way, there are ",
	" days until the year 2006.",
	"Its New Years Eve",
	"Happy New Year"
	);
library[33] = new event(
	"1/13/2007",
	"A 'Black Tie' Affair  -  Phase IV - VI - Tower Point Resort - Mesa, Arizona starts in ",
	" days.   ",
	"A 'Black Tie' Affair  -  Phase IV - VI - Tower Point Resort - Mesa, Arizona starts tomorrow night.",
	"A 'Black Tie' Affair  -  Phase IV - VI - Tower Point Resort - Mesa, Arizona starts tonight."
	);
library[34] = new event(
	"1/20/2007",
	"You have ",
	" days until the Colossal Week of Rounds at St Petersburg FL. with Goss, Rumble and Worlock",
	"Tomorrow is the Colossal Week of Rounds at St Petersburg FL. with Goss, Rumble and Worlock",
	"Colossal Week of Rounds at St Petersburg FL. with Goss, Rumble and Worlock starts today. "
	);
library[35] = new event(
	"2/3/2007",
	"Super Saturday - Phase V-VI  - Stardust Dance Center - Plant City, Florida in  ",
	 "days",
	"Super Saturday, Stardust Dance Center - Plant City, Florida tomorrow night",
	"Super Saturday Stardust Dance Center - Plant City, Florida tonight."
	);
library[36] = new event(
	"2/17/2007",
	"You have ",
      " days until the Fabulous Four Weekend - Phase IV-VI - w/Moore & Read - Stardust Dance Center - Plant City, FL",
	"Tomorrow is the first day of the Fabulous Four Weekend - Phase IV-VI - w/Moore & Read - Stardust Dance Center - Plant City, FL",
	"Today is the first day of the Fabulous Four Weekend - Phase IV-VI - w/Moore & Read - Stardust Dance Center - Plant City, FL"
	);
library[37] = new event(
	"2/24/2007",
	"The Carolina Jubilee of Rounds - 2/24-2/25 - (Phase IV-V-VI in West Columbia, SC) starts in  ",
	" days ",
	"The Carolina Jubilee of Rounds starts tomorrow.",
	"The Carolina Jubilee of Rounds starts today."
	);
library[38] = new event(
	"8/31/2007",
	"In ",
     " days we depart for 15 days exploring Britain, Ireland, Scotland and Wales ",
	"Tomorrow we depart for 15 days exploring Britain, Ireland, Scotland and Wales",
	"Today we depart for 15 days exploring Britain, Ireland, Scotland and Wales"
	);
library[39] = new event(
	"12/6/2007",
	"In ",
	" days we depart for 7 days exploring Canada's Winter Wonderland ",
	"7 days exploring Canada's Winter Wonderland starts tomorrow .",
	"7 days exploring Canada's Winter Wonderland starts today."
	);
library[40] = new event(
	"3/26/2008",
	"In ",
     "  days we depart for 15 days exploring The Plains of Africa - Kenya Wildlife Safari ",
	"Tomorrow we depart for 15 days exploring The Plains of Africa - Kenya Wildlife Safari",
	"Today we depart for 15 days exploring The Plains of Africa - Kenya Wildlife Safari"
	);
library[41] = new event(
	"4/6/2007",
	"You have ",
	" days until the European week of Rounds (April 6-22) Cham, Germany.<br>Phase III-IV-V-IV w/Robinson. Dance starts ",
	"The European week of Rounds starts tomorrow.</A>",
	" The European week of Rounds starts today."
	);
library[42] = new event(
	"4/27/2007",
	"You have ",
	" days until the Texas Cotillion - (April 27-29) - Phase IV-V-VI <br> Dance Federation Building - Lubbock, Texas starting ",
	"Tomorrow is the start of the Texas Cotillion ",
	"Today you should be in Lubbock Texas for the start of the Texas Cotillion"
	);
library[43] = new event(
	"5/20/2007",
	"You have ",
	" days until Spring Week of Rounds - Phase III-VI w/Kincaid, Blackford & Rumble - Fontana Village, North Carolina ",
	"Tomorrow is the first day of the Spring Week of Rounds - Phase III-VI w/Kincaid, Blackford & Rumble- Fontana Village, North Carolina",
	"Today is the first day of the Spring Week of Rounds - Phase III-VI w/Kincaid, Blackford & Rumble - Fontana Village, North Carolina"
	);
library[44] = new event(
	"6/1/2007",
	"You have ",
	" days until the Western Ontario W/E (June 1-3) Phase III-V <br>John Paul Secondary School - London, Ontario Canada",
	"Tomorrow is the first day of the Western Ontario W/E ",
	"Today is the first day of the Western Ontario W/E"
	);
library[45] = new event(
	"4/23/2000",
	"Cherry Hill W/E with Rumble and Goss - Cherry Hill Campgrounds - College Park, Maryland (April 23-25) starts in ",
	" days.",
	"Cherry Hill Weekend starts tomorrow. ",
	"Cherry Hill Weekend starts today."
	);
library[46] = new event(
	"10/22/2000",
	"Cherry Hill W/E with Rumble and Read - Cherry Hill Campgrounds - College Park, Maryland (October 22-24) starts in ",
	" days.",
	"Cherry Hill Weekend starts tomorrow. ",
	"Cherry Hill Weekend starts today."
	);
library[47] = new event(
	"7/20/2007",
	"Pre-URDC W/E - July 20 - 22 - Phase III-IV-V-VI - Joplin Memorial Hall -  Joplin, Misouri starts in ",
	" days.",
	"Pre-URDC W/E - Phase III-IV-V-VI - Joplin Memorial Hall -  Joplin, Misouri starts tomorrow.",
	"Pre-URDC W/E - Phase III-IV-V-VI - Joplin Memorial Hall -  Joplin, Misouri starts today."
	);
library[48] = new event(
	"7/25/2001",
	"You have ",
	" days to the 31st URDC Convention - July 25-28 - Phase IV-V-VI - John Q. Hammond Center- Joplin, Misouri ",
	"URDC Convention (7/25 - 7/28) starts tomorrow",
	"URDC Convention 7/25 - 7/28 starts today"
	);
library[49] = new event(
	"8/4/2000",
	"You have ",
	" days until the start of the Roundarama Institute - Phase IV-VI w/Rumble & Moore - Purdue University -W.Lafayette, Indiana ",
	"The Roundarama Institute starts tomorrow.",
	"The Roundarama Institute starts today. "
	);
library[99] = new event(
	"1/1/2011",
	"You have run out of events in your list.  By the way, there are ",
	" days until the year 2011.",
	"Its New Years Eve",
	"Happy New Year"
	);

//Insert above here
library.length = 6;

varholder = 99
for (var eventNum = 0; eventNum <num_events; ++eventNum) {
	if(varholder==99 && library[eventNum].bdate.getTime() - today.getTime() >= 0){
		varholder=eventNum;}
	if(varholder < 99 && library[eventNum].bdate - library[varholder].bdate < 0 && 		library[eventNum].bdate.getTime() - today.getTime() >= 0){
		varholder=eventNum;}
//	document.write(eventNum +", " + varholder +"<br>");
	}

varholdernext = 99
for (var eventNum = 0; eventNum <num_events; ++eventNum) {
	if(varholdernext==99 && library[eventNum].bdate.getTime() - library[varholder].bdate.getTime() >= 0.5){
		varholdernext=eventNum;}
	if(varholdernext < 99 && library[eventNum].bdate - library[varholder].bdate > 0.5 && 		library[varholdernext].bdate.getTime() - library[eventNum].bdate.getTime() > 0.5){
		varholdernext=eventNum;}
//	document.write(eventNum +", " + varholdernext +", " + varholder + "<br>");
	}


var else_msg="Uhhh...something!"
for (var eventNum = 0; eventNum <num_events; ++eventNum) {

	// equality test below did not work for unknown reasons. Switched to abs( delta ) test.
	// if(library[eventNum].bdate == library[varholder].bdate) {

	if(Math.abs(library[varholder].bdate - library[eventNum].bdate)<2) {
		//Create constant to represent the number of milliseconds per day
		msPerDay = 24 * 60 * 60 * 1000 ; 

		//Subtract today from targetdate
		//Difference will be in milliseconds so we divide by milliseconds per day 
		daysLeft = Math.round((library[varholder].bdate.getTime() - today.getTime()) / msPerDay);
		//daysLeftNext = Math.round((library[varholdernext].bdate.getTime() - today.getTime()) / msPerDay);
		//document.write(eventNum);
		library[eventNum].printa();
	}
}
document.write("<hr>");
for (var eventNum = 0; eventNum <num_events; ++eventNum) {

	if(Math.abs(library[varholdernext].bdate - library[eventNum].bdate)<2) {
		//Create constant to represent the number of milliseconds per day
		msPerDay = 24 * 60 * 60 * 1000 ; 

		//Subtract today from targetdate
		//Difference will be in milliseconds so we divide by milliseconds per day 
		daysLeftNext = Math.round((library[varholdernext].bdate.getTime() - today.getTime()) / msPerDay);
		library[eventNum].printb();
	}
}
//document.write("<hr>");

// -->

