//*****************************************************
//Configuration information

timesetup = 4000; // delay in milliseconds
images = new Array(9); //number of images

images[0] = "<a href=\"#\"><img src=\"image1.gif\" alt=\"Click here for ...\" border=\"0\" width=\"230\" height=\"270\"></a>";

images[1] = "<a href=\"#\"><img src=\"image2.gif\" alt=\"Click here for ...\" border=\"0\" width=\"230\" height=\"270\"></a>";

images[2] = "<a href=\"#\"><img src=\"image3.gif\" alt=\"Click here for ...\" border=\"0\" width=\"230\" height=\"270\"></a>";

images[3] = "<a href=\"#\"><img src=\"image4.gif\" alt=\"Click here for ...\" border=\"0\" width=\"230\" height=\"270\"></a>";

images[4] = "<a href=\"#\"><img src=\"image5.gif\" alt=\"Click here for ...\" border=\"0\" width=\"230\" height=\"270\"></a>";

images[5] = "<a href=\"#\"><img src=\"image6.gif\" alt=\"Click here for ...\" border=\"0\" width=\"230\" height=\"270\"></a>";

images[6] = "<a href=\"#\"><img src=\"image7.gif\" alt=\"Click here for ...\" border=\"0\" width=\"230\" height=\"270\"></a>";

images[7] = "<a href=\"#\"><img src=\"image8.gif\" alt=\"Click here for ...\" border=\"0\" width=\"230\" height=\"270\"></a>";

images[8] = "<a href=\"#\"><img src=\"image9.gif\" alt=\"Click here for ...\" border=\"0\" width=\"230\" height=\"270\"></a>";


//*****************************************************

type = "IE"; //default setting
BrowserSniffer(); //find out which browser
choosenImage = 0;
choosenIndex = 0;

displayStart();

if (images.length > 0) {
  timerID = setInterval(swapImage,timesetup);
}

//---------------------------
function BrowserSniffer() {
  if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) type="OP";
  else if (document.all) type="IE";
  else if (document.layers) type="NN";
  else if (!document.all && document.getElementById) type="MO";
  else type = "IE";
}

//---------------------------
function whatBrows() {
  window.alert("Browser is : " + type);
}

//---------------------------
function ChangeContent(id, str) {

  if (type=="IE") {
    document.all[id].innerHTML = str;
  }

  if (type=="NN") {
    document.layers[id].document.open();
    document.layers[id].document.write(str);
    document.layers[id].document.close();
  }

  if (type=="MO" || type=="OP") {
    document.getElementById(id).innerHTML = str;
  }

}

//---------------------------
function swapImage() {
  index = Math.floor(Math.random() * images.length);
  if (index == choosenIndex) {
    index++;
    if (index == images.length) {
      index = 0;
    }
  }  
  choosenImage = images[index];
  ChangeContent("box0", choosenImage);
  choosenIndex = index;
}


//---------------------------
function displayStart() {
  index = Math.floor(Math.random() * images.length);
  choosenImage = images[index];
  ChangeContent("box0", choosenImage);
  choosenIndex = index;
}
