/* ***********************************************************
** BANNER.JS - JS Image Banner library
** ===================================
** This library contains functions to create a rotating image
** banner. It's yours for free; please maintain this header!
**
** To load this library in an HTML doc, put the following
** line in the doc's HEAD (before any other SCRIPT tags):
**
** <SCRIPT SRC="banner.js" LANGUAGE="JavaScript"></SCRIPT>
**
** Author      Ver  Date    Comments
** ======      ===  ====    ========
** Rick Scott  1.0  1/1/00  First release
**
** Copyright 2000, Rick Scott, all rights reserved.
*********************************************************** */

if (! document.images)
  alert("Sorry, but your rotating banner won't work;\n" +
        "You need to be running Netscape 3.0+ or IE 4.0+.");

var CurrBanner = 1;     // current banner num
var Init       = true;  // to pause before first rotation
var TimerID;            // to stop setTimeout() call

function make2DArray(numXels, numYels)  // create 2D array
  {
  var arr = new Array(numXels);
  for (var i=0; i<numXels; i++)
    arr[i] = new Array(numYels);
  return arr;
  }

function gotoBannerURL()  // load URL of current banner
  {
  //clearTimeout(TimerID);  // stop rotation while waiting for URL to load
  window.open(Banners[CurrBanner-1][1]);  // load URL
  }

function rotateBanner()  // rotate banner images
  {
  if (document.images[IMGTAGNUM].complete)  // wait till curr image is loaded to rotate
    {
    if (Init == false)   // wait one setTimeout() cycle to rotate first time
      {
      CurrBanner++;
      if (CurrBanner > NUMBANNERS)  // loop banners: 1234512345, etc.
        CurrBanner = 1;
      document.images[IMGTAGNUM].src = Banners[CurrBanner-1][0];  // display banner image
      }
    Init = false;
    TimerID = setTimeout("rotateBanner()", BANNERSECS*1000);
    }
  }

function doBannerButton(button)  // process Stop/Start button click
  {
  if (button.value == "Stop Banner")  // user clicked on "Stop Banner"
    {
    button.value = "Start Banner";
    clearTimeout(TimerID);  // stop rotation
    }
  else  // user clicked on "Start Banner"
    {
    button.value = "Stop Banner"
    rotateBanner();  // start rotation
    }
  }

