$(document).ready(function(){
	$(".inlineNav li:first-child").addClass("first");
	$(".inlineNav li:last-child").addClass("last");
	textToLowerCase("#secondaryNav h2");
	accordionContent();
	setSidebarHeight();
	randomTestimonial();
});

function accordionContent() {
	$("#accordion").accordion( { header: 'h3', collapsible: true } );
	$("#accordion h3").hover(
		function() {
			$(this).addClass("hover");
		},
		function() {
			$(this).removeClass("hover");
		}
	); 
}

function randomTestimonial() {
	var testimonials = $("#testimonials p:not(.linkRight)")
	var i = Math.floor(Math.random()*testimonials.length);
	testimonials.hide();
	testimonials.eq(i).show();
}

function textToLowerCase(selector) {
	$(selector).each(function(i){
		var text = $(this).text();
		$(this).text(text.toLowerCase());
	});
}

function setSidebarHeight() {
	var contentHeight = $("#content").outerHeight();
	// var titleHeight = $("h2.pageTitle").outerHeight(true);
	var titleHeight = 68;
	var targetHeight = contentHeight + titleHeight;
	if (targetHeight > 414) {
		targetHeight = 414;
	}
	// alert("contentHeight: " + contentHeight + "\ntitleHeight: " + titleHeight + "\ntargetHeight: " + targetHeight);
	$("#sidebar").height(targetHeight);
}
