// JavaScript Document

$(document).ready(function()	{

	gallery();						   

   });



function gallery()	{
	
	$(".box a.next").show();
	$(".box #testimonials p").hide().css("min-height", "10px");
	$(".box #testimonials p:first").show();

	numPhotos = $(".box").find("#testimonials p").size();	
	
	var totHeight = 0;
	
	for(i = 1; i <= numPhotos; i++)	{
		currHeight = $(".box #testimonials p:nth-child(" + i + ")").height();
		if(currHeight > totHeight)	{
			totHeight = currHeight; 	
		}
	}
	
	$(".box #testimonials").height(totHeight + 30);

	i = 1;

	$(".box a.next").click(function(e)	{
		e.preventDefault();
		i++;
			if(i <= numPhotos)	{
			
				$(".box #testimonials p:nth-child(" + (i-1) + ")").fadeOut();
				setTimeout(function()	{
					$(".box #testimonials p:nth-child(" + i + ")").fadeIn();
				}, 500);
			} else	{
				i = 1;		
				
				$(".box #testimonials p:nth-child(" + numPhotos + ")").fadeOut();
				setTimeout(function()	{
					$(".box #testimonials p:first").fadeIn();
				}, 500);
			}
			
			if(newHeight < 20)	{
				totalHeight = $(".box #testimonials").parent().height();
				$(".box #testimonials").parent().css("min-height", totalHeight);
			}
	});
	

}