$(document).ready(function(){ 

var currQuestion=0;
var frustrationScore=0;
var readinessScore=0;
var totalQuestions = $("#questions p").length-1;
var firstQuestion = $("#questions p:eq("+currQuestion+")").html();
var currValue=0;

$("p.qText").html(firstQuestion); //displays first question on load

$("input[@name=r1]").click(function(){
	$(".submitBtn").attr("disabled", ""); // enables next button when a radio button is clicked...otherwise it stays disabled
});

showCount();
$(".submitBtn").click(
	function() {
		//;
		
		if (currQuestion < totalQuestions){
			
			
			$("p.qText").html( $("#questions p:eq("+(currQuestion+1)+")").html() ); //displays next p element in questions div
			trackAnswers($("input[@name=r1]:checked").val());
			
			currQuestion+=1; //question DOM id tracker
			$(".submitBtn").attr("disabled", "true"); //disables submit button when clicked...ready for next question validation
			$("input[@name=r1]").attr("checked", ""); //removes selected radio button...ready for next question validation
			showCount(); //shows count :) !
			
		}else{
			trackAnswers($("input[@name=r1]:checked").val());
			//alert("frustration score: "+frustrationScore+" "+"\n readiness score: "+readinessScore);
			
			$("#contentWrapper").html( $("#results").html() );
			$("#contentWrapper").css("text-align","");
			$("#frustrationScore").append(frustrationScore);
			$("#readyScore").append(readinessScore);
			
			if (frustrationScore < 45){
				
				$(".response2").hide();
			}else{
				//$("#frustrationScore").append(frustrationScore);
				$(".response1").hide();
			}
			if (readinessScore < 26){
				//$(".response3 #readyScore").append(readinessScore);
				$(".response4").hide();
			}else{
				//$(".response4 #readyScore").append(readinessScore);
				$(".response3").hide();
			}
			
			//$("#contentWrapper).css
		}
	}
	
);

function showCount(){
	$(".count").html((currQuestion+1)+" of "+ (totalQuestions+1));
	if (currQuestion == totalQuestions){
		$(".submitBtn").val("View Results");
		$(".submitBtn").blur();
	}
}


function trackAnswers(answer){

	if (currQuestion <= 5){
		frustrationScore+=parseInt(answer);
		
	}else if (currQuestion > 5 && currQuestion <= 10) {
		readinessScore+=parseInt(answer);
	}
	
}


});
