<!--// NOTES
//
// two dimensional arrays are used here to create a data table of months and important dates and messages
// array numbering is 0 to 11 to represent numbers 1 to 12 as per ECMA standard
// actual date numbers in KeyDate[month number] arrays are still quoted as '1' through '31'
// eg; info[0] is first instance of 'info' array: info[0][0] is first instance of 'info[0]' array - corresponds to january, first date & first message.
// script creates top level of 3 x 12 arrays of important dates in 12 month period
// sub-items to correspond to date sequence in KeyDate array
// months start with 'info[0]' -  end 'info[11]' - case sensitive
// day (KeyDate) items start 'info[month number][0]' - for as many items as there are key dates in month
// eg third item of fourth month would be 'info[3][2]'
//
// EXAMPLE:
// example of 'live' code is contained between '/*' and '*/' comment blocks
// state the month and year as a comment for clarity
// JANUARY 2001
// eg; two keydates for month # 0, (january), 1st and 12th days
/*
    KeyDate[0] = new Array("1","12"); //  <--<< LIST IMPORTANT CALENDAR DATES  <--<<
*/
// JANUARY 2001
// eg; message and hyperlink for item one, 1st of month, & item two, 12th of month
/*
    info[0] = new Array(); infolink[0] = new Array(); //  <--<< PROVIDE [ BRIEF! ] MESSAGE & LINK FOR EACH DATE <--<<
    info[0][0] = "Happy new year!"; infolink[0][0] = "/calendar#1";
    info[0][1] = "Is the party over?"; infolink[0][1] = "/calendar#2";
*/
// if there were three dates in month, next in sequence would be info[0][3]...
//
//- DATA DECLARATION - [ STATIC ]
//
// define 'KeyDate' and 'info' and 'infolink' array containers
// 3 x 12 item top-level arrays of important dates in 12 month period
  var KeyDate = new Array(12);
  var info = new Array(12);
  var infolink = new Array(12);
//
// DATA STORE - [ EDITABLE ]
//
// JANUARY 2002
 KeyDate[0] = new Array("17","18","19","23","24","25","26","27","28"); // month # is 0
 info[0] = new Array(); infolink[0] = new Array();
 info[0][0] = "Away at Euro Disney"; infolink[0][0] = "availability.html";
 info[0][1] = "Away at Euro Disney"; infolink[0][1] = "availability.html";
 info[0][2] = "Away at Euro Disney"; infolink[0][2] = "availability.html";
 info[0][3] = "In UK on business"; infolink[0][3] = "availability.html";
info[0][4] = "In UK on business"; infolink[0][4] = "availability.html";
info[0][5] = "In UK on business"; infolink[0][5] = "availability.html";
info[0][6] = "In UK on business"; infolink[0][6] = "availability.html";
info[0][7] = "In UK on business"; infolink[0][7] = "availability.html";
info[0][8] = "In UK on business"; infolink[0][8] = "availability.html";
//
//
// FEBRUARY 2002
 KeyDate[1] = new Array("19","20","21","22","23","24"); // month # is 1
 info[1] = new Array(); infolink[1] = new Array();
 info[1][0] = "In UK on business"; infolink[1][0] = "availability.html";
info[1][1] = "In UK on business"; infolink[1][1] = "availability.html";
info[1][2] = "In UK on business"; infolink[1][2] = "availability.html";
info[1][3] = "In UK on business"; infolink[1][3] = "availability.html";
info[1][4] = "In UK on business"; infolink[1][4] = "availability.html";
info[1][5] = "In UK on business"; infolink[1][5] = "availability.html";
//
// MARCH 2002
 KeyDate[2] = new Array("2","12","13","14","17","18","19","20","21","24","25","26","27","28","29","30","31"); // month # is 2
 info[2] = new Array(); infolink[2] = new Array();
 info[2][0] = "My Birthday"; infolink[2][0] = "availability.html";
 info[2][1] = "Working for elata"; infolink[2][1] = "availability.html";
 info[2][2] = "Working for elata"; infolink[2][2] = "availability.html";
 info[2][3] = "Working for elata"; infolink[2][3] = "availability.html";
 info[2][4] = "Working for elata"; infolink[2][4] = "availability.html";
 info[2][5] = "Working for elata"; infolink[2][5] = "availability.html";
 info[2][6] = "Working for elata"; infolink[2][6] = "availability.html";
 info[2][7] = "Working for elata"; infolink[2][7] = "availability.html";
 info[2][8] = "Working for elata"; infolink[2][8] = "availability.html";
 info[2][9] = "Working for elata"; infolink[2][9] = "availability.html";
 info[2][10] = "Working for elata"; infolink[2][10] = "availability.html";
 info[2][11] = "Fly to UK"; infolink[2][11] = "availability.html";
 info[2][12] = "Business in UK"; infolink[2][12] = "availability.html";
 info[2][13] = "Return to France by ferry"; infolink[2][13] = "availability.html";
 info[2][14] = "Move house in Nantes"; infolink[2][14] = "availability.html";
 info[2][15] = "Return to UK by ferry"; infolink[2][15] = "availability.html";
 info[2][16] = "Return to France by plane"; infolink[2][15] = "availability.html";
