// Event Calendar
// copyright Stephen Chapman, 10th June 2006, 30th October 2006

var tb = 't'; // top or bottom (t or b)
var headbg = '#12615680';  // table heading background colour
var todaybg = '#84c1c1'; // current selected date background colour
var textclr = '#000000'; // text colour
var linkclr = '#ff0000'; // link text colour
var noMessage =  'Bonne journée !'; // message to display when no entry in array

var dA = new Array(); var x = 0;
// first 8 characters in ccyymmdd format for single date events
// first 8 characters in 0000mmdd format for every year events
dA[x++] = "00000101 Bonne Année";
dA[x++] = "00000214 St-Valentin";
dA[x++] = "00001120 Invitation St-Jean";
dA[x++] = "00001121 Invitation St-Jean";
dA[x++] = "00001122 Invitation St-Jean";
dA[x++] = "00001128 Invitation Marieville";
dA[x++] = "00001204 Invitation Monique Ricard";
dA[x++] = "00001205 Invitation Monique Ricard";
dA[x++] = "00001207 Tests de Club";
dA[x++] = "00001211 Invitation Riviere-des-Prairies";
dA[x++] = "00001212 Invitation Riviere-des-Prairies";
dA[x++] = "00001213 Invitation Riviere-des-Prairies";
dA[x++] = "00001220 Fête de Noel pour tous";
dA[x++] = "00001221 16h30 à 18h00 Fête Semi-Privé et Junior 18h10 Intermédiaire et Sénior (amène un ami)";
dA[x++] = "00001223 Pas de Patin";
dA[x++] = "00001224 Pas de Patin";
dA[x++] = "00001227 P.P. 9.30 à 11.30 spécial famille du jour de l'an au sportium amène ton frère ta soeur et papa maman. ";
dA[x++] = "00001228 Pas de Patin";
dA[x++] = "00001230 Pas de Patin";
dA[x++] = "00001231 Pas de Patin";
dA[x++] = "00000108 Invitation Rosemère";
dA[x++] = "00000109 Invitation Rosemère";
dA[x++] = "00000110 Invitation Rosemère";
dA[x++] = "00000122 Finale Régionale";
dA[x++] = "00000123 Finale Régionale";
dA[x++] = "00000124 Finale Régionale, pas de patin au Sportium";
dA[x++] = "00000131 Pas de patin au Sportium";
dA[x++] = "00000205 Rencontre des Jeunes Étoiles";
dA[x++] = "00000206 Rencontre des Jeunes Étoiles";
dA[x++] = "00000207 Rencontre des Jeunes Étoiles";
dA[x++] = "00000214 St-Valentin porte un item rouge: foulard,tuque,mitaine...";
dA[x++] = "00000217 St-Valentin porte un item rouge: foulard,tuque,mitaine...";
dA[x++] = "00000219 Invitation Rive-Sud";
dA[x++] = "00000220 Invitation Rive-Sud";
dA[x++] = "00000221 Invitation Rive-Sud";
dA[x++] = "00000305 Jeux de la Participation";
dA[x++] = "00000306 Jeux de la Participation";
dA[x++] = "00000307 Jeux de la Participation";
dA[x++] = "00000311 Tests de Club";
dA[x++] = "00000408 Finale Provinciale STAR Michel Proulx";
dA[x++] = "00000409 Finale Provinciale STAR Michel Proulx";
dA[x++] = "00000410 Finale Provinciale STAR Michel Proulx";
// dA[x++] = "20060610 New Event Calendar Started today";

