gRtObjectNum = 0;
gRtTimeoutID = 0;
gRtNumObjects = 0;

//---------------------------------------------------------------------
//
// set_object
//
//---------------------------------------------------------------------
function set_object(id, setTo) 
{
   //alert(id);
   var obj;
   if (document.getElementById) 
   {
      //DOM
      obj = document.getElementById( id );
   }
   else if (document.all)
   {
      //Proprietary DOM
      obj = document.all[ id ];
   }
  
   if (!obj)
   {
      /* 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 (obj.style)
      obj = obj.style;
      
   if (typeof(obj.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
   obj.display = setTo;
}

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

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

   // Show div with next banner
   temp_id = "banner" + num;
   set_object(temp_id, 'inline');
   
   // Get link for next banner
   href_id = "banner" + num + "href";
   href = document.getElementById(href_id).href;
   //alert(href);

   // Assign link to rotate controlls "details" link
   document.getElementById('detailshref').href = href;
}

//---------------------------------------------------------------------
//
// pause_object
//
//---------------------------------------------------------------------
function pause_object()
{
   clearInterval(gRtTimeoutID);
   gRtTimeoutID = 0;

   return(false);
}

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

   gRtObjectNum = (gRtObjectNum == gRtNumObjects) ? 1 : gRtObjectNum + 1;

   focus_object(gRtObjectNum);

   if (gRtTimeoutID == 0)
      gRtTimeoutID = setInterval("rotate_object()", 6000);
   
   return(false);
}

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

   gRtObjectNum = (gRtObjectNum == 1) ? gRtNumObjects : gRtObjectNum - 1;

   pause_object();
   focus_object(gRtObjectNum);
   
   return(false);
}

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

   gRtObjectNum = (gRtObjectNum == gRtNumObjects) ? 1 : gRtObjectNum + 1;

   pause_object();
   focus_object(gRtObjectNum);
   
   return(false);
}
