
$(document).ready(function () {
    // get the set of testimonials available
	
	$.getJSON("/model/remote/RemoteTestimonialService.cfc?method=getTestimonialPaths&returnformat=json", handleResponse);
});

handleResponse = function(data){
	testimonials = data;
	//alert(testimonials);
	index = Math.floor(Math.random()*testimonials.length);
	$.get(
		"/testimonials/" + testimonials[index], 
		function(data){
			$("#testimonialBody").html(data);
		}
	);
	/*$("#mainBoxHome #testimonial").attr("src", "/images/testimonials/" + testimonials[index]);
	fadinRunning = false;*/
}

goToTestimonial = function(newIndex){
	index = newIndex;
	$.get(
		"/testimonials/" + testimonials[index], 
		function(data){
			$("#testimonialBody").html(data);
		}
	);
}

/*
fadeinDone = function(){
	var newImg = $("#mainBoxHome #testimonialNew");
	var oldImg = $("#mainBoxHome #testimonial");
	
	oldImg.remove();
	newImg.attr("id", "testimonial");
	fadinRunning = false;
}
*/

getIndex = function(increment){
	var newIndex;
	
	if(index+increment < 0){
		newIndex = index+increment+testimonials.length;
	} else {
		newIndex = (index+increment) % testimonials.length;
	}
	
	return newIndex;
}
