function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

$(document).ready(function(){
	
	// Collapse side menus
	submenus = $('#side_menu li a + ul');
	submenus.css('display', 'none');
	
	// Expand side menus of current page
	$('li.current_page_item').parents('ul').css('display', 'list-item');
	$('li.current_page_item ul').css('display', 'list-item');
	
	// Process the "Do You Have Low T?" quiz
	results = $('#results');
	results.css('display', 'none');
	$('#low_t_quiz').submit(function(){
		pageTracker._trackPageview('/quiz-submission');
		var yes_count = 0;
		for (var i = 1; i <= 10; i++){
			answer = getCheckedValue($('#low_t_quiz input[name=answer_' + i + ']'));
			if (answer == 'Yes' && (i == 1 || i ==7)){
				yes_count += 3;
			}
			else if (answer == 'Yes'){
				yes_count++;
			}
		}
		results.css('text-align', 'left');
		if (yes_count >= 3){
			results.html('<h2>Low T Quiz Results</h2><p>Your answers indicate that you may be suffering from Low T. <a href="http://www.testopel.com/wp-content/uploads/2008/12/adam-questionnaire.pdf" target="_blank" class="pdf">Share your results</a> with your healthcare professional and ask about a simple blood test that can help better diagnose Low T and treatment options.</p><div class="clear"></div>');
		}
		else {
			results.html('<h2>Low T Quiz Results</h2><p>Your answers indicate that you are probably not suffering from Low T.</p><div class="clear"></div>');
		}
		if (results.css('display') == 'none'){
			results.slideToggle();
		}
		return false;
	});
	
	// Reset Font Size
	var originalFontSize = $('html').css('font-size');
	$("#normal_text").click(function(){
		$('html').css('font-size', originalFontSize);
	});

	// Increase Font Size
	$("#larger_text").click(function(){
		var currentFontSize = $('html').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum * 1.1;
		$('html').css('font-size', newFontSize);
		return false;
	});

	// Decrease Font Size
	$("#smaller_text").click(function(){
		var currentFontSize = $('html').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum * 0.9;
		$('html').css('font-size', newFontSize);
		return false;
	});
	
});