gObjectNum = 0;
gTimeoutID = 0;
gNumBanners = 0;

//---------------------------------------------------------------------
//
// set_object
//
//---------------------------------------------------------------------
function set_object(id, setTo) 
{
   //alert(id);
   var theElement;
   if (document.getElementById) 
   {
      //DOM
      theElement = document.getElementById( id );
   }
   else if (document.all)
   {
      //Proprietary DOM
      theElement = document.all[ id ];
   }
  
   if (!theElement)
   {
      /* The page has not loaded, or the browser claims to
      support document.getElementById or document.all but
      cannot actually use either */
      return;
  }

   //Reference the style ...
   if (theElement.style)
      theElement = theElement.style;
      
   if (typeof(theElement.display) == 'undefined') 
   {
      //The browser does not allow us to change the display style
      //Alert something sensible (not what I have here ...)
      window.alert( 'Your browser does not support this' );
      return;
   }
  
   //Change the display style
   theElement.display = setTo;
}

//---------------------------------------------------------------------
//
// focus_object
//
//---------------------------------------------------------------------
function focus_object(layer_id)
{
   //alert("image_id: " + image_id + " image_src: " + image_src);

   for (i = 1; i <= gNumBanners; i++)
   {
      temp_id = "banner" + i;
      set_object(temp_id, 'none');
   }
   
   set_object(layer_id, 'inline');
}

//---------------------------------------------------------------------
//
// pause_object
//
//---------------------------------------------------------------------
function pause_object()
{
   clearTimeout(gTimeoutID);
}

//---------------------------------------------------------------------
//
// rotate_object
//
//---------------------------------------------------------------------
function rotate_object()
{
   //alert(gObjectNum);

   gObjectNum = (gObjectNum == gNumBanners) ? 1 : gObjectNum + 1;

   temp_id = "banner" + gObjectNum;
   focus_object(temp_id);

   gTimeoutID = setTimeout("rotate_object()", 8000);
}

//---------------------------------------------------------------------
//
// prev_object
//
//---------------------------------------------------------------------
function prev_object()
{
   //alert(gObjectNum);

   gObjectNum = (gObjectNum == 1) ? gNumBanners : gObjectNum - 1;
   temp_id = "banner" + gObjectNum;

   pause_object();
   focus_object(temp_id);
}

//---------------------------------------------------------------------
//
// next_object
//
//---------------------------------------------------------------------
function next_object()
{
   //alert(gObjectNum);

   gObjectNum = (gObjectNum == gNumBanners) ? 1 : gObjectNum + 1;
   temp_id = "banner" + gObjectNum;

   pause_object();
   focus_object(temp_id);
}