var contentSwitchActive = 1;
var timeOut;
var divCounter = 0;
function initDynamicHeader(contentID){
	//make it visible 
	$("#testimonial .dynamicContent").css("display", "block");
	$("#testimonial .contentControls").css("display", "block");
	contentSwitchActive = 1;
	$(document).ready(function () {
		dynamicContents = null;
		dynamicContents = new Array;
		arrayPos = 0;
		$(contentID).find(".dynamicContent > div").each(function(){
			$('#testimonial .contentNavPoints').append("<a href='#' onclick='switchDynamicContents("+divCounter+"); return false;'><div class='contentNavPoint'></div></a>");
			$('#testimonial .contentNavPoint:first').addClass("active");
			
			divCounter++;
			dynamicContents.push($(this));
			$(this).attr("class", "dynamicElement element"+divCounter);
			$(this).css("display", "none");
		});
		var middle = ($("#testimonial").width() - $(".contentControls").width())/2; 
		$(".contentControls").css("left", middle);
		$(contentID).find(".dynamicContent div:first").css("display", "block");
		
		if(dynamicContents.length > 0){
			timeOut = setTimeout("switchDynamicContents('next')", 20000);
		}
	});
}

function switchDynamicContents(direction){
	dynamicContents[arrayPos].fadeOut("slow");
	if(direction== "next"){
		if(arrayPos+1 > dynamicContents.length-1){
			arrayPos = 0;
		}else{
			arrayPos++;
		}
	}else if(direction == "prev"){
		if(arrayPos-1 < 0){
			arrayPos = dynamicContents.length-1;
		}else{
			arrayPos--;
		}
	}else{
		clearTimeout(timeOut);
		arrayPos = direction;
	}
	$('#testimonial .contentNavPoint').removeClass("active");
	$('#testimonial .contentNavPoint:eq('+arrayPos+')').addClass("active");
	dynamicContents[arrayPos].fadeIn("slow");
	timeOut = setTimeout("switchDynamicContents('next')", 10000);
}

function nextContent(direction){
	clearTimeout(timeOut);
	if(direction == "next"){
		switchDynamicContents("next");
	}else{
		switchDynamicContents("prev");
	}	
}
