var Testimonial = {
  currentTestimonial : 0,
  slideDuration : 500,
  
  init : function() {
    Testimonial.createTestimonials();
    Testimonial.swapTestimonial();
  },
  
  createTestimonials : function() {
    Testimonial.fx = [];
    Testimonial.testimonialFrames = $$('#testimonialSliderContainer blockquote');   
    Testimonial.testimonialHeight = $('testimonialSliderContainer').getStyle('height').toInt();
    Testimonial.testimonialFrames.each(function(frame, i) {             
      Testimonial.fx[i] = new Fx.Tween(frame, {duration: Testimonial.slideDuration, property: 'top'});          
    });
    
    /* Randomize */
    Testimonial.currentTestimonial = $random(0, Testimonial.testimonialFrames.length-1);
  },
  
  swapTestimonial : function() {
    Testimonial.fx[Testimonial.currentTestimonial].start(0, -Testimonial.testimonialHeight);
    Testimonial.currentTestimonial = (Testimonial.currentTestimonial + 1) % Testimonial.testimonialFrames.length;
    Testimonial.fx[Testimonial.currentTestimonial].start(Testimonial.testimonialHeight, 0);
    Testimonial.swapTestimonial.delay(10000);
  }
}

window.addEvent('domready', function() {
  if($('testimonialSliderContainer') != null) {
    Testimonial.init();
  }
});
