/*
http://simonwillison.net/2004/May/26/addLoadEvent/
*/
function addLoadEvent(func)
{
  var oldonload = window.onload;
  if (typeof window.onload != 'function')
  {
    window.onload = func;
  }
  else
  {
    window.onload = function()
    {
      if (oldonload)
      {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(sponsor_setup);

function sponsor_setup()
{
  var elObj;

  if (!document.getElementById)
  {
    return;
  }
  if (elObj = document.getElementById("sponsors"))
  {
    setTimeout("sponsorslide()",10);
  }
  else
  {
    setTimeout("sponsor_setup()",10);
  }
}




function int_random(n) {
  return Math.floor(Math.random()*n)+1;
}

var sponsornum = 10;
var sponsors = new Array(sponsornum+1);

function sponsors_preload() {
  sponsors[1]=new Image();
  sponsors[1].src="images/sponsors/dret-small.gif";
  sponsors[2]=new Image();
  sponsors[2].src="images/sponsors/macmahon-small.gif";
  sponsors[3]=new Image();
  sponsors[3].src="images/sponsors/bp-small.gif";
  sponsors[4]=new Image();
  sponsors[4].src="images/sponsors/cardno-small.gif";
  sponsors[5]=new Image();
  sponsors[5].src="images/sponsors/gcm-small.gif";
  sponsors[6]=new Image();
  sponsors[6].src="images/sponsors/gtl-small.gif";
  sponsors[7]=new Image();
  sponsors[7].src="images/sponsors/highway-small.gif";
  sponsors[8]=new Image();
  sponsors[8].src="images/sponsors/schweppes-small.gif";
  sponsors[9]=new Image();
  sponsors[9].src="images/sponsors/stp-small.gif";
  sponsors[10]=new Image();
  sponsors[10].src="images/sponsors/wafg-small.gif";
}

//var sponsorstep=int_random(sponsornum);
var sponsorstep=1;
var sponsorstep2=0;

function sponsorslide() {
  //if browser does not support the image object, exit.
  if (!document.images)
    return;
  if (typeof sponsors[1] == 'undefined')
    sponsors_preload();
  document.images.sponsorlogo.src=eval("sponsors["+sponsorstep+"].src");
/*
  sponsorstep2=sponsorstep;
  while (sponsorstep2==sponsorstep) {
    sponsorstep2=int_random(sponsornum);
  }
*/
  sponsorstep2=sponsorstep+1;
  if (sponsorstep2 > sponsornum)
    sponsorstep2 = 1;
  sponsorstep=sponsorstep2;
  setTimeout("sponsorslide()",4300);
}