//
//
// APRIL 2002
 KeyDate[3] = new Array(""); // month # is 3
 info[3] = new Array(); infolink[3] = new Array();
//
// MAY 2002
 KeyDate[4] = new Array(""); // month # is 4
// MAY 2002
 info[4] = new Array(); infolink[4] = new Array();
//
// JUNE 2002
 KeyDate[5] = new Array(""); // month # is 5
// JUNE 2002
  info[5] = new Array(); infolink[5] = new Array();
//
// JULY 2002
 KeyDate[6] = new Array(""); // month # is 6
// JULY 2002
  info[6] = new Array(); infolink[6] = new Array();
//
// AUG 2002
 KeyDate[7] = new Array(""); // month # is 7
// AUG 2002
  info[7] = new Array(); infolink[7] = new Array();
//
// SEPT 2002
 KeyDate[8] = new Array(""); // month # is 8
  info[8] = new Array(); infolink[8] = new Array();
//
// OCT 2002
 KeyDate[9] = new Array(""); // month # is 9
// OCT 2002
  info[9] = new Array(); infolink[9] = new Array();
//
// NOV 2002
 KeyDate[10] = new Array(""); // month # is 10
// NOV 2001
info[10] = new Array(); infolink[10] = new Array();
//
//
// DEC 2002
 KeyDate[11] = new Array("24","25","26"); // month # is 11
 info[11] = new Array(); infolink[11] = new Array();
 info[11][0] = "On vacation for Christmas"; infolink[11][0] = "availability.hmtl";
 info[11][1] = "On vacation for Christmas"; infolink[11][1] = "availability.hmtl";
 info[11][2] = "On vacation for Christmas"; infolink[11][2] = "availability.hmtl";
//
// end data store
//
// calendar date objects [ !important! section must not move ]
//
     var today = new Date();
     var thisDay = today.getDate();
//
// determination of number for month, using default / or search string value
//  executes on load of script / page
//  'granulated' failsafe validation to ensure month value is numeric and in range
//  current month will be default
//
     if (!document.location.search) { var thisMonth = today.getMonth(); } // if no search string, use current month as default (failsafe)
      else {  // use search string as month number
                 if (document.location.search.length <= 3) { thisMonth = today.getMonth(); } // if null value, use current month (failsafe)
                   else { // check integrity of string
                        var dl = new Number(document.location.search.length); // string length
                        var valueToCheck = document.location.search.substring(3,dl); // expose string value
                        var allowed = "0123456789"; // declare acceptible values for string (non integer)
                      for ( Ni=0; Ni < valueToCheck.length; Ni++ ) { // if value string contains non-numeric char's, use current month (failsafe)
                              if (allowed.indexOf(valueToCheck.charAt(Ni)) == -1) { thisMonth = today.getMonth(); break; }
                                else { thisMonth = new Number(document.location.search.substring(3,dl)); } // if string is safe, use search value
                            } // if out of range, use current month (failsafe)
                      if (thisMonth > 11) { thisMonth = today.getMonth(); }
                    }
                 }
//
// determination of number for year: if month is less than current month, treat as following year, else is current year.
 var thisYear = new Number();
	// if ( thisMonth < today.getMonth() ) { thisYear = (y2k(today.getYear())+1) ; }
 	// else { thisYear = y2k(today.getYear());  }

 	thisYear = y2k(today.getYear()); //ADDED

//
// display dynamic calendar
// function bridges trigger script in <body> and process script in <head>
function defineCalendar() { return Calendar(thisMonth,thisYear); }
//
// global var for month names
     //var names = new array("Jan 03","Feb 03","Mar 03","Apr 02","May 02","Jun 02","Jul 02","Aug 02","Sep 02","Oct 02","Nov 02","Dec 02");

     var names = new array("Jan ","Feb ","Mar ","Apr ","May ","Jun ","Jul ","Aug ","Sep ","Oct ","Nov ","Dec ");

     for (x=0; x<12; x++)
     {
	     names[x] = names[x] + thisYear;
     }


