//  (c) 1999 by programmed teaching services & Bill Russell
//  This script loads the month and time table 
//  Last update 4/10/2009.
//
//  Edit the month's start date and length at the end of this file.



  var the_file = '';
  var the_month = 0;
  var sd_month = '';
  var sd_offset = 0;
  var sd_last_day = 0;
  var this_day = '';
  var last_week = 4;
  var wk_day = 0;
  var this_month = 0;

// function loadtt(pday, the_month, sd_offset)
// {
//   show_tt(pday, the_month, sd_offset);
// }




//===========================================================
//                                        SHOW TT    show_tt
// ==========================================================


// 2512.htm - Christmas Day
// tts.htm - Great Train Race Day

function show_tt(pa1, pa2, pa3)
{
var day = pa1;
the_month = pa2;
sd_offset = pa3;
the_file = '';


  wk_day = (day + sd_offset - 1) % 7;

if (the_month == 13) the_file = 'ttfb.htm';
if (the_month < 0903) the_file = 'oldtt.htm';
if (the_month > 1009) the_file = 'nott.htm';





  if (the_month == 0903)
  {
    the_file = 'ttyx.htm';
    if (wk_day == 0) the_file = 'ttbx.htm';
    if (wk_day == 6) the_file = 'ttbx.htm';
    if (day == 9) the_file = 'ttbx.htm';
  }


// Note tempory use of the old tty (ttyx) for April
  if (the_month == 0904)
  {
    the_file = 'ttb.htm';
    if (day < 4) the_file = 'ttyx.htm';
    if (day > 19) the_file = 'tty.htm';
    if (wk_day == 0) the_file = 'ttb.htm';
    if (wk_day == 6) the_file = 'ttb.htm';
    if (day == 29) the_file = "ttyx.htm"
  }

  if (the_month == 0905)
  {
    the_file = 'tto.htm';
    if (wk_day == 0) the_file = 'tty.htm';
    if (wk_day == 6) the_file = 'tty.htm';
    if (day == 1) the_file = 'tty.htm';
    if (day == 3) the_file = 'tts.htm';
  }

  if (the_month == 0906)
  {
    the_file = 'tto.htm';
    if (wk_day == 0) the_file = 'tty.htm';
    if (wk_day == 6) the_file = 'tty.htm';
    if (day == 7) the_file = 'tty.htm';
    if (day >28) the_file = 'tty.htm';
  }


  if (the_month == 0907)
  {
    the_file = 'tto.htm';
    if (wk_day == 0) the_file = 'tty.htm';
    if (wk_day == 6) the_file = 'tty.htm';
    if (day < 11) the_file = 'tty.htm';
  }

  if (the_month == 0908)
  {
    the_file = 'tto.htm';
    if (wk_day == 0) the_file = 'tty.htm';
    if (wk_day == 6) the_file = 'tty.htm';
  }

if (the_month == 0909)
  {
    the_file = 'tto.htm';
    if (wk_day == 0) the_file = 'tty.htm';
    if (wk_day == 6) the_file = 'tty.htm';
    if (day >18) the_file = 'ttb.htm';
  }

if (the_month == 0910)
  {
    the_file = 'tty.htm';
    if (wk_day == 0) the_file = 'ttb.htm';
    if (wk_day == 6) the_file = 'ttb.htm';
    if (day < 2) the_file = 'ttb.htm';
  }

if (the_month == 0911)
  {
    the_file = 'tty.htm';
    if (wk_day == 0) the_file = 'ttb.htm';
    if (wk_day == 6) the_file = 'ttb.htm';
    if (day < 4) the_file = 'ttb.htm';
  }


if (the_month == 0912)
  {
    the_file = 'tty.htm';
    if (wk_day == 0) the_file = 'ttb.htm';
    if (wk_day == 6) the_file = 'ttb.htm';
    if (day > 25) the_file = 'ttg.htm';
    if (day == 25) the_file = "2512.htm"
  }

if (the_month == 1001)
  {
    the_file = 'ttb.htm';
    if (day < 4) the_file = 'ttg.htm';
    if (day == 29) the_file = 'tty.htm';
  }


  if (the_month == 1002)
  {
    the_file = 'tty.htm';
    if (wk_day == 0) the_file = 'ttb.htm';
    if (wk_day == 6) the_file = 'ttb.htm';
}

  if (the_month == 1003)
  {
    the_file = 'tty.htm';
    if (wk_day == 0) the_file = 'ttb.htm';
    if (wk_day == 6) the_file = 'ttb.htm';
    if (day > 28) the_file = 'ttb.htm';
}


  if (the_month == 1004)
  {
    the_file = 'tty.htm';
    if (wk_day == 0) the_file = 'ttb.htm';
    if (wk_day == 6) the_file = 'ttb.htm';
    if (day < 11) the_file = 'ttb.htm';
  }

  if (the_month == 1005)
  {
    the_file = 'tto.htm';
    if (wk_day == 0) the_file = 'tty.htm';
    if (wk_day == 6) the_file = 'tty.htm';
  }

if (the_month == 1006)
  {
    the_file = 'tto.htm';
    if (wk_day == 0) the_file = 'tty.htm';
    if (wk_day == 6) the_file = 'tty.htm';
    if (day > 27) the_file = 'tty.htm';
  }

if (the_month == 1007)
  {
    the_file = 'tto.htm';
    if (wk_day == 0) the_file = 'tty.htm';
    if (wk_day == 6) the_file = 'tty.htm';
    if (day < 10) the_file = 'tty.htm';
  }

if (the_month == 1008)
  {
    the_file = 'tto.htm';
    if (wk_day == 0) the_file = 'tty.htm';
    if (wk_day == 6) the_file = 'tty.htm';
}

if (the_month == 1009)
  {
    the_file = 'tto.htm';
    if (wk_day == 0) the_file = 'tty.htm';
    if (wk_day == 6) the_file = 'tty.htm';
    if (day > 18) the_file = 'ttb.htm';
  }





//   alert('Show TT\n' + day +  ', '+ the_file );  


  window.main.location.href = the_file;
}




