
// ROTATING TESTIMONIAL CODE

$(document).ready(function(){

		// INSTRUCTION: CHANGE MAXTESTIMONIAL TO THE NUMBER OF TESTIMONIAL DIVS
		var maxTestimonial = 7;

		var currentTestimonial = 0;
		var player = true;

		function rotateTestimonials() {

			if(player) {

				$("#testimonial"+currentTestimonial).fadeOut("slow");

				currentTestimonial++;
				if(currentTestimonial > maxTestimonial) currentTestimonial = 1;

				setTimeout(function() {
					$("#testimonial"+currentTestimonial).fadeIn("slow");
				}, 500);

				setTimeout(function () {
					rotateTestimonials();
				}, 10000);

			}

		}

		rotateTestimonials();

		$("#testimonialControlPrev").click(function () {

			player = false;

			$("#testimonial"+currentTestimonial).fadeOut("slow");
			currentTestimonial--;

			if(currentTestimonial < 1) currentTestimonial = maxTestimonial;

			setTimeout(function() {
				$("#testimonial"+currentTestimonial).fadeIn("slow");
			}, 500);

		});

		$("#testimonialControlNext").click(function () {

			player = false;

			$("#testimonial"+currentTestimonial).fadeOut("slow");
			currentTestimonial++;

			if(currentTestimonial > maxTestimonial) currentTestimonial = 1;

			setTimeout(function() {
				$("#testimonial"+currentTestimonial).fadeIn("slow");
			}, 500);

		});

});