//
// alerts_displayer.js
//
// displayer script that only shows entries in the alerts_list for today/tomorrow/happening soon if there are any to display
//
// (c) Paul Nicholson 2005
//
//
// establish how many events there are in the events_list for the loops
eventslistlength = alert_events.length
// document.write("array length = " + eventslistlength)

// date settings
when = new Date(alert_events[3][0])
now = new Date()
today = new Date(now.getTime())
tomorrow = new Date(now.getTime()+(24*60*60*1000))
soon2 = new Date(now.getTime()+(24*60*60*1000*2))
soon3 = new Date(now.getTime()+(24*60*60*1000*3))
soon4 = new Date(now.getTime()+(24*60*60*1000*4))
soon5 = new Date(now.getTime()+(24*60*60*1000*5))
soon6 = new Date(now.getTime()+(24*60*60*1000*6))
soon7 = new Date(now.getTime()+(24*60*60*1000*7))
soon8 = new Date(now.getTime()+(24*60*60*1000*8))
soon9 = new Date(now.getTime()+(24*60*60*1000*9))
soon10 = new Date(now.getTime()+(24*60*60*1000*10))
soon11 = new Date(now.getTime()+(24*60*60*1000*11))
soon12 = new Date(now.getTime()+(24*60*60*1000*12))
soon13 = new Date(now.getTime()+(24*60*60*1000*13))
soon14 = new Date(now.getTime()+(24*60*60*1000*14))
soon15 = new Date(now.getTime()+(24*60*60*1000*15))
soon16 = new Date(now.getTime()+(24*60*60*1000*16))
soon17 = new Date(now.getTime()+(24*60*60*1000*17))

// set up the formatting
var tableheader = "<table border=0 align=center>"
//<tr><td colspan=2><img src=images/msg_in_a_bottle.gif></td></tr>"
var todayrowstart = "<tr bgcolor=#ccffcc><td align=right><font size=2>Today: &nbsp; </font></td><td>"
var tomorrowrowstart = "<tr bgcolor=#ffffcc><td align=right><font size=2>Tomorrow: &nbsp; </font></td><td>"
var soonrowstart = "<tr bgcolor=#cccc99><td align=right><font size=2>Happening soon: &nbsp; </font></td><td>"
var rowend = "</font></td></tr>"
var tablefooter = "</table>"
var dash = "-"

//initialise the counters
var todaymatch = 0
var tomorrowmatch = 0
var soonmatch = 0

// loop to check for matches
for (j=0; j <= eventslistlength-1; j++)
{

dus = alert_events[j][0]
dud = new Date(dus)

if ((today.getDate() == dud.getDate()) && (today.getMonth() == dud.getMonth()) && (today.getYear() == dud.getYear()) )
{ todaymatch = todaymatch + 1 }

if ((tomorrow.getDate() == dud.getDate()) && (tomorrow.getMonth() == dud.getMonth()) && (tomorrow.getYear() == dud.getYear()) )
{ tomorrowmatch = tomorrowmatch + 1 }

if ((soon2.getDate() == dud.getDate()) && (soon2.getMonth() == dud.getMonth()) && (soon2.getYear() == dud.getYear()) )
{ soonmatch = soonmatch + 1 }
if ((soon3.getDate() == dud.getDate()) && (soon3.getMonth() == dud.getMonth()) && (soon3.getYear() == dud.getYear()) )
{ soonmatch = soonmatch + 1 }
if ((soon4.getDate() == dud.getDate()) && (soon4.getMonth() == dud.getMonth()) && (soon4.getYear() == dud.getYear()) )
{ soonmatch = soonmatch + 1 }
if ((soon5.getDate() == dud.getDate()) && (soon5.getMonth() == dud.getMonth()) && (soon5.getYear() == dud.getYear()) )
{ soonmatch = soonmatch + 1 }
if ((soon6.getDate() == dud.getDate()) && (soon6.getMonth() == dud.getMonth()) && (soon6.getYear() == dud.getYear()) )
{ soonmatch = soonmatch + 1 }
if ((soon7.getDate() == dud.getDate()) && (soon7.getMonth() == dud.getMonth()) && (soon7.getYear() == dud.getYear()) )
{ soonmatch = soonmatch + 1 }
if ((soon8.getDate() == dud.getDate()) && (soon8.getMonth() == dud.getMonth()) && (soon8.getYear() == dud.getYear()) )
{ soonmatch = soonmatch + 1 }
if ((soon9.getDate() == dud.getDate()) && (soon9.getMonth() == dud.getMonth()) && (soon9.getYear() == dud.getYear()) )
{ soonmatch = soonmatch + 1 }
if ((soon10.getDate() == dud.getDate()) && (soon10.getMonth() == dud.getMonth()) && (soon10.getYear() == dud.getYear()) )
{ soonmatch = soonmatch + 1 }
if ((soon11.getDate() == dud.getDate()) && (soon11.getMonth() == dud.getMonth()) && (soon11.getYear() == dud.getYear()) )
{ soonmatch = soonmatch + 1 }
if ((soon12.getDate() == dud.getDate()) && (soon12.getMonth() == dud.getMonth()) && (soon12.getYear() == dud.getYear()) )
{ soonmatch = soonmatch + 1 }
if ((soon13.getDate() == dud.getDate()) && (soon13.getMonth() == dud.getMonth()) && (soon13.getYear() == dud.getYear()) )
{ soonmatch = soonmatch + 1 }
if ((soon14.getDate() == dud.getDate()) && (soon14.getMonth() == dud.getMonth()) && (soon14.getYear() == dud.getYear()) )
{ soonmatch = soonmatch + 1 }
if ((soon15.getDate() == dud.getDate()) && (soon15.getMonth() == dud.getMonth()) && (soon15.getYear() == dud.getYear()) )
{ soonmatch = soonmatch + 1 }
if ((soon16.getDate() == dud.getDate()) && (soon16.getMonth() == dud.getMonth()) && (soon16.getYear() == dud.getYear()) )
{ soonmatch = soonmatch + 1 }
if ((soon17.getDate() == dud.getDate()) && (soon17.getMonth() == dud.getMonth()) && (soon17.getYear() == dud.getYear()) )
{ soonmatch = soonmatch + 1 }


}

