﻿delay = 35500  // delay between banners in milliseconds (1000 millisec. = 1 sec.)
curImg1 = 0
curImg2 = 0

theImageSrcs = new Array('banner/qbbanner.gif','banner/aabanner.gif','banner/scandinavianpipes.gif','banner/mimmo.gif','banner/smokingpipes.gif','banner/subanner.gif','banner/kevin.gif','banner/smokershaven.gif','banner/alpascia.gif','banner/frank.gif')
theImagesHrefs = new Array('http://www.qualitybriar.com','http://www.aab-taxfreepipes.com','http://www.scandpipes.com/index.html','http://www.romeobriar.com','http://www.smokingpipes.com','http://www.pipes.su','http://www.pipes.com.tw','http://www.smokershaven.com','http://www.alpascia.com','http://www.pfeifenstudio-frank.de')


function click(which) {
  if (which == 1)
    window.open(theImagesHrefs[curImg1 - 1], 'ny', 'toolbar=yes,menubar=yes,scrollbars=yes,status=yes,directories=yes,location=yes,resizable=yes')
  else
    window.open(theImagesHrefs[curImg2 - 1], 'ny', 'toolbar=yes,menubar=yes,scrollbars=yes,status=yes,directories=yes,location=yes,resizable=yes')
}

function getRandom() {
  nextRan = Math.random() * theImageSrcs.length
  nextRan = Math.floor(nextRan)
  return nextRan
}

function animate() {
  oldCurImg = curImg1 
  // First image
  nextImg = getRandom()
  do
    nextImg = getRandom()
  while ((nextImg == (curImg1 - 1)) || (nextImg == (curImg2 - 1)))
  document.animation1.src = theImageSrcs[nextImg]
  curImg1 = nextImg + 1

  // First image
  nextImg = getRandom()
  do
    nextImg = getRandom()
  while ((nextImg == (oldCurImg - 1)) || (nextImg == (curImg1 - 1)) || (nextImg == (curImg2 - 1)))
  document.animation2.src = theImageSrcs[nextImg]
  curImg2 = nextImg + 1
  setTimeout('animate()', delay)
}