// JavaScript Document
$(document).ready(function(){
	testimonials = new testimonials();
	testimonials.go();
})

function testimonials()
{
	//get the list of items
	this.ul = $('#testimonials ul');
	this.li = $('#testimonials li');
	this.count = $(this.li).length;
	this.index = 0;
	this.time = 7500;
}

testimonials.prototype.go = function()
{
	if (this.count > 1) {
		//hide the testimonials
		$(this.li).hide();
		//relocate the testimonials
		$(this.ul).css('position', 'relative');
		$(this.li).css('position', 'absolute');
		$(this.li).css('top', '0px');
		$(this.li).css('left', '0px');
		//set the up
		this.fadeIn();
	}
}

testimonials.prototype.fadeIn = function()
{
	if (this.count < 2) {
		return;
	}
	if (this.index === this.count) {
		this.index = 0;
	}
	//display the index
	$(this.ul).animate({"height": ($(this.li[this.index]).height())+"px"}, "slow");
	$(this.li[this.index]).fadeIn('slow');
	//set the next timeout for the exit
	window.setTimeout('testimonials.fadeOut()',this.time);
}

testimonials.prototype.fadeOut = function()
{
	//display the index
	$(this.li[this.index]).fadeOut("slow", function(){
		testimonials.fadeIn();
	});
	this.index++
}