// permission is granted to use this javascript provided that the below code is not altered
var pageLoaded = 0; window.onload = function() {pageLoaded = 1;}
function loaded(i,f) {if (document.getElementById && document.getElementById(i) != null) f(); else if (!pageLoaded) setTimeout('loaded(\''+i+'\','+f+')',100);
}
function monthlength(month,year) {var dd = new Date(year, month, 0);return dd.getDate();}
var moy = ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'];var today = new Date();var selDate = today.getFullYear()+getmmdd(today.getMonth()+1,today.getDate());
function dispCal(yy,mm) {if (mm < 0 || mm > 12) {alert('month must be between 1 and 12'); return false;} if (yy != 0 && (yy < 1901 || yy > 2100)) {alert('year must be after 1900 and before 2101'); return false;} var dow = ['Dim','Lun','Mar','Mer','Jeu','Ven','Sam']; var calendar = new Date();  var today = calendar.getDate(); calendar.setDate(1); if (yy > 1900) calendar.setFullYear(yy); if (mm > 0) calendar.setMonth(mm - 1); var yy = year = calendar.getFullYear(); var month = calendar.getMonth(); calendar.setDate(today); var weekday = calendar.getDay(); var daysInMonth = monthlength(month+1,year); var hilite_start = '<td width="30" style="background:' + todaybg + '" align="center"><b>'; var td_start = '<td width="30" align="center">'; var cal = '<div id="cal"><div style="border:0pt solid #80;height:150px;width:180px"><table border="1" bgcolor="#cbe2d2" cellspacing="0" cellpadding="1" align="center"><tr><td colspan="7" style="background:' + headbg + '" align="center"><b>' + moy[month]  + ' ' + year + '<\/b><\/td><\/tr><tr>'; for(dex=0; dex < 7; dex++) {cal += td_start + dow[dex] + '</td>';} cal += '<\/tr><tr>'; var day2 = today; for (dex = today; dex > 6; dex -=7) day2 = dex; weekday -= day2 - 1; while (weekday < 0) weekday += 7; for(dex=0; dex < weekday; dex++) cal += td_start + ' <\/td>'; for(dex=1; dex <= daysInMonth; dex++) {if(weekday == 7) {cal += '</tr><tr>'; weekday = 0;} if(selDate==year+getmmdd(month+1,dex)) cal += hilite_start +'<span '+clickDate(dex,month,year) + '>'+ dex + '<\/span><\/b><\/td>'; else cal += td_start + '<span '+clickDate(dex,month,year) + '>' + dex + '<\/span><\/td>'; weekday += 1;} for(dex=weekday; dex < 7; dex++) cal += td_start + ' <\/td>'; cal += '<\/tr><\/table><\/div>';if (document.getElementById) {var mmb = month;  mm = month + 1; var yya = yyb = yy; if (mmb <1) {mmb += 12; yyb--;} var mma = month + 2; if (mma > 12) {mma -= 12; yya++;} var yb = yy -1; var ya = yy +1; cal += '<table border="0" cellspacing="0" cellpadding="2" width="180"><tr><td><a href="#" onclick="if (cala = dispCal('+yb+','+mm+')) {document.getElementById(\'cal\').innerHTML = cala; return false;}"><<</a></td><td><a href="#" onclick="if (cala = dispCal('+yyb+','+mmb+')) {document.getElementById(\'cal\').innerHTML = cala; return false;}"><</a></td><td align="right"><a href="#" onclick="if (cala = dispCal('+yya+','+mma+')) {document.getElementById(\'cal\').innerHTML = cala; return false;}">></a></td><td align="right"><a href="#" onclick="if (cala = dispCal('+ya+','+mm+')) {document.getElementById(\'cal\').innerHTML = cala; return false;}">>></a></td></tr></table>';} else {cal += '<div> </div>';} cal += '</div>'; return cal;}
function start() {var x = '<div id="calDate" style="border:0pt solid #80;width:180px"><\/div>'; var y = ''; if (tb == 't') y = x + dispCal(0,0); else y = dispCal(0,0) + x; document.getElementById('calendar').innerHTML = y; ev();}
loaded('calendar',start);
function clickDate(day, month, year) {var ct = nextDate(year + getmmdd(month+1,day));if (ct == '') ct = nextDate('0000' + getmmdd(month+1,day));if (ct == '') return 'style="color:'+textclr+'"'; else return 'style="cursor:pointer;color:'+linkclr+'" onclick="selDate = '+year+ getmmdd(month+1,day)+'; isDate(' + day + ',' + month + ',' + year + ');return false;"';}function isDate(dayVal,monthVal,yearVal) {var ct = nextDate(yearVal + getmmdd(monthVal+1,dayVal));if (ct == '') ct = nextDate('0000' + getmmdd(monthVal+1,dayVal));if (ct == '') ct = noMessage;document.getElementById('calDate').innerHTML = selDate + ':<br \/>' +ct; return false;}function nextDate(yymmdd) {var x = dA.length;for (var i = 0; i < x; i++) {if (dA[i].substr(0,8) == yymmdd) return dA[i].substr(8);}return '';}function getmmdd(mm,dd) {return (mm > 9 ? '' + mm : '0' + mm) + (dd > 9 ? dd : '0' + dd);}
function ev() {var ct = nextDate(selDate);var ct = nextDate(selDate);if (ct == '') ct = nextDate('0000' + selDate.substr(4));if (ct == '') ct = noMessage; document.getElementById('calDate').innerHTML = selDate + ':<br \/> ' +ct;}