var testimonialCycleTime = 5000;//milliseconds
var logoCycleTime = 6000; //milliseconds
var testimonialRotTime = 1000;
var logoRotTime = 1500;
var TFO = $("#testimonialContainer .active");
var LFO = $("#logoContainer .active");
$(document).ready(function(){
	if(typeof(LFO)!="undefined"){
		$(document).oneTime(logoCycleTime,"logoCycle", function(){
			rotateLogo();
		});
	}
	if(typeof(TFO)!="undefined"){
		$(document).oneTime(testimonialCycleTime,"testimonialCycle", function(){
			rotateTestimonial();
		});
	}
}); 

function rotateTestimonial(){
	var obj = $("#testimonialContainer .active");
	var nextobj = $("#testimonialContainer .active").next();
	if(String(nextobj.attr("id")) == "undefined"){
		nextobj = TFO;
	}
	obj.fadeOut(testimonialRotTime, function(){
		obj.removeClass("active");
		nextobj.fadeIn(testimonialRotTime, function(){
			$(document).oneTime(testimonialCycleTime,"testimonialCycle", function(){
				rotateTestimonial();
			});
		nextobj.addClass("active"	);
		});
	});
	
}

function rotateLogo(){
	var obj = $("#logoContainer .active");
	var nextobj = $("#logoContainer .active").next();

	if(String(nextobj.attr("id")) == "undefined"){
		nextobj = LFO;
	}
	obj.fadeOut(logoRotTime, function(){
		obj.removeClass("active");
		nextobj.fadeIn(logoRotTime, function (){
			$(document).oneTime(logoCycleTime,"logoCycle", function(){
				rotateLogo();
			});
		nextobj.addClass("active");
		});
	});
}
