function DumpVar(v) {
  var members = new Array();
  for(var m in v) {
    members.push(m);
  }
  alert(members.join("; "));
}


function ShowPhoto(title, caption, imgUrl) {
  var divList = document.getElementById("divList");
  var divPhoto = document.getElementById("divPhoto");
  var h3PhotoTitle = document.getElementById("h3PhotoTitle");
  var imgPhoto = document.getElementById("imgPhoto");
  var spanCaption = document.getElementById("spanCaption");

  Hide(divList);
  Show(divPhoto);
  h3PhotoTitle.innerHTML = title;
  imgPhoto.src = imgUrl;
  spanCaption.innerHTML = caption;

  return false;
}

function ShowPhotoList() {
  var divList = document.getElementById("divList");
  var divPhoto = document.getElementById("divPhoto");
  Hide(divPhoto);
  Show(divList);
  return false;
}


function Hide(elem) {
  elem.className = "Hide";
}

function Show(elem) {
  elem.className = "";
}

function PageInit() {
  InitRotateImage('topImg');
}

function OldPageInit() {
  rotImg1 = new ImageRotator("imgRot1", 6000, 
    new Array("layout-photo/Lorenzo1.jpg", 
              "layout-photo/ArtBeat17.jpg", 
              "layout-photo/McKenzie3.jpg", 
              "layout-photo/honk-speech-2007.jpg"));

  rotImg2 = new ImageRotator("imgRot2", 6000, 
    new Array("layout-photo/ArtBeat8.jpg", 
              "layout-photo/garden12.jpg", 
              "layout-photo/Lorenzo3.jpg", 
              "layout-photo/library.jpg"));

  rotImg3 = new ImageRotator("imgRot3", 6000, 
    new Array("layout-photo/McKenzie4.jpg", 
              "layout-photo/statue-park.jpg", 
              "layout-photo/supporter5_2007.jpg",
              "layout-photo/garden6.jpg"));

  rotImg1.Start("rotImg1");
  rotImg2.Start("rotImg2");
  rotImg3.Start("rotImg3");

}

function ImageRotator(id, speed, images) {
  this.imageUrls = images;
  this.speed = speed;
  this.imageId = id;
  this.imageIdx = -1;

  this.Start = function(varName) {
    setInterval(varName + ".Rotate();", this.speed);
  };

  this.Rotate = function() {
    this.imageIdx++;
    if (this.imageIdx >= this.imageUrls.length) {
      this.imageIdx = 0;
    }

    var img = document.getElementById(this.imageId);
    img.src = this.imageUrls[this.imageIdx];

  }
}

var imgRotator;
function PageInit2() {
  imgRotator = new CssClasRotator("divTopImages", 6000,
    new Array("ShowOne", "ShowTwo", "ShowThree"));
  imgRotator.Start("imgRotator");
}

function CssClasRotator(id, period, classes) {
  this.divId = id;
  this.period = period;
  this.classes = classes;
  this.index = 0;

  this.Start = function(varName) {
    setInterval(varName + ".Rotate();", this.period);
  }


  this.Rotate = function() {
    this.index++;
    if (this.index >= this.classes.length) {
      this.index = 0;
    }

    var div = document.getElementById(this.divId);
    div.className = this.classes[this.index];
  }
}

function InitRotateImage(parentId) {
  var parentDiv = document.getElementById(parentId);
  parentDiv.count = parentDiv.children.length;
  parentDiv.RotateChildren = _RotateChildren;
  parentDiv.fadeClasses = new Array("Opac05", "Opac10", "Opac15",
   "Opac20", "Opac25", "Opac30", "Opac35", "Opac40", "Opac45",
   "Opac50", "Opac55", "Opac60", "Opac65", "Opac70", "Opac75", 
   "Opac80", "Opac85", "Opac90", "Opac95");

  for(var i = 0; i < parentDiv.count; i++) {
    var child = parentDiv.children[i];
    child.FadeIn = _FadeIn;
  }


  var rotScript = "document.getElementById('"+parentId+"').RotateChildren();";
  setInterval(rotScript, 6000);

  function _RotateChildren() {
    for(var i = 0; i < this.count; i++) {
      var child = this.children[i];
      if (child.style.zIndex != 1) {
        child.style.zIndex--;
      } else {
        child.className = "Opac05";
        child.fadeLevel = 0;
        child.style.zIndex = this.count;

        var fadeScript = 
          "document.getElementById('"+child.id+"').FadeIn()";
        child.fadeThreadId = setInterval(fadeScript, 50);
      }
    }
  }

  function _FadeIn() {
    var parent = this.parentNode;
    if (this.fadeLevel < parent.fadeClasses.length) {
      this.fadeLevel++;
      this.className = parent.fadeClasses[this.fadeLevel];
    } else {
      this.className = "";
      this.FadeLevel = 0;
      clearInterval(this.fadeThreadId);
    }
  }

  
}
