function swap(imgid, imgname)
{
  document.images[imgid].src = "images/" + imgname;
}


function swapOn( imgid )
{
  var pic = document.images[imgid].src;
  var npic = pic.substr(0,pic.length - 4) + "-on.gif";
  document.images[imgid].src = npic;
}

function swapOff( imgid )
{
  var pic = document.images[imgid].src;
  var npic = pic.substr(0,pic.length - 7) + ".gif";
  document.images[imgid].src = npic;
}

var newRandNum
var oldRandNum

function cycle()
{
  var cycleVar = setTimeout( "rotateImage()", 5000 );
}


function rotateImage()
{
  var suffix;
  var newImgNum;
  var maxImg = 22;
  do
  {
    newRandNum = Math.round( Math.random() * (maxImg - 1 ) ) + 1;
  } while ( oldRandNum == newRandNum );
  if ( newRandNum == 1 ) { suffix = ".gif" }
  else                   { suffix = ".jpg" }
  
  if ( newRandNum <= 9 ) { newImgNum = "0" + newRandNum; }
  else                   { newImgNum = newRandNum; }
  document.images['mainimage'].src = "/images/web/main-image" + newImgNum + suffix;
  oldRandNum = newRandNum;
}

function loadMainAd()
{
  document.images['ad'].src = "/images/ads/reebokgrandprix.jpg";
}

function sOn( id )
{
  document.getElementById(id).style.borderBottomColor = "#008000";
  document.getElementById(id).style.backgroundColor = "#E0E0E0";
  document.getElementById(id).style.color = "#008000";
}
function sOff( id )
{
  document.getElementById(id).style.borderBottomColor = "#C0C0C0";
  document.getElementById(id).style.backgroundColor = "#F0F0F0";
  document.getElementById(id).style.color = "#808080";
}

function setGalleryImg( imageName )
{
  document.images['slideimg'].src = "/images/events/" + imageName;
}

function elink( name, host, text )
{ var linkText = "";
  if ( text == "" )
  {
    linkText = name + "@" + host;
  }
  else
  {
    linkText = text;
  }
  document.write( "<a href=\"mailto:" + name + "@" + host + "\">" + linkText + "</a>" );
}

function changeOpacity( item, value )
{ item.style.opacity = value;
  item.style.filter = "alpha(opacity=" + (value*100) + ")";
}