//
// main calendar calculation and display function
function Calendar(Month,Year) {
// local var for month days
     var days = new array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
// initial vars for cell colors
     var HeadColor = "bgcolor=\"\#fffff0\"";
     var RowColor = "bgcolor=\"\#f0f8ff\"";
     var DayColor = "bgcolor=\"\#f0f8ff\"";
     var HighColor = "bgcolor=\"\#f0f8ff\"";
// begin building output format
    var output = "";
    var firstDay = new Date(Year,Month,1);
    var startDay = firstDay.getDay();
//
 if (((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0))
 { days[1] = 29; } // leap year
   else { days[1] = 28; }
//  writes form for changing value of month to display
 var  calendarNavForm = "<select onChange=\"submit();\" class=\"smallform\" name=\"m\">";
  for  ( No = 0 ; No <12; No++)
   {
       calendarNavForm += "<option value=\"" + No + "\">" + names[No] + "</\option>";
    }
    calendarNavForm += "<\/select>";
// begin building output - table head
    output += "<FORM class=\"smallform\" NAME=\"calendarNav\" METHOD=\"GET\" ACTION=\"\">";
    output += "<table border=\"0\" cellspacing=\"0\" CELLPADDING=\"3\" width=\"98%\">";
    output += "<tr " + HeadColor + "><th colspan=\"4\">" + names[Month] + " " +  "<\/th>";
    output += "<th colspan=\"3\">" + calendarNavForm + "<\/th><\/tr>";
    output += "<tr " + RowColor + "><th>S<\/th><th>M<\/th><th>T<\/th><th>W<\/th><th>T<\/th><th>F<\/th><th>S<\/th><\/tr>";
    output += "<tr align=\"center\">";
// begin days of calendar
 var column = 0;
// empty cells till starting date
 for ( iD=0; iD < startDay; iD++ ) {
   output += "<td align=\"center\" width=\"14\%\" bgcolor=\"\#fffff0\">&nbsp;<\/td>"; column++;
   }
// start dates
 for ( i=1; i<=days[Month]; i++ )
  {
     var insert = "";
   if ( (column == 0) || (column == 6) ) {  DayColor =  "bgcolor=\"\#fdf5e6\""; }
     else {  DayColor =  "bgcolor=\"\#fffff0\""; }
// set default colours and assign link for matched KeyDates
 for ( k=0; k < KeyDate[Month].length; k++)
  {
   if ( i ==  parseInt(KeyDate[Month][k]) )
    {
      DayColor = "class=\"calendarbox\" bgcolor=\"#fffff0\""; // if keydate, background is white, red box
      HighColor = "class=\"highbox\" bgcolor=\"\#b0c4de\""; // if keydate & current date, background is gold, red box
      var CurrentLink = infolink[Month][k]; // determine corresponding hyperlink
// where key dates matched add  event-handlers to HTML code
  insert = "<a onMouseOver=\"show(\'" + i + "\');  return true;\" onMouseOut=\"hide(\'" + i + "\');  return true;\" href='" + CurrentLink + "'>" + i + "<\/a>"; break; }
     else  { insert = i; }
   }
// if current day of current month, highlight in gold, else default
   if ( ( i == thisDay )  && ( Month == (today.getMonth())) && (Year == thisYear ) )  { output += "<td width=\"14\%\"" + HighColor + ">" + insert + "<\/td>"; }
     else  { output += "<td align=\"center\" width=\"14\%\"" + DayColor + ">" + insert + "<\/td>"; }
     column++;
// wrap row every 7 cells
   if ( (column == 7) && (i < days[Month]) ) { output += "<\/tr><tr align=\"center\">"; column = 0; }
  }
// if required fill last row with empty cells to complete
 if ( (column != 7) && (column > 0)  ) { var CC = new Number(column);
        for (iC=CC; iC < 7 ; iC++)  { output += "<td align=\"center\" width=\"14\%\" bgcolor=\"\#fffff0\">&nbsp;<\/td>";  }
      }
// done formatting table
 output += "<\/tr><\/table><\/FORM>";
// write out
  return document.write(output);
 }
//
// calendar month array
function array(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11) {
     this[0] = m0; this[1] = m1; this[2] = m2; this[3] = m3;
     this[4] = m4; this[5] = m5; this[6] = m6; this[7] = m7;
     this[8] = m8; this[9] = m9; this[10] = m10; this[11] = m11;
 }
//
// full year workaround
function y2k(number) {
      return (number < 1000) ? number + 1900 : number;
   }
//
// display info[x] message text to page according to relative Object Models
//
function show(item) {
 var NumItem = parseInt(item);
// extract correct Text for Date
 for  (N=0; N < KeyDate[thisMonth].length; N++)  {  if ( KeyDate[thisMonth][N]   ==  NumItem ) { var ComingEvent = info[thisMonth][N];  }  }
// write text to page
 if (document.getElementById) { document.getElementById("EventForDate").innerHTML = ComingEvent; }
  else if ( (!document.getElementById) && (document.all) ) { document.all["EventForDate"].innerHTML = ComingEvent; }
  else if (document.layers) { window.defaultStatus =  ComingEvent; }
  return true;
}
// remove message according to relative Object Models
function hide(item) { //
 if (document.getElementById) { document.getElementById("EventForDate").innerHTML = ""; }
  else if ( (!document.getElementById) && (document.all) ) { document.all["EventForDate"].innerHTML = ""; }
  else  if (document.layers) { window.defaultStatus = "APNIC"; }
  return true;
}
//
// direct write current month to document
// document.write(Calendar(thisMonth,thisYear)); // historic
//
// sets selection to selected month (over-ride default behaviour)
 function ResetMonth() { return document.calendarNav.elements[0].options[thisMonth].selected = true;}
//
//-->
