var m_timerID;

// sponsors
var m_iImageTotal_spons = 0;
var m_iImageCurrent_spons = 0;

// adver
var m_iImageTotal_ads;
var m_iImageCurrent_ads;

function rotateImages() {
  if (m_iImageTotal_spons > 1) rotateImages_spons();
  if (m_iImageTotal_ads > 1) rotateImages_ads();
  m_timerID = window.setTimeout("rotateImages()", 2000);
}

function rotateImages_spons() {
  var sImageCurrent = '';
  sImageCurrent = 'box1Img' + m_iImageCurrent_spons;
  document.all(sImageCurrent).style.display = 'none';
  
  m_iImageCurrent_spons = m_iImageCurrent_spons + 1;
  if(m_iImageCurrent_spons > m_iImageTotal_spons) { m_iImageCurrent_spons = 1; }
  sImageCurrent = 'box1Img' + m_iImageCurrent_spons;
  document.all(sImageCurrent).style.display = 'inline';
}

function rotateImages_ads() {
  var sImageCurrent = '';
  sImageCurrent = 'boxAdsImg' + m_iImageCurrent_ads;
  document.all(sImageCurrent).style.display = 'none';
  
  m_iImageCurrent_ads = m_iImageCurrent_ads + 1;
  if(m_iImageCurrent_ads > m_iImageTotal_ads) { m_iImageCurrent_ads = 1; }
  sImageCurrent = 'boxAdsImg' + m_iImageCurrent_ads;
  document.all(sImageCurrent).style.display = 'inline';
}

function setImageTotal_spons(intTotal) {
  m_iImageTotal_spons = intTotal;  
}

function setImageTotal_ads(intTotal) {
  m_iImageTotal_ads = intTotal;  
}

// Initialisation
function initRotation() {
  if (m_iImageTotal_spons > 1) initRotation_spons();
  if (m_iImageTotal_ads > 1) initRotation_ads();
  startRotation();
}

function initRotation_spons() {
  var sImageCurrent = '';
  m_iImageCurrent_spons = 1;
  
  for(var i=1; i <= m_iImageTotal_spons; i++ ) {
    sImageCurrent = 'box1Img' + i;
    document.all(sImageCurrent).style.display = 'none';
  }
  if( m_iImageTotal_spons > 0 )
    document.all('box1Img1').style.display = 'inline';
}

function initRotation_ads() {
  var sImageCurrent = '';
  m_iImageCurrent_ads = 1;
  
  for(var i=1; i <= m_iImageTotal_ads; i++ ) {
    sImageCurrent = 'boxAdsImg' + i;
    document.all(sImageCurrent).style.display = 'none';
  }
  if( m_iImageTotal_ads > 0 )
    document.all('boxAdsImg1').style.display = 'inline';
}

// Start rotation
function startRotation() {
  m_timerID = window.setTimeout("rotateImages()", 2000);
}

// Stop rotation
function stopRotation() {
  window.clearTimeout(m_timerID);
}