$(document).ready(function(){

var testimonial = {
    container: '#hidden-testimonials',
    duration: 15000,
    fadeInTime: 200,
    fadeOutTime: 250,
    nextTestimonial: function() {
        var next = $(testimonial.container).children().first();
        return next;
    },
    heights: '',
    setHeight: function(container,newheight){
        container.animate({
            height: newheight
        })
    },
    changeTestimonial: function() {
        var next = testimonial.nextTestimonial();
        var container = $('#testimonial-wrapper');
        var activeTestimonial = $('.active-testimonial');
        var currentHeight = container.height();
       
        if(!$.browser.msie) { // if Not IE
        
        // lock in the current height, until we can load the next testimonial 
        testimonial.setHeight(container,currentHeight);
        // fade out the current contents
        container.children().fadeOut(testimonial.fadeOutTime, function(){
            // move the active testimonial out

            $('.active-testimonial').appendTo('#hidden-testimonials').removeClass('active-testimonial');
            // append the newest testimonial
            next.css({opacity: 0}).show().appendTo(container).addClass('active-testimonial').stop().animate({opacity:0.01},1,
            function(){
            var newtestimonial = $('.active-testimonial');
            $('#testimonial-wrapper').animate({height: newtestimonial.height()}, 250, 'easeOutBack',
                function(){
                   $('.active-testimonial').animate({opacity: 1},testimonial.fadeInTime,function(){
                        // This is to restore anti-aliasing from IE filters
                        $(this).css('filter','none');
                   });
                }
            );
        });

        }); 
        
        } else {
            // for IE
            $('.active-testimonial').appendTo('#hidden-testimonials').removeClass('active-testimonial');
            container.html(next).find('.testimonial-body').addClass('active-testimonial');
            $('.active-testimonial').show();
        
        }
              
    },
    init: function(){
         // we want to check to see if user is using IE
          // If Yes, set a quick transition time.
          if (navigator.appName == 'Microsoft Internet Explorer') {
           testimonial.fadeInTime = 15;
           testimonial.fadeOutTime = 100;
          }
    
        setInterval(testimonial.changeTestimonial,testimonial.duration);
    }
    
    

}

testimonial.init();

});
