var count;
var interval;
var previous = 0;
var current = 0;

$(document).ready(function(){
	$("#t").load("testimonials.html #testimonials", function() {
		count = $("div.testimonial").size();
		$("div.testimonial").css({'top': '5px' , 'display' : 'none'});
		$("div.testimonial:eq(" + current + ")").fadeIn(100, function() {
			if ( $.browser.msie ) 
				this.style.removeAttribute('filter'); // ie7 & prior text anti-aliasing bug fix
		});
		interval = setInterval(testimonialRotate, 5000);

		$('#testimonials').hover(function() {
			clearInterval(interval);
		}, function() {
			interval = setInterval(testimonialRotate,5000);
		});
	});
});

function testimonialRotate() {
	current = (previous + 1) % count;

	$("div.testimonial:eq(" + previous + ")").fadeOut(400, function () {
		$("div.testimonial:eq(" + current + ")").fadeIn(400, function () {
			if ( $.browser.msie ) 
				this.style.removeAttribute('filter'); // ie7 & prior text anti-aliasing bug fix
		});
	});
	previous = current;
}

