var current = 0;
var parentDiv = document.getElementById('testimonials');
var children = parentDiv.children;

//Hide all but one for now!
for(i=0; i< children.length; i++)
{
  setOpacity(0);
}
current = 0;

/* cross browser method to set opacity */
function setOpacity(level) {
  var element = children[current]
  element.style.opacity = level;
  element.style.MozOpacity = level;
  element.style.KhtmlOpacity = level;
  element.style.filter = "alpha(opacity=" + (level * 100) + ");";
  if(level == 0)
  {
    element.style.display = 'none';
    current = (current + 1) % children.length;
  }
  else
    element.style.display = '';
}

/* rotate and create timers to fade the testimonial in */
function fadeIn()
{
   
  for (i = 0; i <= 1; i = i + 0.05) {
    setTimeout("setOpacity(" + i + ")", i * 1000);
  }
  setTimeout("fadeOut()", 9000);
       
}

/* create timers to fade the testimonial away */
function fadeOut() 
{
  for (i = 0; i <= 1; i = i + 0.05) {
    setTimeout("setOpacity(" + (1 - i) + ")", i * 1000);
  }      
  setTimeout("fadeIn()", 1000);
}
fadeIn();