// only put a table in if there are any matches

if (todaymatch > 0 || tomorrowmatch > 0 || soonmatch > 0)

{
document.write(tableheader)

// put a row in if there are matches today
if (todaymatch>0)
{
document.write(todayrowstart)

for (j = 0; j <= eventslistlength-1; j++)
{
dus = alert_events[j][0]
dud = new Date(dus)


if ((today.getDate() == dud.getDate()) && (today.getMonth() == dud.getMonth()) && (today.getYear() == dud.getYear()) )
{
document.write("<li><font size=2>" + alert_events[j][1] + "</font></li>")}
}

document.write(rowend)

}

//
// put a row in if there are matches tomorrow
if (tomorrowmatch>0)
{ document.write(tomorrowrowstart)

for (j = 0; j <= eventslistlength-1; j++)
{
dus = alert_events[j][0]
dud = new Date(dus)

if ((tomorrow.getDate() == dud.getDate()) && (tomorrow.getMonth() == dud.getMonth()) && (tomorrow.getYear() == dud.getYear()) )
{
document.write("<li><font size=2>" + alert_events[j][1] + "</font></li>")}

}

document.write(rowend)

}

//
//
// put a row in if there are matches soon
if (soonmatch>0)
{ document.write(soonrowstart)

for (j = 0; j <= eventslistlength-1; j++)
{
dus = alert_events[j][0]
dud = new Date(dus)

if ((soon2.getDate() == dud.getDate()) && (soon2.getMonth() == dud.getMonth()) && (soon2.getYear() == dud.getYear()) )
{
soon2Month = soon2.getMonth() + 1
document.write("<li><font size=2>" + soon2.getDate() + "/" +soon2Month + ": " + alert_events[j][1] + "</font></li>")}

if ((soon3.getDate() == dud.getDate()) && (soon3.getMonth() == dud.getMonth()) && (soon3.getYear() == dud.getYear()) )
{
soon3Month = soon3.getMonth() + 1
document.write("<li><font size=2>" + soon3.getDate() + "/" +soon3Month + ": " + alert_events[j][1] + "</font></li>")}

if ((soon4.getDate() == dud.getDate()) && (soon4.getMonth() == dud.getMonth()) && (soon4.getYear() == dud.getYear()) )
{
soon4Month = soon4.getMonth() + 1
document.write("<li><font size=2>" + soon4.getDate() + "/" +soon4Month + ": " + alert_events[j][1] + "</font></li>")}

if ((soon5.getDate() == dud.getDate()) && (soon5.getMonth() == dud.getMonth()) && (soon5.getYear() == dud.getYear()) )
{
soon5Month = soon5.getMonth() + 1
document.write("<li><font size=2>" + soon5.getDate() + "/" +soon5Month + ": " + alert_events[j][1] + "</font></li>")}

if ((soon6.getDate() == dud.getDate()) && (soon6.getMonth() == dud.getMonth()) && (soon6.getYear() == dud.getYear()) )
{
soon6Month = soon6.getMonth() + 1
document.write("<li><font size=2>" + soon6.getDate() + "/" +soon6Month + ": " + alert_events[j][1] + "</font></li>")}

if ((soon7.getDate() == dud.getDate()) && (soon7.getMonth() == dud.getMonth()) && (soon7.getYear() == dud.getYear()) )
{
soon7Month = soon7.getMonth() + 1
document.write("<li><font size=2>" + soon7.getDate() + "/" +soon7Month + ": " + alert_events[j][1] + "</font></li>")}

if ((soon8.getDate() == dud.getDate()) && (soon8.getMonth() == dud.getMonth()) && (soon8.getYear() == dud.getYear()) )
{
soon8Month = soon8.getMonth() + 1
document.write("<li><font size=2>" + soon8.getDate() + "/" +soon8Month + ": " + alert_events[j][1] + "</font></li>")}

if ((soon9.getDate() == dud.getDate()) && (soon9.getMonth() == dud.getMonth()) && (soon9.getYear() == dud.getYear()) )
{
soon9Month = soon9.getMonth() + 1
document.write("<li><font size=2>" + soon9.getDate() + "/" +soon9Month + ": " + alert_events[j][1] + "</font></li>")}

if ((soon10.getDate() == dud.getDate()) && (soon10.getMonth() == dud.getMonth()) && (soon10.getYear() == dud.getYear()) )
{
soon10Month = soon10.getMonth() + 1
document.write("<li><font size=2>" + soon10.getDate() + "/" +soon10Month + ": " + alert_events[j][1] + "</font></li>")}

if ((soon11.getDate() == dud.getDate()) && (soon11.getMonth() == dud.getMonth()) && (soon11.getYear() == dud.getYear()) )
{
soon11Month = soon11.getMonth() + 1
document.write("<li><font size=2>" + soon11.getDate() + "/" +soon11Month + ": " + alert_events[j][1] + "</font></li>")}

if ((soon12.getDate() == dud.getDate()) && (soon12.getMonth() == dud.getMonth()) && (soon12.getYear() == dud.getYear()) )
{
soon12Month = soon12.getMonth() + 1
document.write("<li><font size=2>" + soon12.getDate() + "/" +soon12Month + ": " + alert_events[j][1] + "</font></li>")}

if ((soon13.getDate() == dud.getDate()) && (soon13.getMonth() == dud.getMonth()) && (soon13.getYear() == dud.getYear()) )
{
soon13Month = soon13.getMonth() + 1
document.write("<li><font size=2>" + soon13.getDate() + "/" +soon13Month + ": " + alert_events[j][1] + "</font></li>")}

if ((soon14.getDate() == dud.getDate()) && (soon14.getMonth() == dud.getMonth()) && (soon14.getYear() == dud.getYear()) )
{
soon14Month = soon14.getMonth() + 1
document.write("<li><font size=2>" + soon14.getDate() + "/" +soon14Month + ": " + alert_events[j][1] + "</font></li>")}

if ((soon15.getDate() == dud.getDate()) && (soon15.getMonth() == dud.getMonth()) && (soon15.getYear() == dud.getYear()) )
{
soon15Month = soon15.getMonth() + 1
document.write("<li><font size=2>" + soon15.getDate() + "/" +soon15Month + ": " + alert_events[j][1] + "</font></li>")}

if ((soon16.getDate() == dud.getDate()) && (soon16.getMonth() == dud.getMonth()) && (soon16.getYear() == dud.getYear()) )
{
soon16Month = soon16.getMonth() + 1
document.write("<li><font size=2>" + soon16.getDate() + "/" +soon16Month + ": " + alert_events[j][1] + "</font></li>")}

if ((soon17.getDate() == dud.getDate()) && (soon17.getMonth() == dud.getMonth()) && (soon17.getYear() == dud.getYear()) )
{
soon17Month = soon17.getMonth() + 1
document.write("<li><font size=2>" + soon17.getDate() + "/" +soon17Month + ": " + alert_events[j][1] + "</font></li>")}



}

document.write(rowend)

}
//
document.write(tablefooter)

}



//
// *** END of JAVASCRIPT ***