var count;
var interval;
var previous = 0;
var current = 0;

$(document).ready(function(){
	$("div.video").after("<div id=\"t\"></div>");
	$("#t").load("testimonials.html", function() {
		count = $("div.testimonial").size();
		$("div.testimonial:eq(" + current + ")").css('top', '5px');
		interval = setInterval(testimonialRotate, 7000);

		$('#testimonials').hover(function() {
			clearInterval(interval);
		}, function() {
			interval = setInterval(testimonialRotate,5000);
		});
	});
});

function testimonialRotate() {
	current = (previous + 1) % count;
	$("div.testimonial:eq(" + previous + ")").animate({top: -205}, 1500,  function() { 
		$(this).css('top', '210px');
	});
	$("div.testimonial:eq(" + current + ")").show().animate({top: 5}, 1500);
	previous = current;
}