//===================================================
//  --------------------------------------  Show Month
//===================================================

function showmonth(p0, p1, p2, p3)
{
  sd_month = p0;
  this_month = p1;
  sd_last_day = p2;
  sd_offset = p3;
  var temp = p2 + p3;
  if( temp > 35) last_week = 5
  else last_week = 4;;

window.main.document.open('text/html','replace');
  window.main.document.writeln('<html> <head> <title> </title>');
//  window.main.document.writeln('<script language="JavaScript" src = "tt.js">');
  window.main.document.writeln('<link rel="stylesheet" href="../wrpuff.css" type="text/css">');
  window.main.document.writeln('</head>');
  window.main.document.writeln('<body>');
  window.main.document.writeln('<center> <form>');
  window.main.document.writeln('<table border = 1>');
  window.main.document.write('<tr> <th colspan = 7 > <p>');
  window.main.document.write('<h2><center>');
  window.main.document.writeln(sd_month + '</center></h2></th> </tr>');
  window.main.document.write('<tr><td><center>Sun</center></td>');
  window.main.document.write('<td> <center>Mon</center></td>');
  window.main.document.write('<td> <center>Tue</center></td>');
  window.main.document.write('<td> <center>Wed</center></td>');
  window.main.document.write('<td> <center>Thu</center></td>');
  window.main.document.write('<td> <center>Fri</center></td> ');
  window.main.document.writeln('<td><center>Sat</center></td> </tr>');


  for(var week=0; week<=last_week; week++ )
  {
    window.main.document.writeln('<tr align = right>');
for(var day = 1; day <= 7; day++ )
    {
      this_day = day + (week * 7) - sd_offset;
      if(this_day < 1) this_day = "<br>";
      if(this_day > sd_last_day) this_day = "<br>";
      window.main.document.write('<td>');

      if (this_day > 0)
      {
        window.main.document.write('<input type = radio name = "x" value = "" ');
        window.main.document.write(' onclick="javascript:parent.show_tt(' );
        window.main.document.write( this_day + ', ' + this_month + ', ');
        window.main.document.write( sd_offset + ')">');
      } 

      window.main.document.writeln(this_day + '</td>');
    }

    window.main.document.writeln('</tr>');
  }

window.main.document.writeln('</table> </form> </center> </body> </html>');
}

//==================================================================
// ------------------------------------------------------  LoadMonth
//=====================================================================
function loadmonth(dummy)

{
  this_month = dummy;

  if (this_month == "") window.main.location.href = "month0.htm";

//  Edit the next lines when necessary
//  showmonth(Month Name, Month-Number, LastDay, Offset
//  Offset: This indicates the day on which the month starts.
//    If the month starts on Sunday the offset is 0,
//   if on Saturday the offset is 6


  if (this_month == 0901) showmonth("January 2009", 0901, 31, 4);
  if (this_month == 0902) showmonth("February 2009", 0902, 28, 0);
  if (this_month == 0903) showmonth("March 2009", 0903, 31, 0);
  if (this_month == 0904) showmonth("April 2009", 0904, 30, 3);
  if (this_month == 0905) showmonth("May 2009", 0905, 31, 5);
  if (this_month == 0906) showmonth("June 2009", 0906, 30, 1);

  if (this_month == 0907) showmonth("July 2009", 0907, 31, 3);
  if (this_month == 0908) showmonth("August 2009", 0908, 31, 6);
  if (this_month == 0909) showmonth("September 2009", 0909, 30, 2);
  if (this_month == 0910) showmonth("October 2009", 0910, 31, 4);
  if (this_month == 0911) showmonth("November 2009", 0911, 30, 0);
  if (this_month == 0912) showmonth("December 2009", 0912, 31, 2);

if (this_month == 1001) showmonth("January 2010", 1001, 31, 5);
  if (this_month == 1002) showmonth("February 2010", 1002, 28, 1);
  if (this_month == 1003) showmonth("March 2010", 1003, 31, 1);
  if (this_month == 1004) showmonth("April 2010", 1004, 30, 4);
  if (this_month == 1005) showmonth("May 2010", 1005, 31, 6);
  if (this_month == 1006) showmonth("June 2010", 1006, 30, 2);

  if (this_month == 1007) showmonth("July 2010", 1007, 31, 4);
  if (this_month == 1008) showmonth("August 2010", 1008, 31, 0);
  if (this_month == 1009) showmonth("September 2010", 1009, 30, 3);
  if (this_month == 1010) showmonth("October 2010", 1010, 31, 5);
  if (this_month == 1011) showmonth("November 2010", 1011, 30, 1);
  if (this_month == 1012) showmonth("December 2010", 012, 31, 3);



  if (this_month == 13)  window.main.location.href = 'tttfb.htm';

}







// end of file
