// BEHAVIOUR: WELCOME PAGE (SLIDESHOW, etc)

// (c) 2006 Toowoomba Motor Village - all rights reserved



// 'MAIN' - called when complete page loaded with images, etc
// Initially, only start slideshow projector if broadband (to ensure responsiveness on low-bandwidth); however,
// when page fully downloaded (hence cached), & then re-entered , slideshow will download even if low-bandwidth.
// Site response-times (& UX) are improved by use of common image-files for both slideshow & other page-bkgds.
// Notes: - slideshow PAUSES when mouse HOVERS over MENU (on left) or main black CENTRAL TEXT
//        - slideshow ADVANCES to next-slide when MAP is CLICKED (once carousel has 2 slides)
//        - slideshow NOT LOADED if page-load duration is long (for non broadband)

function hostLoaded()
{
  try
  {
      var PAGELOAD_SLOW_SECS = 8.0;
      var pageLoad_secs = ((new Date()).getTime() - hostLoaded.pageLoadStartTime) / 1000;
      if ( pageLoad_secs >= PAGELOAD_SLOW_SECS )  { return; }

      new ProjectorBg (
                        'viewport',          // target element for slideshow
                        20,                  // first-slide  duration in secs
                        15,                  // other-slides duration in secs
                        2,                   // resume-after-pause delay in secs
                        1,                   // start delay, in secs (breathing-space)
                        'map',               // [bg-only] target element for next-click    [otherwise use '']
                        'notes',             // [bg-only] target element1 for hover-pause  [otherwise use '']
                        'nav',               // [bg-only] target element2 for hover-pause  [otherwise use '']
                        'Images',            // slides-folder - relative to page           [otherwise use '']
                        'TSRBgrnd1.jpg',  // img1 slideshow image 1
                        'TSRBgrnd2.jpg',  // img2
                        'TSRBgrnd3.jpg',  // img3
                        'TSRBgrnd4.jpg',  // img4
                        'TSRBgrnd5.jpg'  // img5
                      );

      window.document.getElementById('xcss').ondblclick = xStyleSheetsOnOff;    // dev-tool (can be eliminated)
  }
  catch(e) { }

}



// SCRIPT INITIALISATION
// When page fully loaded, initiate processing, but only if a modern-browser;
// obsolete browsers are not countenanced (as script merely enhances an already competent page).
// This script-page formally binds the page-load event, hence does not use deprecated 'window.onload' event.
// The following is a statement which defines & executes a literal anonymous function
// whose only post-execution effect is normally the event-handler vector
// (in this script, the start-time of page-load is stored as well).
// [review-crossbrowser: consider alternatives to use of 'window-load' event: eg 'window.document.load', etc.]

(
        function (evtHandler)
        {
            try
            {
                evtHandler.pageLoadStartTime = (new Date()).getTime();
                
                var CAPTURE    = false;
                var W3C        = !!(window.addEventListener);
                var MSIE       = !!(window.attachEvent);
                
                if (W3C)  { window.addEventListener('load', evtHandler, CAPTURE); }
                else 
                if (MSIE) { window.attachEvent('onload', evtHandler); }
            }
            catch(e) { }
        }
 )(hostLoaded);                                           // change function-name if name-space clash




// -----------------------------------------------------------------------------------------

// DEVELOPMENTAL COMPONENTS (dev-purposes only)
// [these component(s) are not formal features of classes above]
// Toggle Stylesheet(s) Off/On        [when off, default HTML styles are used]
// loop thru stylesheets collection, setting 'disabled' property of
// all stylesheets to inverted 'disabled' property-value of the first sheet.

function xStyleSheetsOnOff()
{
   var sss = window.document.styleSheets;
   var len = sss.length;
   if (len > 0)
   {
      var dsbld = !(sss[0].disabled);            // invert sheet0 disabled-state
      for (var i=0; i<len; i++)
      {
          sss[i].disabled = dsbld;
      }
   }
   Projector.enabled = false; // special: freeze projector - current slide, if visible, remains so
}

// ------------------------------------------------------------------------------------------

// (c) 2006 Ian Brown

// end script

