var rotatorTimeout;
var rotatorTimeDelay = 6000;
var rotatorImages = new Array()
rotatorImages[0] = "images/header_image1.jpg"
rotatorImages[1] = "images/header_image2.jpg"
rotatorImages[2] = "images/header_image3.jpg"
myImage = 0;

function changeImageOpacity(numVal){
  numValOpacity = "." + numVal
  numValFilter = "alpha(opacity=" + numVal + ")";
  document.getElementById("topImageDiv").style.opacity = numValOpacity;
  document.getElementById("topImageDiv").style.filter = numValFilter;
}
function initiateRotator(numVal){
  if (numVal > 0) {
    myNum = numVal - 10;
    changeImageOpacity(myNum);
    setTimeout("initiateRotator(myNum)",40);
  }
  else {
    document.getElementById("topImage").src = document.getElementById("bottomImage").src;
    document.getElementById("topImageDiv").style.opacity = "100";
    document.getElementById("topImageDiv").style.filter = "alpha(opacity=100)";
  }
}
function loadNewImage(){
  document.getElementById("bottomImage").src = rotatorImages[myImage];
  initiateRotator(100);
  myImage = myImage + 1;
  if (myImage >= rotatorImages.length){
    myImage = 0;
  }
  rotatorTimeout = setTimeout("loadNewImage()",rotatorTimeDelay);
}
function stopRotator(){
  clearTimeout(rotatorTimeout);
}
function startRotator(){
  clearTimeout(rotatorTimeout);
  loadNewImage();
}
