  // DATEBASEDSEASONALPAGEREDIRCT.JS
  //
  // Complete self contained code that can be used in situations requiring a temporary redirect
  // (with an expiry date) to a seasonal version of a page, such as a special Christmas version
  // of the home page, etc.
 
  TheExpiryDateAsANumber = 20201231;
  TempRedirPageURL = "index.htm";
  TempRedirHomeDirectory = "";  // "" or "../" if it is in a subdirectory or the complete URL if required.

  var ErrorTrappingOn = true; // Set to true or false. If false then error reporting is turned on.

  function errorHandler(errorMessage, url, lineNumber) {

    // All JavaScript errors are trapped. If ErrorTrappingOn is false then an alert box with the error
    // details is also displayed. This code is supported under Netscape 3+ and IE4+ and later.
    if (ErrorTrappingOn == false)
      {
       errormsg  = "This page contains a scripting error.\r\n\r\n";
       errormsg += "Line: "  + lineNumber   + "\r\n";
       errormsg += "Error: " + errorMessage + "\r\n";
       errormsg += "URL: "   + url;
       alert(errormsg);
      };
    event.returnValue = true;
    return true;
  };
  window.onerror = errorHandler;

  var MinBrowserReqForDateBasedRedir = false; // Default value before testing.
  if ((window.screen) && (window.screen.width) && (screen.width >= 100))
   {
    MinBrowserReqForDateBasedRedir = true;
   };

  // Date comparison functions.
  //
  var TodaysDateAsANumberForEasyComparisons = 0; // Declared globally before being assigned.
  function ConvertTodaysDateToNumberForComparisonPurposesSelfContainedVersion() {

    if (MinBrowserReqForDateBasedRedir)
      {
       TodaysDateInfo = new Date();
       ThisYear = "" + TodaysDateInfo.getFullYear(); // Get as a string.
       ThisMonthNumber = 1 + TodaysDateInfo.getMonth(); // Get as a number.
       ThisMonth = "" + ThisMonthNumber; // Get as a string.
       if (ThisMonth.length == 1)
         {
          ThisMonth = "0" + ThisMonth; // Make sure that it is a 2 digit string.
         };
       ThisDay = "" + TodaysDateInfo.getDate(); // Get as a string.
       if (ThisDay.length == 1)
         {
          ThisDay = "0" + ThisDay; // Make sure that it is a 2 digit string.
         };
       TodaysDateString = "" + ThisYear + "" + ThisMonth + "" + ThisDay + ""; // Build string.
       TodaysDateAsANumberForEasyComparisons = 1 * TodaysDateString; // Convert to number.
      };
  };
  // Now call the ConvertTodaysDateToNumberForComparisonPurposesSelfContainedVersion function to assign the
  // TodaysDateAsANumberForEasyComparisons variable as a number.
  // For example, May 21 2001 would return a value of: 20010521
  // The numeric order of the elements is deliberate for easy less than, equal to and greater
  // than comparisons.
  ConvertTodaysDateToNumberForComparisonPurposesSelfContainedVersion();
  // 
  // Date comparison function. A typical conditional call dependent on whether todays date is
  // less than or equal to December 31st, 2001 would be:
  // if (IsTodaysDateLessThanOrEqualTo(20011231)
  function IsTodaysDateLessThanOrEqualToSelfContainedVersion(DateAsNumber) {

    if (MinBrowserReqForDateBasedRedir)
      {
       if (TodaysDateAsANumberForEasyComparisons < 1)
         {
          ConvertTodaysDateToNumberForComparisonPurposesSelfContainedVersion(); // Not previously called.
         };
       if (TodaysDateAsANumberForEasyComparisons < 1)
         {
          return false; // Not supported.
         };
       // Make sure both values are numeric before doing a numeric comparison.
       if ((1 * TodaysDateAsANumberForEasyComparisons) <= (1 * DateAsNumber))
         {
          return true;
         } else {
                 return false;
                };
      } else {
              return false;
             };
  };

  if (IsTodaysDateLessThanOrEqualToSelfContainedVersion(TheExpiryDateAsANumber))
    {
      if ((window.location) && (window.location.replace))
        {
         window.location.replace(TempRedirPageURL);
        } else {
                   if ((window.location) && (window.location.href))
                     {
                      window.location.href = TempRedirPageURL;
                     };
                 };
    };
 